Connecting Slack

Create the App

At https://api.slack.com/apps choose Create New App → From scratch, name it, and pick the workspace.

Note the app id now — it is in the address bar, https://api.slack.com/apps/ A0123ABCDEF/…, and every settings page hangs off it. Two apps with the same name are indistinguishable in the app list, and configuring the wrong twin produces the least obvious failure in this document: a fully configured Event Subscriptions page that never delivers, because the app receiving the messages is the other one. If you ever suspect it, ask Slack which app owns the bot people are actually talking to:

curl -H "Authorization: Bearer xoxb-…" https://slack.com/api/auth.test
curl -H "Authorization: Bearer xoxb-…" "https://slack.com/api/bots.info?bot=B0123ABCDEF"
# → "app_id": "A0123ABCDEF"  — configure that one

Delete the spare rather than leaving it around.

Add Bot Token Scopes

Under OAuth & Permissions → Bot Token Scopes, add:

Scope Needed for
app_mentions:read Receiving @-mentions.
chat:write Posting, editing and deleting the bot's messages.
commands Slash commands.
im:history, im:read, im:write Direct messages, including conversation.directMessage().
mpim:write conversation.includePeople() — opening the group direct message the people are brought into.
mpim:history, mpim:read Group direct messages — the adapter treats them as group conversations, so without these it is deaf in them.
channels:history, groups:history conversation.transcript() in public and private channels.
channels:read, groups:read Membership events. Slack refuses the member_joined_channel / member_left_channel subscriptions without them.
reactions:read Reaction events. Likewise: reaction_added cannot be subscribed to without it. Reading reactions is a separate scope from placing them.
reactions:write conversation.react().
users:read conversation.profile(), and resolving a mention() to a name.
users:read.email The email on a profile.
files:write conversation.upload().
files:read conversation.download(attachment). message.attachments[].url is url_private — not public, and fetched with the bot token. Without the scope Slack answers with its sign-in page under HTTP 200 rather than an error, which is why a bot must never fetch that URL itself.

Worth adding now, even if unused yet

Adding a scope later means re-installing the app in every workspace, so add these while you are on the page:

Scope Buys you
chat:write.public Posting to a public channel the bot was never invited to. Without it, conversation.sendTo() to a channel-by-id fails with not_in_channel — the usual surprise when a bot is wired to announce something.
channels:join Letting the bot add itself to a public channel rather than needing a human to invite it.
usergroups:read Resolving <!subteam^S…> — a user-group mention currently renders as its raw id.
emoji:read Resolving a workspace's custom emoji, so a reaction event names something readable.
team:read Workspace name and domain, which is what a message permalink needs.

Not added, deliberately: chat:write.customize (overriding the bot's name and avatar per message makes a bot look like it is impersonating somebody), links:read / links:write (unfurling is not implemented), and any *:write scope on channels themselves — a support bot has no business renaming or archiving anything.

Install the app to the workspace and copy the Bot User OAuth Token (xoxb-…).

Secrets

wrangler secret put SLACK_BOT_TOKEN        # xoxb-…
wrangler secret put SLACK_SIGNING_SECRET   # Basic Information → Signing Secret
wrangler secret put SLACK_BOT_USER_ID      # Uxxxx — see below

SLACK_BOT_USER_ID is optional — Events API deliveries carry the bot's identity — but setting it makes mention detection work for the payloads that do not.

The app's settings do not show it anywhere. Do not hunt for it under OAuth & Permissions; ask Slack instead, once the token exists:

curl -H "Authorization: Bearer xoxb-…" https://slack.com/api/auth.test
# {"ok":true,"user":"your-bot","user_id":"U0123456789","bot_id":"B0123456789", …}

user_id (U…) is the value. bot_id (B…) is a different identifier and is not what this variable wants.

Without SLACK_BOT_TOKEN the adapter reports Slack as not configured and the bot simply serves no Slack routes. A token without a signing secret fails the deployment, rather than leaving the endpoint unauthenticated.

Point Slack at the Worker

The Worker must be reachable before you start this step. Slack verifies a Request URL the moment you enter it, by posting a url_verification challenge the adapter answers automatically. Against a Worker that is not up, verification fails and the URL is not saved — so deploy first, or start wrangler dev and a tunnel. Confirm with curl https://<worker>/health before touching Slack.

All three surfaces use the same URL — the adapter dispatches on content type, so there is nothing to keep in step later:

https://<worker>/slack/events

Event Subscriptions

  1. Turn Enable Events on.

  2. Paste the URL and wait for the green Verified.

  3. Expand Subscribe to bot events — it is collapsed by default, below the URL, and is easy to miss once the URL has gone green. Add all nine the adapter handles: app_mention, message.im, message.channels, message.groups, message.mpim, reaction_added, reaction_removed, member_joined_channel, member_left_channel.

    Subscribing to only half of a pair is the quieter mistake: a bot that sees reaction_added but not reaction_removed believes every reaction is still there.

  4. Click Save Changes. The two halves of this page persist differently: the Request URL saves itself the instant it verifies, the event list does not. Until you press the button the events you added live only in the browser — they look exactly like saved ones and disappear on reload. A verified URL with an unsaved event list is a page that looks finished and delivers nothing.

  5. Reload the page and check the nine events are still listed. That is the only proof they were stored.

  6. Reinstall the app if Slack shows the banner asking you to.

Interactivity and Shortcuts

Turn the Interactivity toggle on and the Request URL field appears; paste the same URL. Shortcuts are a separate, optional section further down — you do not need one. Buttons and select menus arrive here rather than on the events URL, so without this the bot answers questions but every button does nothing.

Slash Commands

There is no page-level URL here: it is a field inside each command. Create New Command, then fill in /your-command, the same Request URL, a short description and a usage hint. Leave Escape channels, users, and links unticked — it rewrites @name and URLs into Slack's markup inside the command text, which is noise for whatever reads the question.

The command name is yours to choose. parseSlashCommand strips the leading slash and passes through whatever arrives, and onCommand receives it.

App Home — Required for Direct Messages

Features → App Home → Show Tabs → Messages Tab: turn it on, then tick "Allow users to send Slash commands and messages from the messages tab".

Both are needed. Without them the DM conversation is read-only: Slack refuses the message client-side with "Slack couldn't send this message", so nothing is ever sent, no event is generated, and the bot looks broken while the endpoint is perfectly healthy. Reload Slack (Cmd+R) afterwards — the client caches the conversation as read-only until it re-fetches the app config.

The message.im subscription and the im:history scope are the other half of this; all three are required for a DM to reach the bot.

Turn Off Socket Mode

Settings → Socket Mode must be off. With it on, Slack delivers events over a WebSocket and never calls the Request URL — while Event Subscriptions carries on showing the URL as verified and the events as subscribed. Wingman is an HTTP bot; a Worker cannot hold a socket open to Slack.

Check It Works

In order, because each step depends on the one before:

# 1. The Worker is up and serving Slack (an empty list means no credentials).
curl -s https://<worker>/health
# {"status":"ok","bot":"…","platforms":["slack"]}

# 2. The token is valid and names the bot you expect.
curl -s -H "Authorization: Bearer xoxb-…" https://slack.com/api/auth.test

# 3. The bot is in the channel you are testing in.
curl -s -H "Authorization: Bearer xoxb-…" \
  "https://slack.com/api/users.conversations?types=public_channel,im"

Then DM the bot, or @mention it in a channel it belongs to. A plain message in a channel is deliberately ignored — isAddressedToBot keeps the bot quiet unless it is mentioned. In a direct conversation every message counts as addressed, so no mention is needed there.

If nothing happens, the question that splits the problem in half is did the request arrive. Check the Worker's log, or the tunnel's (http://127.0.0.1:4040 for ngrok). Nothing at all means Slack is not delivering, and the fault is in this page's configuration rather than in the bot.

Troubleshooting

Symptom Cause
"Slack couldn't send this message" when you DM the bot The App Home Messages Tab is off, or its "allow users to send…" box is unticked. Step 5.
URL verification fails The Worker is not reachable. Verify https://<worker>/health answers first.
URL verified, events listed, nothing ever delivered The event list was never saved (step 4.4), or Socket Mode is on (step 6).
Everything configured, still nothing — and the app looks perfect You are configuring a different app with the same name. Check the app id against bots.info. Step 1.
Bot answers in channel but ignores buttons The Interactivity URL is unset; it is configured separately from events.
Bot ignores plain channel messages By design — mention it, or DM it.
not_in_channel when posting The bot is not in that channel; invite it, or add chat:write.public.
missing_scope Add the scope, then reinstall — scope changes need a new install.
invalid_auth after reinstalling The bot token rotated. Copy the new xoxb-… and restart the Worker.

Security

Every inbound request is verified against the signing secret — HMAC-SHA256 over v0:{timestamp}:{body}, compared in constant time, with a five-minute freshness window so a captured request cannot be replayed. An unsigned or stale request gets an opaque 400.

Related: Capabilities, Deploying a bot, Troubleshooting.

← Chat platformsConnecting Google Chat →