Connect Slack to your agents for messaging, channels, and events.
Overview
The Slack integration lets your agents send messages, read channels, respond to events, and interact with your Slack workspace.
Why "Bring Your Own Key" (BYOK)?
By using your own Slack app, you get complete control over events and triggers. Events only come from workspaces where your app is installed—no noise from other users.
Benefits:
- Isolated events — only receive events from your workspaces
- Full control — configure exactly which events to subscribe to
- Bot tokens — send messages as your custom bot
- Webhook verification — secure event delivery with your signing secret
Prerequisites
Before connecting, you'll need:
- A Slack workspace where you have admin permissions (or can request app approval)
- A Slack account to create the app
Step 1: Create a Slack App
- Go to the Slack API portal
- Click Create New App
- Choose From scratch
- Name your app (e.g., "Inference Agent")
- Select your workspace
- Click Create App
Step 2: Configure OAuth Scopes
- In your app settings, go to OAuth & Permissions
- Scroll to Scopes section
- Add Bot Token Scopes based on what you need:
Common scopes
| Scope | Allows |
|---|---|
channels:read | View basic channel info |
channels:history | Read channel messages |
chat:write | Send messages as your bot |
users:read | View user profiles |
reactions:read | View emoji reactions |
files:read | Access files shared in channels |
- Add User Token Scopes if you need to act as the user:
| Scope | Allows |
|---|---|
channels:read | View channels the user is in |
chat:write | Send messages as the user |
Step 3: Configure OAuth Redirect URL
- In OAuth & Permissions, scroll to Redirect URLs
- Add the callback URL:
| Environment | Callback URL |
|---|---|
| Production | https://app.inference.sh/settings/secrets/oauth/slack |
| Staging | https://app.staging.inference.sh/settings/secrets/oauth/slack |
| Local dev | http://localhost:3000/settings/secrets/oauth/slack |
- Click Save URLs
Step 4: Get Your Credentials
- Go to Basic Information in your app settings
- Copy these values:
| Credential | Location | Purpose |
|---|---|---|
| Client ID | App Credentials | OAuth authentication |
| Client Secret | App Credentials | OAuth authentication |
| Signing Secret | App Credentials | Webhook verification |
- (Optional) Go to OAuth & Permissions and copy the Bot Token (
xoxb-...) if you want to send messages without OAuth
Step 5: Connect in inference.sh
Configure credentials
- Go to Settings → Secrets → Integrations
- Find Slack and click Configure
- Enter your credentials:
- Client ID
- Client Secret
- Signing Secret (for webhook events)
- Bot Token (optional, for sending messages)
- Click Save credentials
These are stored securely as encrypted secrets.
Authorize the connection
- Click Connect
- You'll be redirected to Slack to authorize
- Select your workspace and review permissions
- Click Allow
- Done! Your Slack integration is now active.
Event Subscriptions (for triggers)
To receive real-time events from Slack:
- In your Slack app, go to Event Subscriptions
- Toggle Enable Events to On
- Set the Request URL to your webhook endpoint:
code
1https://api.inference.sh/webhooks/slack - Subscribe to bot events you want:
| Event | Trigger |
|---|---|
message.channels | New message in a channel |
message.im | Direct message to your bot |
app_mention | Someone @mentions your bot |
reaction_added | Emoji reaction added |
member_joined_channel | User joins a channel |
- Click Save Changes
Capabilities
| Capability | Description | Required Scopes |
|---|---|---|
slack.channels.read | Read channel info | channels:read |
slack.channels.history | Read channel messages | channels:history |
slack.channels.write | Send messages | chat:write |
slack.users.read | Read user profiles | users:read |
slack.reactions.read | Read emoji reactions | reactions:read |
slack.files.read | Read shared files | files:read |
Using in apps
Declare Slack requirements in your app:
1requirements:2 integrations:3 - key: slack.channels.write4 description: Send notifications to Slack5 6 - key: slack.channels.history7 description: Read channel messages8 optional: trueAt runtime, your app receives:
1SLACK_ACCESS_TOKEN=xoxp-user-token2SLACK_BOT_TOKEN=xoxb-bot-token3SLACK_TEAM_ID=T01234567Example: Send a message
1from slack_sdk import WebClient2import os3 4client = WebClient(token=os.environ["SLACK_BOT_TOKEN"])5 6client.chat_postMessage(7 channel="#general",8 text="Hello from my AI agent! 🤖"9)Example: Read channel history
1from slack_sdk import WebClient2import os3 4client = WebClient(token=os.environ["SLACK_ACCESS_TOKEN"])5 6result = client.conversations_history(channel="C01234567", limit=10)7 8for message in result["messages"]:9 print(f"{message.get('user')}: {message.get('text')}")Security
- Your app — you control the Slack app and its permissions
- Signing secret — webhook events are verified using your secret
- Encrypted storage — all credentials are encrypted at rest
- Revocable — uninstall the app from your workspace anytime
Revoking access
- From inference.sh: Settings → Integrations → Disconnect
- From Slack: Workspace Settings → Manage Apps → Remove
Troubleshooting
"Callback URL mismatch"
- Ensure the redirect URL in your Slack app matches exactly
- The URL is case-sensitive
"Invalid signing secret"
- Verify you copied the Signing Secret from Basic Information
- Make sure there are no extra spaces
"Missing scopes"
- Add the required scopes in OAuth & Permissions
- Reinstall the app to your workspace after adding scopes
"Channel not found"
- Your bot needs to be invited to private channels
- Use
/invite @YourBotNamein the channel