Zum Inhalt springen

Slack

Der Slack-Provider integriert Ihren digitalen Worker in Slack-Workspaces. Er unterstützt:

  • Direktnachrichten (DMs)
  • Kanalnachrichten
  • App-Erwähnungen
  • Interaktive Komponenten (Buttons, Menüs)
  • Block Kit Rich Messaging
  • Slash-Befehle
  • Thread-Antworten
  • Ein Slack-Workspace
  • Admin-Zugriff, um eine Slack-App zu erstellen
  1. Eine Slack-App erstellen

    Gehen Sie zu api.slack.com/apps und klicken Sie auf “Create New App”:

    • Wählen Sie “From scratch”
    • Geben Sie einen App-Namen ein (z. B. “My Support Bot”)
    • Wählen Sie Ihren Workspace aus
  2. Bot-Token-Scopes konfigurieren

    Gehen Sie zu OAuth & PermissionsScopesBot Token Scopes:

    Erforderliche Scopes:

    • chat:write - Nachrichten senden
    • im:history - DM-Verlauf lesen
    • im:write - DMs öffnen
    • users:read - Benutzerinformationen lesen

    Optionale Scopes:

    • channels:history - Kanalnachrichten lesen
    • channels:read - Kanäle auflisten
    • files:read - Dateien lesen
    • files:write - Dateien hochladen
  3. Event Subscriptions aktivieren

    Gehen Sie zu Event Subscriptions:

    • Aktivieren Sie Events
    • Setzen Sie die Request URL: https://your-domain.com/webhook/slack/{tenant}/{team}

    Abonnieren Sie Bot-Events:

    • message.im - DM-Nachrichten
    • message.channels - Kanalnachrichten
    • app_mention - @mentions
  4. Interaktivität aktivieren

    Gehen Sie zu Interactivity & Shortcuts:

    • Aktivieren Sie Interactivity
    • Setzen Sie die Request URL: https://your-domain.com/webhook/slack/{tenant}/{team}/interactive
  5. App im Workspace installieren

    Gehen Sie zu Install AppInstall to Workspace

    Kopieren Sie das Bot User OAuth Token (beginnt mit xoxb-)

  6. App-Zugangsdaten abrufen

    Aus Basic Information:

    • App ID
    • Configuration Token (für Manifest-Updates)
  7. Provider konfigurieren

    answers.json
    {
    "messaging-slack": {
    "enabled": true,
    "public_base_url": "https://your-domain.ngrok-free.app",
    "api_base_url": "https://slack.com/api",
    "bot_token": "xoxb-xxx-xxx-xxx",
    "slack_app_id": "A07XXXXXX",
    "slack_configuration_token": "xoxe.xoxp-xxx"
    }
    }
  8. Setup ausführen

    Terminal-Fenster
    gtc setup --answers answers.json ./my-bundle
OptionErforderlichBeschreibung
enabledJaDen Provider aktivieren/deaktivieren
public_base_urlJaÖffentliche URL für Webhooks
bot_tokenJaBot User OAuth Token (xoxb-...)
slack_app_idJaApp ID aus Basic Information
slack_configuration_tokenNeinFür automatische Manifest-Updates
api_base_urlNeinSlack-API-URL (Standard: https://slack.com/api)
- id: reply
type: reply
config:
message: "Hello! How can I help you?"

Slack verwendet das Format mrkdwn:

- id: formatted
type: reply
config:
message: |
*Bold* _Italic_ `code`
>Blockquote
• Bullet point

Verwenden Sie das Block Kit von Slack für umfangreiche Layouts:

- id: rich_message
type: reply
config:
blocks:
- type: section
text:
type: mrkdwn
text: "*Welcome!*\nHow can I assist you today?"
- type: divider
- type: actions
elements:
- type: button
text:
type: plain_text
text: "Get Help"
action_id: "help_clicked"
value: "help"
- type: button
text:
type: plain_text
text: "View Status"
action_id: "status_clicked"
value: "status"
- id: ask_action
type: reply
config:
message: "What would you like to do?"
blocks:
- type: actions
elements:
- type: button
text:
type: plain_text
text: "Create Ticket"
style: primary
action_id: "create_ticket"
- type: button
text:
type: plain_text
text: "Cancel"
style: danger
action_id: "cancel"
- id: select_option
type: reply
config:
blocks:
- type: section
text:
type: mrkdwn
text: "Select a category:"
accessory:
type: static_select
action_id: "category_select"
options:
- text:
type: plain_text
text: "Technical Support"
value: "technical"
- text:
type: plain_text
text: "Billing"
value: "billing"
- text:
type: plain_text
text: "General"
value: "general"

In einem Thread antworten:

- id: thread_reply
type: reply
config:
message: "This replies in the thread"
thread_ts: "{{original_message.thread_ts}}"
- id: upload_file
type: reply
config:
files:
- url: "https://example.com/report.pdf"
filename: "report.pdf"
title: "Monthly Report"

Nachrichten, die nur für einen Benutzer sichtbar sind:

- id: ephemeral
type: reply
config:
message: "Only you can see this"
ephemeral: true
user: "{{user_id}}"
flows/on_interaction.ygtc
name: handle_interaction
version: "1.0"
nodes:
- id: route_action
type: branch
config:
conditions:
- expression: "action_id == 'help_clicked'"
next: show_help
- expression: "action_id == 'create_ticket'"
next: create_ticket
default: unknown_action
- id: show_help
type: reply
config:
message: "Here's how I can help..."
triggers:
- type: block_action
target: route_action
- id: handle_select
type: branch
config:
conditions:
- expression: "selected_value == 'technical'"
next: technical_flow
- expression: "selected_value == 'billing'"
next: billing_flow
  1. Gehen Sie in Ihren App-Einstellungen zu Slash Commands
  2. Erstellen Sie einen Befehl (z. B. /support)
  3. Setzen Sie die Request URL auf Ihren Webhook

Verarbeiten Sie ihn in Ihrem Flow:

flows/slash_command.ygtc
name: slash_command
version: "1.0"
nodes:
- id: handle_command
type: reply
config:
message: "Support bot at your service!"
response_type: in_channel # or "ephemeral"
triggers:
- type: slash_command
command: "/support"
target: handle_command
greentic.demo.yaml
tenants:
demo:
teams:
support:
channels:
slack:
provider: messaging-slack
config:
channel_id: "C1234567890"
tenants:
demo:
teams:
support:
channels:
slack-general:
provider: messaging-slack
config:
channel_id: "C1234567890"
slack-vip:
provider: messaging-slack
config:
channel_id: "C0987654321"
  1. Event Subscriptions prüfen:

    • Prüfen Sie, ob die Request URL korrekt ist
    • Stellen Sie sicher, dass Events aktiviert sind
    • Prüfen Sie, ob der Bot die richtigen Events abonniert hat
  2. Bot-Berechtigungen prüfen:

    • Installieren Sie die App nach dem Hinzufügen von Scopes erneut
    • Prüfen Sie, ob sich der Bot im Kanal befindet
  3. Webhook testen:

    Terminal-Fenster
    curl https://your-domain.com/webhook/slack/demo/default

Ihr Bot-Token ist ungültig oder abgelaufen. Holen Sie sich ein neues Token unter OAuth & Permissions.

  • Prüfen Sie, ob die Kanal-ID korrekt ist
  • Stellen Sie sicher, dass der Bot zum Kanal hinzugefügt wurde
  • Prüfen Sie, ob der Kanal nicht archiviert ist

Die Slack-Limits variieren je nach Methode. Behandeln Sie sie sauber:

- id: reply
type: reply
config:
message: "Response"
retry_on_rate_limit: true
max_retries: 3

Greentic validiert automatisch:

  • Request-Zeitstempel
  • Signatur mit dem Signing Secret
  • Token-Verifizierung