# Slack

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

SwB reads and posts in Slack through a Slack app that you make from a manifest. A manifest is a file that holds all the settings of the app.

The app uses Socket Mode. SwB opens this connection to Slack, so your server can use a private address.

## Before you start [#before-you-start]

Use a Slack account that can create and install apps in the workspace. Your organization may require app approval. Sign in to SwB as the owner.

## Copy the setup prompt [#copy-the-setup-prompt]

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.
````

Paste the prompt into your SwB owner client.

## Set up the Slack app [#set-up-the-slack-app]

### Open the Slack app settings [#open-the-slack-app-settings]

Open [Slack app settings](https://api.slack.com/apps). Click **Create New App** → **From a manifest**.
### Select the workspace [#select-the-workspace]

Select your workspace. Click **Next**.
### Paste the manifest [#paste-the-manifest]

Select **YAML**. Copy one of the app manifests below. Paste it in full.
### Create the app [#create-the-app]

Click **Next** → **Create**.
### Make the app-level token [#make-the-app-level-token]

Click **Basic Information** → **App-Level Tokens** → **Generate Token and Scopes**. Type a name for the token.
### Add the scope [#add-the-scope]

Click **Add Scope** → `connections:write`. Click **Generate**.
### Install the app [#install-the-app]

Click **Install App** → **Install to Workspace**. Click **Allow** as the Slack user that SwB acts for.
### Get approval in Enterprise Grid [#get-approval-in-enterprise-grid]

If Slack asks for approval, send the app to a workspace or organization admin for approval.

### Save the tokens [#save-the-tokens]

Open the claim link for your workspace. Paste each Slack token into its field.
### Invite the bot [#invite-the-bot]

If you use a bot, send `/invite @<bot name>` in each Slack channel for SwB.
### Find the workspace ID [#find-the-workspace-id]

Open Slack in a browser. Give your agent the workspace ID from the address. It starts with `T`.

## App manifests [#app-manifests]

### Bot and your account [#bot-and-your-account]

```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
```

### Your account only [#your-account-only]

```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
```

## What the agent does [#what-the-agent-does]

The agent calls `connect(what="slack")`. SwB checks which tokens are missing. It returns a claim link for the workspace that needs them.

The agent adds the workspace under `blocks.slack.workspaces` in `config/switchboard.yaml`. It sets the workspace ID and token names. It grants access under `blocks.slack.agents`.

This example connects one workspace with a bot and your account. Replace `T0DEMO0001` with your 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]
```

Use the agent name that `switchboard_status` shows. Add one grant for each agent. Use the same workspace label in the workspace entry and the grant. For the account-only manifest, add `user_only: true` next to `team_id`. Remove `bot` from `identities`. Set the grant to `[user]`.

Restart SwB when `connect` asks. The agent can check each Slack identity with `slack_workspaces`. An identity is the bot or your account.

## Credentials [#credentials]

| Token | Where Slack shows it | Format | Where it goes |
| --- | --- | --- | --- |
| App-level token | **Basic Information** → **App-Level Tokens** | Starts with `xapp-` | SwB claim link |
| Bot token | **OAuth & Permissions** → **OAuth Tokens** → **Bot User OAuth Token** | Starts with `xoxb-` | SwB claim link |
| User token | **OAuth & Permissions** → **OAuth Tokens** → **User OAuth Token** | Starts with `xoxp-` | SwB claim link |

## Check the connection [#check-the-connection]

Run `connect(what="slack")` again and check for `connected`. Call `slack_workspaces`. Check that `ready` is `true` for each identity and `connected` is `true` for the workspace.

For bot setup, mention the bot in a channel and add a target name. Ask the agent to check `slack_events` or `slack_wait`. To test a post, use `slack_post` from an identity with write access.

## Fix problems [#fix-problems]

If SwB reports a Socket Mode problem, open **Socket Mode** in the app settings. Turn on **Enable Socket Mode**.

If you change the scopes of the app, install the app again. Then save the new tokens through a new claim link.

Search with `slack_search` uses your own account. It needs the user token with the scope `search:read`.
