How to securely connect AI agents to Slack: risks, platforms, and a checklist
The most secure way to connect an AI agent to Slack is to give it its own bot identity with the fewest scopes it needs, add it only to the channels where it should work, and keep its Slack token somewhere the agent can't
The most secure way to connect an AI agent to Slack is to give it its own bot identity with the fewest scopes it needs, add it only to the channels where it should work, and keep its Slack token somewhere the agent can't read. Then treat every Slack message as untrusted input, log every tool call, and require a person's approval before the agent does anything beyond replying in the thread. You can build that yourself on Slack's APIs, wire it up in Zapier or n8n, use Slack's own AI and MCP features, or run the agent on a managed agent platform such as Type.com.
Why an AI agent needs more care than a normal Slack bot
A classic bot runs fixed code: /deploy staging does the same thing every time. An agent reads free text, picks its own tools, and can be talked into things.
The OWASP Top 10 for LLM applications (2025) ranks prompt injection first and excessive agency sixth. In Slack, anyone who can post where the agent reads can put text in front of the model, and the token's scopes decide what an injection can do.
The 7 risks to design for
1. Token scope
Request only what the job needs. A mention-driven agent can start with app_mentions:read (messages that mention the app in conversations it's in) and chat:write. Add channels:history or groups:history only if it must read whole channels, and skip chat:write.public, which lets an app post in channels it isn't a member of.
2. Who the agent acts as
Per Slack's token docs, bot tokens (xoxb-) belong to the app and keep working if the installing user is deactivated. User tokens (xoxp-) act with that user's access, and writes appear as that user. Use a bot token for shared agents, and a user token only when the agent works for one person.
3. Credential storage
Anything an agent can read, an injected prompt can try to send somewhere else. Keep the bot token and signing secret out of prompts, repo files, and any environment the agent's code can read. Put them behind a tool or proxy that makes the Slack call and returns only the result.
4. Prompt injection from channel content
Every message, file, and thread reply was written by someone else, including other bots and, in Slack Connect channels, people outside your company. Answer app_mention events instead of every message, drop bot messages before the model runs, and tell the agent to treat message text as data, not instructions. That helps, but it doesn't replace narrow scopes.
5. Audit trail
Slack shows what the bot posted, not which messages the model read, which tools it called, or why. Log the event ID, every tool call with its input and result, and the final reply.
Store event IDs and skip repeats, too. Slack retries up to 3 times when it doesn't get a 2xx within 3 seconds, so a slow handler can start the same run more than once.
6. Approvals for write actions
Replying in the thread is low risk. Posting in other channels, sending DMs, or writing to your CRM is not. Have the agent post a proposal and wait for approval from someone who's allowed to give it. Slack's Real-time Search API guide gives the same advice: let users confirm before an app messages channels or people it found.
7. Per-channel and per-team access
A bot only gets events from conversations it belongs to, so channel membership is your first boundary. Keep each team's agent and credentials separate: the agent in #sales shouldn't hold finance's keys. Turn on Slack app approval so nobody installs an agent with broad scopes unreviewed.
5 ways to connect an AI agent to Slack
1. Build it yourself: Slack app + Claude or OpenAI API
You write a Slack app with Bolt, call a model API, and build your own tool layer. You control and own everything: signature checks, acknowledging within 3 seconds and running the agent from a queue, de-duplicating retries, token storage, logging, and approvals.
The signature check is short. Reject timestamps more than five minutes old to block replays:
import { createHmac, timingSafeEqual } from "node:crypto";
// timestamp: X-Slack-Request-Timestamp header; signature: X-Slack-Signature header
export function isFromSlack(rawBody: string, timestamp: string, signature: string, signingSecret: string) {
const ts = Number(timestamp);
if (!Number.isFinite(ts) || Math.abs(Date.now() / 1000 - ts) > 60 * 5) return false;
const expected =
"v0=" + createHmac("sha256", signingSecret).update(`v0:${timestamp}:${rawBody}`).digest("hex");
const a = Buffer.from(expected);
const b = Buffer.from(signature);
return a.length === b.length && timingSafeEqual(a, b);
}
2. Workflow tools: Zapier, n8n, Make
You chain a Slack trigger, an LLM step, and an action in minutes. Check whose Slack account the connection uses (a user connection posts as that person), who else can reuse it, and whether there's a human step before writes. n8n can be self-hosted if Slack data has to stay on your servers.
3. Slack's own AI and agent platform
Slack offers Slackbot, Agentforce, and Marketplace agents from partners such as Anthropic and OpenAI. For agents you build, Slack's MCP server and Real-time Search (RTS) API search on behalf of the signed-in user and return only what that user can see, and Slack's RTS guide says apps must not store or copy results or train on them. Both are limited to Marketplace-published and internal apps, admins approve MCP clients, and MCP activity appears in Slack's audit logs.
4. Agent integration infrastructure: Paragon, Composio
These give you managed OAuth, token refresh, and ready-made Slack tools for an agent you build and host. A good fit if you're shipping an AI product that connects to customers' Slack workspaces. You still own the agent: its runtime, instructions, and approvals.
5. Managed agent platforms: Type.com and others
The vendor runs the agent and stores the credentials, and you configure channels, connections, and approvals instead of building infrastructure. Credal and Relevance AI are also in this category. Ask any vendor to show you, in the product, where access is scoped, whose credentials the agent uses, and where a person approves a write.
How the options compare
| Option | Setup | Where the Slack token lives | Built-in guardrails | Best fit |
|---|---|---|---|---|
| DIY app + LLM API | High | Your secret store | Whatever you build | One narrow use case |
| Zapier, n8n, Make | Low | The tool's credential store (your server if you self-host n8n) | Filters and human steps you add | Simple trigger, prompt, action flows |
| Slack native | Low to medium | Slack; MCP and RTS clients outside Slack hold a user token | App approval, admin-approved MCP clients, user-level permissions | Search and answers from Slack content |
| Paragon, Composio | Medium | The vendor's managed auth | Managed OAuth and token refresh | AI products that connect to customers' Slack |
| Type.com | Low | Type.com's servers; the agent sees results, not tokens | Per-Space connections, Read-only access, approvals in the Slack thread, tool-call history | Shared team agents in Slack without running bot infrastructure |
How Type.com handles each risk
Type.com runs Claude Code and Codex agents on managed cloud machines, each in its own sandboxed VM, and your team talks to them from Slack. Each risk above maps to a documented control:
| Risk | What Type.com does |
|---|---|
| Channel access | Slack sends events only from channels you've invited the app to. Each connected channel maps to a Space and answers @mentions by default, or new posts or every message if you choose. |
| Identity | AI acts with the effective access of the person and conversation that started the work. Scheduled runs act as the automation's creator. |
| Credentials | OAuth grants and encrypted API keys stay on Type.com's servers. Connections make the call outside the agent, and automation code gets a short-lived scoped token, never a provider credential. |
| Other tools | Personal or team connections, assigned to specific Spaces. A new team connection is limited to its owner and admins until shared, and each grant is Full or Read-only. |
| Prompt injection | In Slack-triggered automations, the agent is told to treat the Slack event as data, not instructions. Code automations can filter events on the server before your code runs, for example dropping bot messages. |
| Duplicates | In code automations, a Slack retry with the same event ID runs only once per subscription. |
| Audit trail | Every thread shows the agent's tool calls, with the connection, input, success, and result. Run history records each run's output, stages, and errors. |
| Approvals | Automations can pause on a question in the triggering Slack thread, and only people with a linked Type.com account and access to the task thread can answer. In a connected channel, a 🛑 reaction stops a response in progress. |
Read-only is enforced by Type.com, so for data that must never change, also connect an account that's read-only in the source app. You can test an automation in a private thread only you can see before it touches a busy channel. Plans start at $50 a month for 2 team members and $100 of AI usage, with a 14-day free trial.
Checklist
- Bot token for shared agents; user tokens only for one person's own work
- Fewest scopes (
app_mentions:readandchat:writeto start) - App added only to the channels it serves, with Slack app approval on
- Token and signing secret stored where the agent can't read them
- Signature verified on every request; timestamps over 5 minutes old rejected
- 2xx within 3 seconds, agent run in the background, event IDs de-duplicated
- Mentions only, bot messages dropped, message text treated as data
- Human approval for posts outside the thread, DMs, and writes to other systems
- Every run logged, with a way to stop it and revoke the token fast
FAQ
What's the biggest security risk when you connect an AI agent to Slack?
Broad access plus untrusted input. If the agent can read many channels and post anywhere, one injected message can make it leak data or post where it shouldn't. Narrow scopes, limited channel membership, and approvals for writes cap the damage.
Should a Slack AI agent use a bot token or a user token?
A bot token for anything shared: it belongs to the app and keeps working after the installer leaves. A user token acts with that person's access and posts as them, so use it only when the agent works for that one person.
How do I get an AI agent to do a task when someone tags it in Slack?
Subscribe to app_mention events, verify the signature, return a 2xx within 3 seconds, run the agent in the background, and reply in the thread. In Type.com, connect Slack, add the connection to a Space, and invite the app to the channel. Then connect the channel to the Space to answer @mentions, or create a Slack-triggered automation whose instructions say to reply in the thread.
Can an AI agent read private Slack channels?
With a bot token, only private channels it's been added to, and only with the groups:history scope. With a user token, it can read whatever that user can, another reason to use bot tokens for shared agents.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.