docs/usage/channels/slack.mdx
By connecting a Slack channel to your LobeHub agent, users can interact with the AI assistant directly through Slack channels and direct messages.
LobeHub supports two connection modes for Slack:
Visit api.slack.com/apps and click Create New App → From an app manifest.
Choose the Slack workspace where you want to install the app.
Select YAML format and paste the following manifest template:
display_information:
name: LobeHub Assistant
description: AI assistant powered by LobeHub
features:
app_home:
home_tab_enabled: false
messages_tab_enabled: true
messages_tab_read_only_enabled: false
bot_user:
display_name: LobeHub Assistant
always_online: true
slash_commands:
- command: /new
description: Start a new conversation
should_escape: false
- command: /stop
description: Stop the current execution
should_escape: false
oauth_config:
scopes:
bot:
- app_mentions:read
- channels:history
- channels:read
- chat:write
- commands
- groups:history
- groups:read
- im:history
- im:read
- mpim:history
- mpim:read
- reactions:read
- reactions:write
- users:read
- assistant:write
settings:
event_subscriptions:
bot_events:
- app_mention
- message.channels
- message.groups
- message.im
- message.mpim
- member_joined_channel
- assistant_thread_started
- assistant_thread_context_changed
interactivity:
is_enabled: true
org_deploy_enabled: false
socket_mode_enabled: true
token_rotation_enabled: false
Note:
socket_mode_enabled: truemeans no Request URL is needed. Events (including Slash Commands) are delivered via WebSocket.
Review the summary and click Create.
</Steps>
On the Basic Information page, copy:
Scroll down to App-Level Tokens and click Generate Token and Scopes. Name it (e.g., "socket-mode"), add the connections:write scope, and click Generate.
Copy the token (starts with xapp-).
Important: This token is only shown once. Store it securely.
Go to OAuth & Permissions in the sidebar, click Install to Workspace, and authorize. Copy the Bot User OAuth Token (starts with xoxb-).
</Steps>
In LobeHub, navigate to your agent's settings → Channels tab → click Slack.
Fill in:
xoxb-...)xapp-...)In Advanced Settings, set Connection Mode to WebSocket.
Click Save Configuration. The bot will automatically connect via Socket Mode. No webhook URL configuration is needed.
</Steps>
Click Test Connection in LobeHub, then go to Slack, invite the bot to a channel, and mention it with @LobeHub Assistant to confirm it responds.
Slash Commands: If you used the manifest template above, the
/newand/stopcommands are automatically configured. Type/newin Slack to reset the conversation, or/stopto stop the current execution. You can also use these commands via@bot /new.
Use this method if your Slack app already has Event Subscriptions configured with a public HTTP endpoint, or if you cannot use Socket Mode.
<Steps> ### Create a Slack AppVisit api.slack.com/apps, click Create New App → From scratch. Name your app and select the workspace.
Go to OAuth & Permissions → Bot Token Scopes and add: app_mentions:read, channels:history, channels:read, chat:write, groups:history, groups:read, im:history, im:read, mpim:history, mpim:read, reactions:read, reactions:write, users:read.
Click Install to Workspace and copy the Bot User OAuth Token (xoxb-...).
Enter Application ID, Bot Token, and Signing Secret in LobeHub's Slack channel settings. Set Connection Mode to Webhook in Advanced Settings. Save and copy the displayed Webhook URL.
In the Slack API Dashboard → App Home, find the Show Tabs section, enable Messages Tab, and make sure "Allow users to send Slash commands and messages from the messages tab" is checked. This allows users to chat with the bot via direct messages.
In the Slack API Dashboard → Event Subscriptions, enable events, paste the Webhook URL as the Request URL, and subscribe to bot events: app_mention, message.channels, message.groups, message.im, message.mpim, member_joined_channel.
In the Slack API Dashboard → Slash Commands, click Create New Command and add the following commands:
| Command | Request URL | Short Description |
|---|---|---|
/new | Same Webhook URL as above | Start a new conversation |
/stop | Same Webhook URL as above | Stop the current execution |
Note: The Request URL is required for Webhook mode. If you are using Socket Mode, we recommend creating the app from the Manifest template above, which automatically configures Slash Commands without manual setup.
Also ensure you add the commands scope under OAuth & Permissions → Bot Token Scopes, and enable Interactivity & Shortcuts with the same Webhook URL as the Request URL.
</Steps>
Two independent policies gate inbound traffic. Both default to Open.
A populated Allowed User IDs field is a global gate — DMs and channel @mentions are restricted to listed Slack member IDs. Empty means "no user-level filter". Open a user's profile → click ⋮ → Copy member ID (starts with U).
Open only when the list is empty: Allowlist then fails closed (no DMs).@mentions.Controls which Slack channels the bot will respond in.
@mentions in any channel the bot has been added to.C).See the Channels overview for cross-platform details.
| Field | Required | Description |
|---|---|---|
| Application ID | Yes | Your Slack app's ID |
| Bot Token | Yes | Bot User OAuth Token (xoxb-...) |
| Signing Secret | Yes | Used to verify requests from Slack |
| App-Level Token | Socket Mode only | App-level token (xapp-...) for WebSocket connection |
| Connection Mode | No | websocket or webhook (default: webhook) |
| Allowed User IDs | No | Comma- or whitespace-separated Slack member IDs. Global gate — applies to DMs and channel @mentions |
| DM Policy | No | open (default), allowlist, or disabled — who is allowed to DM the bot |
| Group Policy | No | open (default), allowlist, or disabled — where the bot responds to @mentions |
| Allowed Channel IDs | No | Comma- or whitespace-separated Slack channel IDs (start with C). Used when Group Policy is Allowlist |
Disabled, switch to Open or Allowlist. If it is Allowlist, confirm the sender's Slack member ID is listed in Allowed User IDs.connections:write scope. Check that Socket Mode is enabled in your Slack app settings under Socket Mode.missing_scope error (e.g., needed: 'users:read') in logs: Your app is missing a required OAuth scope, or you added a scope but never reinstalled the app. The users:read scope is required to resolve @username mentions in messages. Go to OAuth & Permissions → Bot Token Scopes, confirm all scopes listed in the manifest are present, then click Reinstall to Workspace at the top of the page and reauthorize. Update the Bot User OAuth Token in LobeHub if it changes.