Slack Runtime
AgentFlow can run a dedicated Slack agent from Slack messages, app mentions, and Slack Assistant threads. The HTTP API owns installation and tenant-admin controls; a separate Socket Mode worker keeps the Slack connection open and dispatches events into the AgentFlow runtime.Deployment Shape
Run Slack in two pieces:| Process | Responsibility |
|---|---|
| FastAPI web service | Tenant-admin Slack settings, OAuth install URL/exchange, installation records, user links, and health checks |
| Slack Socket Mode worker | Receives Slack events, acks each envelope, deduplicates events, resolves the tenant installation, and runs AgentFlow turns |
TENANT can be used instead of SLACK_TENANT_ID. The worker enters that tenant database with tenant_context() before recording event receipts, looking up installations, resolving thread bindings, and running turns.
Configuration
Set these values on the API service:SLACK_SOCKET_MODE_ENABLED is reported by admin settings and health endpoints. The standalone worker still requires SLACK_APP_TOKEN; SLACK_SOCKET_MODE_CONCURRENCY limits concurrent event processing inside the worker.
Optional runtime limits:
| Setting | Purpose |
|---|---|
SLACK_EVENT_MAX_AGE_SECONDS | Maximum accepted Slack event age for runtime guards |
SLACK_FILE_MAX_BYTES | Maximum Slack file size to ingest as an AgentFlow attachment |
SLACK_BROAD_MENTION_POLICY | Broad mention handling policy |
Admin API
Tenant admins manage Slack through/api/v1/admin/slack/*:
| Endpoint | Purpose |
|---|---|
GET /api/v1/admin/slack/settings | Show configured client/app-token state and default agent |
GET /api/v1/admin/slack/health | Check config readiness and enabled installation counts |
GET /api/v1/admin/slack/oauth/install-url | Build a Slack OAuth installation URL |
POST /api/v1/admin/slack/oauth/exchange | Exchange an OAuth code and persist the installation |
GET /api/v1/admin/slack/installations | List workspace installations |
GET /api/v1/admin/slack/installations/{slack_team_id} | Retrieve one workspace installation |
PUT /api/v1/admin/slack/installations/{slack_team_id} | Save an installation manually |
PATCH /api/v1/admin/slack/installations/{slack_team_id} | Enable or disable an installation |
DELETE /api/v1/admin/slack/installations/{slack_team_id} | Revoke an installation |
GET /api/v1/admin/slack/user-links | List Slack-user to AgentFlow-user links |
POST /api/v1/admin/slack/user-links | Upsert a Slack-user link |
auth0_user_id; unmapped Slack users receive a Slack notice asking an admin to link their profile.
Supported Slack Events
The Socket Mode worker handles these Slack routes:| Slack route | AgentFlow behavior |
|---|---|
message.im | Direct message to the app becomes a SlackAgent turn |
app_mention | Mentioning the app in a channel starts or continues a thread-bound conversation |
assistant_thread_started | Starts a Slack Assistant thread |
assistant_thread_context_changed | Continues a Slack Assistant thread with updated context |
block_actions with slack_regenerate | Re-runs an interrupted Slack turn |
Thread Binding And Context
Each Slack thread maps to one AgentFlow conversation through a deterministic origin id:slack_thread, so the same conversation remains available through normal conversation APIs.
Slack turns pass Slack context into the runtime as:
origin_type: Slack thread origin typeorigin_id: deterministic Slack thread idorigin_metadata: route, team, channel, thread timestamp, message timestamp, user id, bot id, event id, and file idscontext_refs: Slack channel, thread, user, and file references for registered entity resolverssession_context.slack: normalized Slack routing metadata
Streaming And Failures
AgentFlow streams the SlackAgent response into Slack through a coalescing sink. If the turn fails before any response text is posted, Slack gets a short internal-error message. If the failure happens after partial output, AgentFlow finalizes the partial Slack message best-effort and posts an interrupted notice with a Regenerate button. Clicking Regenerate:- Acks the Slack action immediately.
- Resolves the clicked Slack user through the same installation and user-link checks.
- Verifies the target user conversation part still belongs to the thread and has not already been replaced.
- Re-runs the turn with a fresh Slack message id and
regenerate_after_user_part_id. - Updates the notice to a button-less regenerating or failure message.

