Skip to main content
Connectors

Slack

Talk to an agent by mentioning it in a Slack channel or thread.

SlackRoute/slack/eventsAgent Actorreceive, replywebhookreceive()chat.postMessage

Quickstart

Create a Slack app

In Slack’s app settings, create an app, add the app_mentions:read and chat:write bot token scopes, and install it to your workspace. Copy the bot token and the signing secret.

Add the route

npm add @rivet-dev/pi rivetkit hono @slack/web-api

Run the server with any runtime that serves a fetch handler, for example npx srvx --import tsx server.ts. See HTTP Server.

Set the environment

SLACK_SIGNING_SECRET=...
SLACK_BOT_TOKEN=xoxb-...
ANTHROPIC_API_KEY=sk-ant-...

Subscribe to mentions

Under Event Subscriptions, set the request URL to https://<your-worker>/slack/events and subscribe to the app_mention bot event. Slack sends a challenge, which the route answers. Mention the app in a channel to start a conversation.

How it works

  • The route verifies Slack’s signature against the raw body and rejects requests older than five minutes.
  • Each Slack thread gets its own agent, keyed by team, channel, and thread. Mentioning the app again in the thread continues the same session.
  • Slack expects a response within three seconds and an agent run takes longer, so the route only hands the message to the agent’s receive action and returns. receive schedules reply, which prompts the agent and posts the answer in the thread with the Slack Web API. The schedule is saved with the agent, so the reply still runs if the request that delivered the message goes away.
  • Slack retries events it thinks timed out. The route ignores retries, because the first delivery is already being answered.

Configure

VariablePurpose
SLACK_SIGNING_SECRETRequired. Verifies that requests come from Slack.
SLACK_BOT_TOKENRequired. Posts replies with the Slack Web API.
ANTHROPIC_API_KEYRequired. The agent’s model key. See API Keys.

Supported events

Slack surfaceWebhook pathWhat the route does
Event Subscriptions, app_mention/slack/eventsHands the message to the thread’s agent, which replies in the thread.
URL verification/slack/eventsAnswers Slack’s challenge.

To answer direct messages too, subscribe to message.im, add the im:history scope, and handle message events the same way.