Setup Steps
Follow the Slack setup guide in the cookbook. Required configuration:SLACK_TOKEN(Bot User OAuth Token)SLACK_SIGNING_SECRET(App Signing Secret)- An ngrok tunnel (for local development) and event subscriptions pointing to
/slack/events
Example Usage
Create an agent, expose it with theSlack interface, and serve via AgentOS:
basic.py
cookbook/agent_os/interfaces/slack/basic.py.
Core Components
Slack(interface): Wraps an AgnoAgent,Team, orWorkflowfor Slack integration via FastAPI.AgentOS.serve: Serves the FastAPI app using Uvicorn.
Slack Interface
Main entry point for Agno Slack applications.
Initialization Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
agent | Optional[Agent] | None | Agno Agent instance. |
team | Optional[Team] | None | Agno Team instance. |
workflow | Optional[Workflow] | None | Agno Workflow instance. |
prefix | str | "/slack" | Custom FastAPI route prefix for the Slack interface. |
tags | Optional[List[str]] | None | FastAPI route tags for API documentation. Defaults to ["Slack"] if not provided. |
reply_to_mentions_only | bool | True | When True (default), bot responds to @mentions in channels and all direct messages. When False, responds to all messages in channels. |
agent, team, or workflow.
Key Method
| Method | Parameters | Return Type | Description |
|---|---|---|---|
get_router | None | APIRouter | Returns the FastAPI router and attaches endpoints. |
Endpoints
Mounted under the/slack prefix:
POST /slack/events
- Handles all Slack events (URL verification, messages, app mentions)
- Verifies Slack signature on each request
- Uses thread timestamps as session IDs for per-thread context
- Streams responses back into the originating thread (splits long messages)
Testing the Integration
- Run the app locally:
python <my-app>.py(ensure ngrok is running) - Invite the bot to a channel:
/invite @YourAppName - Mention the bot in a channel:
@YourAppName hello - Open a DM with the bot and send a message
Troubleshooting
- Verify
SLACK_TOKENandSLACK_SIGNING_SECRETare set - Confirm the bot is installed and invited to the channel
- Check ngrok URL and event subscription path (
/slack/events) - Review application logs for signature failures or permission errors