Slack Integration
OpenPollen supports Slack Bot via plugin, using Socket Mode to connect to Slack servers without requiring a public IP. Simple deployment.
Prerequisites
- Admin access to a Slack workspace
- An App created on Slack API
- Two tokens obtained:
- Bot Token (
xoxb-): for calling Slack APIs - App-Level Token (
xapp-): for Socket Mode connection
- Bot Token (
Create a Slack App
1. Create the App
- Log in to Slack API
- Click Create New App > From scratch
- Enter the App name and select a workspace
2. Enable Socket Mode
- Select Socket Mode from the left menu
- Enable Enable Socket Mode
- Create an App-Level Token:
- Enter a token name (e.g.,
openpollen-socket) - Add scope:
connections:write - Click Generate
- Enter a token name (e.g.,
- Save the generated
xapp-prefixed token (this is the App Token)
3. Configure Event Subscriptions
- Select Event Subscriptions from the left menu
- Enable Enable Events
- Under Subscribe to bot events, add:
message.channels— Listen to public channel messagesmessage.groups— Listen to private channel messagesmessage.im— Listen to direct messages
- Click Save Changes
4. Configure Bot Permissions
- Select OAuth & Permissions from the left menu
- Under Bot Token Scopes, add:
chat:write— Send messagesusers:read— Read user infochannels:history— Read public channel historygroups:history— Read private channel historyim:history— Read DM history
5. Install App to Workspace
- Select Install App from the left menu
- Click Install to Workspace
- After authorization, save the Bot User OAuth Token (
xoxb-prefix, this is the Bot Token)
Configuration
Configure Slack in openpollen.json:
{
"channels": {
"slack": {
"enabled": true,
"botToken": "${SLACK_BOT_TOKEN}",
"appToken": "${SLACK_APP_TOKEN}",
"groupPolicy": "mention"
}
}
}| Field | Type | Default | Description |
|---|---|---|---|
enabled | boolean | false | Enable Slack |
botToken | string | — | Bot User OAuth Token (xoxb- prefix) |
appToken | string | — | App-Level Token (xapp- prefix) |
groupPolicy | string | mention | Group message policy |
Two Types of Tokens
| Token | Prefix | Purpose | Where to Get |
|---|---|---|---|
| Bot Token | xoxb- | Slack Web API calls (send messages, get user info, etc.) | OAuth & Permissions |
| App Token | xapp- | Socket Mode WebSocket connection | Basic Information > App-Level Tokens |
Group Message Policy
| Value | Behavior |
|---|---|
mention | Only respond when @mentioned (recommended) |
all | Respond to all messages in channel |
Usage
After starting OpenPollen, the Slack Bot connects automatically via Socket Mode:
openpollen start OpenPollen v0.1.0 started
Gateway: http://127.0.0.1:18800
Slack Bot: @openpollen (Socket Mode)Direct Messages
Send messages directly to the Bot in Slack.
Channel Messages
@mention the Bot + your message (when groupPolicy is mention). Channel messages use threaded replies.
To invite the Bot to a channel: type /invite @your-bot-name in the channel.
Message Format
- Receiving: Text messages supported
- Replying: Plain text replies; channel messages use threaded replies
- Length limit: Slack has no strict message length limit, but very long messages may affect readability
How It Works
The Slack plugin uses Socket Mode connection:
- Establishes a WebSocket connection to Slack using the App Token
- Listens for
messageevents to receive new messages - Calls
ack()to acknowledge event receipt - Filters bot messages and subtype messages
- Builds
InboundMessageand passes to the Agent - Replies via Web API
chat.postMessage
Socket Mode initiates an outbound WebSocket connection from the client, requiring no public IP or Request URL configuration.
FAQ
Bot not responding to messages
- Verify correct events are added in Event Subscriptions
- Check the
groupPolicysetting. If set tomention, you need to @mention the Bot - Confirm the Bot has been invited to the channel
- Verify both Bot Token and App Token are correctly configured
Token prefix guide
xoxb-prefix: Bot Token, for API callsxapp-prefix: App Token, for Socket Mode connection- Both are required; make sure they are not mixed up
Socket Mode connection failure
- Verify the App Token has the
connections:writescope - Confirm Socket Mode is enabled in App settings
- Check network connectivity
Network issues
If your server is in mainland China, you may need a proxy to access Slack. Set the environment variable:
export HTTPS_PROXY=http://your-proxy:portBot not replying to thread messages
The current version only listens for new messages in channels and DMs. It does not automatically follow up on subsequent conversations within a thread. Each @mention message creates an independent threaded reply.