Slack Integration
Table of contents
- Slack Integration
Slack integration for workspace communication.
Features
- Bidirectional Communication: Send and receive messages via Slack bot
- Session Binding: Bind Slack channels to chat.nvim sessions
- Automatic Polling: Polls for new messages every 3 seconds
- Thread Support: Reply to messages in threads
- Long Message Support: Handles messages up to 40,000 characters
- Mention Detection: Responds to @mentions and thread replies
Setup Guide
1. Create Slack App
- Go to https://api.slack.com/apps
- Click “Create New App”
- Choose “From scratch”
- Give it a name (e.g., “Chat.nvim Bot”) and select your workspace
2. Configure Bot Permissions
Required Bot Token Scopes:
channels:history- Read messages in channelschat:write- Send messagesgroups:history- Read messages in private channelsim:history- Read messages in direct messagesmpim:history- Read messages in multiparty direct messages
These scopes are required for the bot to read and send messages.
Configuration steps:
- Go to “OAuth & Permissions” in your app
- Add the scopes above to “Bot Token Scopes”
- Scroll to “OAuth Tokens for Your Workspace”
- Click “Install to Workspace”
- Copy the Bot User OAuth Token (starts with
xoxb-)
Keep your bot token secure! Never share it or commit it to version control.
3. Get Channel ID
- Open Slack in browser
- Go to the channel you want to use
- The channel ID is in the URL:
https://app.slack.com/client/WORKSPACE_ID/CHANNEL_ID - Or right-click channel → “Copy Link” → extract the last part
Channel IDs typically start with
C(e.g.,C1234567890).
4. Invite Bot to Channel
- In Slack, go to the channel
- Type:
/invite @Chat.nvim Bot - Or use:
/invite @YourBotName
The bot must be invited to the channel to read and send messages.
5. Configure chat.nvim
require('chat').setup({
integrations = {
slack = {
bot_token = 'xoxb-YOUR-BOT-TOKEN',
channel_id = 'CXXXXXXXXXX',
},
},
})
Commands
Neovim Commands
| Command | Description |
|---|---|
:Chat bridge slack |
Bind current session to Slack channel |
Slack Commands
| Command | Description |
|---|---|
/session |
Bind current Slack channel to active chat.nvim session |
/clear |
Clear messages in the bound session |
Workflow
- Configure Slack bot token and channel ID
- Open chat.nvim and create/start a session
- Run
:Chat bridge slackto bind the session - In Slack, mention the bot (e.g.,
@Chat.nvim Bot hello) to interact - AI response will be sent back to Slack automatically
Message Handling
Mentions
In channels, mention the bot to get a response:
@Chat.nvim Bot What is the weather today?
The bot only responds when mentioned to avoid noise in busy channels.
Thread Replies
Reply to any bot message in a thread:
[Reply in thread]
Can you provide more details?
Thread replies are detected and processed automatically.
Direct Messages
In direct messages, just send a message:
Hello, how can you help me?
Technical Details
- API: Slack Web API
- Authentication: Bot User OAuth Token (xoxb-)
- Polling: 3-second intervals
- Message Limit: 40,000 characters
- State Persistence:
stdpath('data')/chat-slack-state.json - Timeout Protection: 5-second request timeout
Troubleshooting
Bot Not Responding
Symptom: Bot does not respond to messages.
Solution:
- Verify bot_token and channel_id are correct
- Check bot has required permissions
- Ensure bot is invited to the channel
- Make sure you’re mentioning the bot with @bot_name
- Check Slack API logs:
:messagescommand in Neovim
Permission Errors
Symptom: Bot lacks permissions to read/send messages.
Solution:
- Verify all required scopes are added
- Reinstall the app to workspace after adding scopes
- Check if the workspace admin needs to approve the app
Channel Access Issues
Symptom: Bot cannot read messages in channel.
Solution:
- Ensure bot is invited to the channel (
/invite @BotName) - Check if the channel is private (bot needs
groups:historyscope) - Verify the bot is not restricted by workspace policies
State Issues
Symptom: Session binding not working.
Solution:
- Clear state:
:lua require('chat.integrations.slack').clear_state()
Notes
- Slack API has rate limits (tier 3: ~50+ requests per minute)
- The bot only responds when mentioned or in thread replies
- Private channels require the bot to be invited
- Bot user ID is cached in state for faster mention detection
Best Practices
1. Use Dedicated Channel
Create a dedicated channel for AI assistance:
#ai-assistant
2. Limit Bot Access
Only invite the bot to channels where you need AI assistance.
3. Use Threads for Context
Use thread replies to maintain conversation context:
@Bot initial question
[Thread reply] follow-up question
[Thread reply] another question
4. Monitor Rate Limits
Be aware of Slack API rate limits when using the integration heavily.
Next Steps
- Discord Integration - Setup Discord bot
- Telegram Integration - Setup Telegram bot
- IM Integration Overview - All IM integrations