Installation
Install the Slack interface dependencies:Setup
Required environment variables:-
SLACK_SIGNING_SECRET(for request signature validation) -
SLACK_TOKEN(Bot User OAuth Token, required by SlackTools for sending messages) -
Optional:
SLACK_VERIFICATION_TOKEN
Operating Modes
- TASK (default) – Each message is processed as an independent task; no conversation history. Best for simple Q&A and one-off queries.
- CHAT – Messages from the same user share a conversation session. The agent remembers context. Best for multi-turn assistants and support bots.
Streaming
Setstream=True to progressively update the Slack message as tokens arrive from the agent. The initial message is posted immediately and then edited in-place as new chunks are generated. Works in both TASK and CHAT modes.
Heartbeat
When used with anAutonomousAgent that has heartbeat=True, the interface periodically sends the agent’s heartbeat_message to the agent, then posts the response to Slack.
The target channel is resolved automatically from the first incoming message. You can also set it explicitly via heartbeat_channel.
Reset Command (CHAT mode only)
In CHAT mode, users can clear their conversation by sending the reset command (e.g./reset) as a message. Configure it with reset_command; set to None to disable.
If the agent has a workspace configured, the reset command will also trigger a dynamic greeting message based on the workspace configuration. See Workspace for details.
Access Control (Whitelist)
Passallowed_user_ids (list of Slack user IDs, e.g. ["U01ABC123"]). Only those users are processed; others receive “This operation not allowed”. Omit allowed_user_ids (or set None) to allow all users.
Example Usage
Create an agent, expose it with theSlackInterface interface, and serve via InterfaceManager. Example with CHAT mode, reset command, and optional whitelist:
Core Components
-
SlackInterface(interface): Wraps an UpsonicAgentfor Slack via FastAPI. -
InterfaceManager.serve: Serves the FastAPI app using Uvicorn.
SlackInterface Interface
Main entry point for Upsonic Slack applications.
Initialization Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
agent | Agent | Required | Upsonic Agent instance. |
signing_secret | Optional[str] | None | Slack signing secret (or set SLACK_SIGNING_SECRET). |
verification_token | Optional[str] | None | Slack verification token (or set SLACK_VERIFICATION_TOKEN). |
name | str | "Slack" | Interface name. |
reply_to_mentions_only | bool | True | Whether to only reply to @mentions and DMs. |
mode | Union[InterfaceMode, str] | InterfaceMode.TASK | TASK or CHAT. |
reset_command | Optional[str] | "/reset" | Message text that resets chat session (CHAT mode). Set None to disable. |
storage | Optional[Storage] | None | Storage backend for chat sessions (CHAT mode). |
allowed_user_ids | Optional[List[str]] | None | Whitelist of Slack user IDs (e.g. "U01ABC123"). None = allow all. |
stream | bool | False | Stream agent responses by progressively updating the message. |
heartbeat_channel | Optional[str] | None | Explicit Slack channel ID for heartbeat delivery. Auto-detected from first incoming message if omitted. |
Key Methods
| Method | Parameters | Return Type | Description |
|---|---|---|---|
attach_routes | None | APIRouter | Returns the FastAPI router and attaches endpoints. |
is_user_allowed | user_id: str | bool | Whether the user is in the whitelist (or whitelist disabled). |
Endpoints
Mounted under the/slack prefix:
POST /slack/events
- Receives Slack events and messages.
-
Validates signature (
X-Slack-SignatureandX-Slack-Request-Timestamp). - Handles URL verification challenge for webhook setup.
-
Processes
app_mentionandmessageevents via the agent. - Sends replies in threads or directly in channels/DMs.
-
Responses:
200 {"status": "ok"}for events,200 {"challenge": "..."}for URL verification,400missing headers,403invalid signature,500errors.
GET /slack/health
- Health/status of the interface.

