Slack
Connect an agent to Slack: Socket Mode setup, in-thread replies, and observer agents.
Triggers turn an agent into a long-lived service that waits for events, acts on them, delivers the result, and goes idle. The slack trigger connects that loop to a Slack workspace over Socket Mode — an outbound WebSocket, so the agent needs no public endpoint. It watches channels and replies in a thread under the messages that wake it.
triggers:
- type: slack
channels: ["help"] # names or ids; omit for all channels the bot is in
# require_mention: true # only respond when @-mentioned (DMs always respond)
# token_env: SLACK_BOT_TOKEN (default)
# app_token_env: SLACK_APP_TOKEN (default)
# from_users: ["U0HAPPY"] # only handle these authors (Slack user ids)
# reply_channel: "C0REVIEW" # post replies here instead of the source thread
# allow_silence: true # a reply of exactly __NO_REPLY__ posts nothingSetup
Setting up the Slack app takes about 10 minutes:
- In api.slack.com/apps, create a new app (from scratch) in your workspace.
- Under Socket Mode, enable it and generate an app-level token with the
connections:writescope — this isSLACK_APP_TOKEN(xapp-…). - Under OAuth & Permissions, add the bot scopes
chat:write,channels:history,groups:history,im:history, andchannels:read, then install the app to the workspace. The bot token it produces isSLACK_BOT_TOKEN(xoxb-…). - Under Event Subscriptions, enable events and subscribe to the bot events
message.channels,message.groups, andmessage.im. Missing event subscriptions are the most common setup failure — the socket connects but nothing arrives. - Export both tokens, invite the bot to a channel (
/invite @your-bot), and run the agent:af run agent.yaml
Replies go into a thread under the triggering message; conversations are keyed per thread (a DM is one rolling conversation), and memory.scope: thread continues them (Memory). The agent ignores bots, itself, message edits, and empty messages; long replies split at Slack's recommended 4000-char limit. If you change scopes later, reinstall the app — Slack applies them only on install.
Observer agents
Three optional keys together turn the trigger from a chatbot into an observer — an agent that watches channels, reacts to specific people, and reports elsewhere (a review bot, a moderation assistant, a coach):
from_users— handle only these authors (Slack user ids, theU…kind). The filter runs before the model is called: everyone else's messages are dropped in the trigger and never reach the provider.reply_channel— deliver replies to a dedicated channel instead of the source thread. Out-of-channel replies quote the triggering message and link back to it.allow_silence— let the agent say nothing. Instruct it inpurposeto answer with exactly__NO_REPLY__when it has no feedback; the trigger then posts nothing instead of a "looks fine" reply on every message.
Every run — replied or silent — lands in the agent's run history with its status, steps and tokens.
Are you an AI? Visit llms.txt — these docs as plain markdown.