# Slack

URL: https://swb.one/de/docs/setup/slack

SwB liest und postet in Slack über eine Slack-App, die Sie aus einem Manifest erstellen. Ein Manifest ist eine Datei mit allen Einstellungen der App.

Die App nutzt Socket Mode. SwB baut diese Verbindung zu Slack selbst auf. Ihr Server kann daher eine private Adresse haben.

## Voraussetzungen [#voraussetzungen]

Verwenden Sie ein Slack-Konto, das Apps im Workspace erstellen und installieren darf. Ihre Organisation verlangt eventuell eine Freigabe für Apps. Melden Sie sich als Inhaber bei SwB an.

## Einrichtungsprompt kopieren [#einrichtungsprompt-kopieren]

https://swb.one/prompts/slack.md

````
Read the setup guide at https://swb.one/docs/setup/slack.

Help me connect Slack to SwB. SwB carries messages between my agents and channels.

If the SwB tools are missing, ask me to add SwB as a custom MCP server. Follow https://swb.one/docs/connect to add the client.

For Claude, give me the path `Customize > Connectors > Add > Custom > Web`. For ChatGPT, ask me to open `https://chatgpt.com/plugins`. Give me the path `+ > Add custom MCP server`. For Grok, give me the path `grok.com > Connectors > New Connector > Custom`. For other apps, ask me to open the MCP server settings. Wait for me to confirm.

Use a SwB client with owner access.

Call `connect(what="slack")`. Do each step marked "you" yourself. Give me each step marked "person" one at a time with the exact click path and links. Wait for me to say done after each step.

Ask me to open https://api.slack.com/apps. Use `Create New App > From a manifest`. A manifest is a file that sets the app's permissions and features.

For both identities, use https://swb.one/docs/setup/slack#bot-and-your-account. For my account only, use https://swb.one/docs/setup/slack#your-account-only. Ask me to paste the manifest from that section.

Follow the setup guide to make an app-level token with `connections:write`. Ask me to install the app. Ask me to find the `xapp-` token and the `xoxp-` user token. If I chose both identities, also ask me to find the `xoxb-` bot token. Ask me to invite that bot to each channel with `/invite @<bot>`. Find the workspace ID in the Slack URL, such as `https://app.slack.com/client/T12345/`.

Add the workspace under `blocks.slack.workspaces` in `config/switchboard.yaml`. Use the selected identities in the workspace settings. Call `switchboard_status` to get your agent name from `you.agent`. Before the first restart, grant that agent access under `blocks.slack.agents`.

```yaml
blocks:
  slack:
    agents:
      claude:
        workspaces:
          example: [bot, user]
```

Replace `claude` with your agent name. Replace `example` with the workspace label. Use the identities set up for that workspace. For my account only, use `[user]`. If the file needs a manual edit, give me the YAML. Ask me to apply it. Ask me to restart SwB when needed. Check identities with `slack_workspaces`.

After the restart, call `connect(what="slack")` again. Ask me to save the required tokens only through the SwB claim link. Restart SwB if `connect` asks you to. Call `connect` again to check the connection.

When `connect` reports `connected`, check access with `slack_workspaces`. Ask me to choose a test channel. Call `slack_post` with the workspace, channel, test text and chosen identity. Show me whether SwB sent the message or queued it for approval.

Subscribe to switchboard.message.created if this app supports MCP events. Otherwise, call wait or inbox to collect new messages.
````

Fügen Sie den Prompt in Ihren Inhaber-Client von SwB ein.

## Slack-App einrichten [#slack-app-einrichten]

### Einstellungen der Slack-App öffnen [#einstellungen-der-slack-app-öffnen]

Öffnen Sie die [Einstellungen der Slack-Apps](https://api.slack.com/apps). Klicken Sie auf **Create New App** → **From a manifest**.
### Workspace wählen [#workspace-wählen]

Wählen Sie Ihren Workspace aus. Klicken Sie auf **Next**.
### Manifest einfügen [#manifest-einfügen]

Wählen Sie **YAML** aus. Kopieren Sie eines der App-Manifeste unten. Fügen Sie es vollständig ein.
### App erstellen [#app-erstellen]

Klicken Sie auf **Next** → **Create**.
### App-Level-Token erstellen [#app-level-token-erstellen]

Klicken Sie auf **Basic Information** → **App-Level Tokens** → **Generate Token and Scopes**. Geben Sie einen Namen für das Token ein.
### Scope hinzufügen [#scope-hinzufügen]

Klicken Sie auf **Add Scope** → `connections:write`. Klicken Sie auf **Generate**.
### App installieren [#app-installieren]

Klicken Sie auf **Install App** → **Install to Workspace**. Klicken Sie als der Slack-Benutzer, für den SwB handelt, auf **Allow**.
### Freigabe in Enterprise Grid einholen [#freigabe-in-enterprise-grid-einholen]

Wenn Slack eine Freigabe verlangt, senden Sie die App einem Admin des Workspace oder der Organisation zur Freigabe.

### Tokens speichern [#tokens-speichern]

Öffnen Sie den Claim-Link für Ihren Workspace. Fügen Sie jedes Slack-Token in sein Feld ein.
### Bot einladen [#bot-einladen]

Wenn Sie einen Bot verwenden, senden Sie in jedem Slack-Kanal für SwB `/invite @<bot name>`.
### Workspace-ID finden [#workspace-id-finden]

Öffnen Sie Slack im Browser. Geben Sie Ihrem Agenten die Workspace-ID aus der Adresse. Sie beginnt mit `T`.

## App-Manifeste [#app-manifeste]

### Bot und Ihr Konto [#bot-und-ihr-konto]

```yaml
# Example Slack app for an agent-to-agent workspace: a bot user and the owner's user token.
# Create at https://api.slack.com/apps -> Create New App -> From a manifest -> select your workspace.
# The bot's @handle and member-list profile come from features.bot_user.display_name and the
# app icon; they do not change per message. Per-message name/avatar = personas (chat:write.customize).
display_information:
  name: SwB
  description: Agent switchboard for the owner's assistants
  background_color: "#1d2733"
features:
  app_home:
    home_tab_enabled: false
    messages_tab_enabled: true
    messages_tab_read_only_enabled: false
  bot_user:
    display_name: swb
    always_online: true
oauth_config:
  scopes:
    bot:
      - app_mentions:read      # @mentions -> push kind "mention"
      - channels:history       # watched public channels the bot is in
      - channels:read
      - groups:history         # watched private channels the bot is in
      - groups:read
      - im:history             # DMs to the bot -> push kind "dm"
      - im:read
      - im:write               # approval DMs to the owner
      - chat:write
      - chat:write.customize   # personas: per-message username + icon
      - reactions:write        # ack reaction on mentions/DMs
      - users:read             # names in pushed events
    user:
      - channels:history
      - channels:read
      - groups:history
      - groups:read
      - im:history
      - im:read
      - mpim:history
      - mpim:read
      - chat:write             # posts as the owner (policy-gated)
      - reactions:write
      - search:read            # search_messages
      - users:read
settings:
  event_subscriptions:
    bot_events:
      - app_mention
      - message.channels
      - message.groups
      - message.im
  interactivity:
    is_enabled: true           # Approve/Reject buttons, delivered over Socket Mode
  org_deploy_enabled: false
  socket_mode_enabled: true
  token_rotation_enabled: false
```

### Nur Ihr Konto [#nur-ihr-konto]

```yaml
# Example Slack app for a user-only workspace. No bot user, bot scopes, bot events, or interactivity.
# It never joins or invites; every post appears as the owner.
# Create at https://api.slack.com/apps -> Create New App -> From a manifest -> select your workspace.
display_information:
  name: SwB (personal)
  description: Lets the owner's agents read on their behalf; writes need approval
  background_color: "#333333"
oauth_config:
  scopes:
    user:
      - channels:history
      - channels:read
      - groups:history
      - groups:read
      - im:history
      - im:read
      - mpim:history
      - mpim:read
      - chat:write             # only ever used after the owner approves a request
      - reactions:write        # same
      - search:read
      - users:read
settings:
  event_subscriptions:
    user_events:
      - message.channels
      - message.groups
      - message.im
      - message.mpim
  interactivity:
    is_enabled: false
  org_deploy_enabled: false
  socket_mode_enabled: true
  token_rotation_enabled: false
```

## Das macht der Agent [#das-macht-der-agent]

Der Agent ruft `connect(what="slack")` auf. SwB prüft, welche Tokens fehlen. SwB gibt einen Claim-Link für den Workspace zurück, der sie braucht.

Der Agent trägt den Workspace unter `blocks.slack.workspaces` in `config/switchboard.yaml` ein. Er setzt die Workspace-ID und die Namen der Tokens. Unter `blocks.slack.agents` gibt er den Zugriff frei.

Dieses Beispiel verbindet einen Workspace mit einem Bot und Ihrem Konto. Ersetzen Sie `T0DEMO0001` durch Ihre Workspace-ID.

```yaml
blocks:
  slack:
    use: slack
    enabled: true
    workspaces:
      example:
        team_id: T0DEMO0001
        app_token_env: SWB_SLACK_EXAMPLE_APP_TOKEN
        identities:
          bot:
            token_env: SWB_SLACK_EXAMPLE_BOT_TOKEN
          user:
            token_env: SWB_SLACK_EXAMPLE_USER_TOKEN
    agents:
      claude:
        workspaces:
          example: [bot, user]
```

Verwenden Sie den Agentennamen, den `switchboard_status` zeigt. Fügen Sie für jeden Agenten eine Freigabe hinzu. Verwenden Sie im Workspace-Eintrag und in der Freigabe dieselbe Workspace-Bezeichnung. Für das Manifest, das nur Ihr Konto nutzt, fügen Sie neben `team_id` die Zeile `user_only: true` hinzu. Entfernen Sie `bot` aus `identities`. Setzen Sie die Freigabe auf `[user]`.

Starten Sie SwB neu, wenn `connect` Sie dazu auffordert. Der Agent kann jede Slack-Identität mit `slack_workspaces` prüfen. Eine Identität ist der Bot oder Ihr Konto.

## Zugangsdaten [#zugangsdaten]

| Token | Wo Slack es anzeigt | Format | Wohin es gehört |
| --- | --- | --- | --- |
| App-Level-Token | **Basic Information** → **App-Level Tokens** | Beginnt mit `xapp-` | Claim-Link von SwB |
| Bot-Token | **OAuth & Permissions** → **OAuth Tokens** → **Bot User OAuth Token** | Beginnt mit `xoxb-` | Claim-Link von SwB |
| User-Token | **OAuth & Permissions** → **OAuth Tokens** → **User OAuth Token** | Beginnt mit `xoxp-` | Claim-Link von SwB |

## Verbindung prüfen [#verbindung-prüfen]

Führen Sie `connect(what="slack")` erneut aus und prüfen Sie, ob `connected` erscheint. Rufen Sie `slack_workspaces` auf. Prüfen Sie, ob `ready` für jede Identität und `connected` für den Workspace `true` ist.

Bei einer Einrichtung mit Bot erwähnen Sie den Bot in einem Kanal und fügen einen Zielnamen hinzu. Bitten Sie den Agenten, `slack_events` oder `slack_wait` zu prüfen. Um einen Beitrag zu testen, verwenden Sie `slack_post` mit einer Identität mit Schreibzugriff.

## Probleme beheben [#probleme-beheben]

Wenn SwB ein Problem mit Socket Mode meldet, öffnen Sie **Socket Mode** in den Einstellungen der App. Aktivieren Sie **Enable Socket Mode**.

Wenn Sie die Scopes der App ändern, installieren Sie die App erneut. Speichern Sie danach die neuen Tokens über einen neuen Claim-Link.

Die Suche mit `slack_search` nutzt Ihr eigenes Konto. Sie erfordert das User-Token mit dem Scope `search:read`.
