Reach agents from Slack¶
The slack connector lets agents talk in a Slack workspace, and lets a Slack message start
work. It is slack-mcp, a small server that Agent Loops makes (#1351). It speaks as the bot of a
Slack app that you make, and it uses Socket Mode, so Slack needs no public address.
- The event
message.received: a message came into a channel the bot is in, or to the bot directly. Replies in threads come too; the bot's own messages and other bots' do not. Filters:channel,user,thread(the ts of a thread's first message) andmentions(true: only messages that mention the bot, and direct messages). Its data is the channel, the user, the message's ts and its thread's, and whether it mentions the bot. It never holds the text. - The event
question.answered: someone pressed an option on a question thatask_questionposted. Filters:questionandchannel. Its data is the question's id, who answered, and the option (its words and its place, from 0). Only the first answer counts. The question then says who answered, and its buttons go. - The tools:
list_conversationsandlist_channels(where the bot is),read_messages(a conversation's messages, or a thread's, newest first, a page at a time by itscursor),send_messageandask_question(options as buttons).read_messagesgives the text marked as outside content: an agent reads it as data, never as instructions. The server refuses to send@channel,@hereor@everyone. It cannot edit or delete a message.list_conversationsandread_messagesfollow the messaging contract, so the Messages page can read Slack. Slack gives a bot no unread counts, so a conversation has nounread.
A message acts as a person only when that person has linked their Slack user (see
Channels). The identity is the workspace and the user, as
T0123/U0456. The server gives Slack's name and email for the user, so the first message
asks the person whose sign-in email is that email.
Before you start¶
- A Slack workspace where you can make and install an app.
- Agent Loops on the Mac carries
slack-mcp, and every Linux host installs it beside agentsd.
Make the Slack app¶
- Open https://api.slack.com/apps, choose Create New App ▸ From a manifest, and choose your workspace.
- Paste this manifest, and change the name if you want:
display_information:
name: Agents
features:
bot_user:
display_name: Agents
always_online: true
oauth_config:
scopes:
bot:
- app_mentions:read
- channels:history
- channels:read
- chat:write
- groups:history
- groups:read
- im:history
- im:read
- mpim:history
- mpim:read
- users:read
- users:read.email
settings:
event_subscriptions:
bot_events:
- app_mention
- message.channels
- message.groups
- message.im
- message.mpim
interactivity:
is_enabled: true
socket_mode_enabled: true
- Choose Install to Workspace, and allow it. Copy the Bot User OAuth Token
(
xoxb-…) from OAuth & Permissions. - In Basic Information ▸ App-Level Tokens, choose Generate Token and Scopes, add
the scope
connections:write, and copy the token (xapp-…). - In Slack, invite the bot to each channel it must hear:
/invite @Agents.
Add the connector¶
- Add Slack from the Agent Loops marketplace in the catalogue (Settings ▸ Agent Configuration ▸ Connectors ▸ Add Connector…, or Change… ▸ Slack… in the connectors set-up's Messaging slot).
- It asks for
SLACK_BOT_TOKEN, thexoxb-token, andSLACK_APP_TOKEN, thexapp-token. Their values are sealed in~/.agents-secrets/sealed.json. - Choose Add. The entry it writes runs
slack-mcphosted, one copy on the host:
{ "mcpServers": { "slack": { "command": "slack-mcp", "hosted": true,
"env": { "SLACK_BOT_TOKEN": "${SLACK_BOT_TOKEN}", "SLACK_APP_TOKEN": "${SLACK_APP_TOKEN}" } } } }
Start work from Slack¶
- A workflow on
message.receivedwithmentions: truestarts an agent when someone mentions the bot. The agent reads the message withread_messages(conversationandthread: the event'schannel, and itsthreadTsor else itsts), and answers in the thread withsend_message. See Start a workflow from an MCP event. - An agent that needs a choice from someone asks with
ask_question, and waits forquestion.answeredwith thequestionid it got.
Limits¶
- Slack sends each event once, to one open connection, and only while one is open. Run one
slack-mcpfor each Slack app: a second copy gets a share of the events. A message that comes while no copy runs is lost. - The server keeps the last 1,000 events in memory. A poll after more than that says
truncated.