Fixes and updates: - README.md: Remove duplicate heartbeat troubleshooting section - docs/getting-started.md: Fix Node version (18→20), commands, repo URL - docs/commands.md: Rewrite with accurate command list (/start, /status, /heartbeat) - docs/README.md: New multi-channel architecture diagram - docs/whatsapp-setup.md: Add selfChatMode safety docs, media support section - docs/slack-setup.md: Fix broken links New documentation: - docs/configuration.md: Complete YAML config reference - docs/cron-setup.md: Scheduling guide (cron jobs + heartbeats) Written by Cameron ◯ Letta Code "Documentation is a love letter that you write to your future self." - Damian Conway
6.2 KiB
Slack Setup for LettaBot
This guide walks you through setting up Slack as a channel for LettaBot.
Overview
LettaBot connects to Slack using Socket Mode, which means:
- No public URL required (no ngrok needed)
- Works behind firewalls
- Real-time bidirectional communication
Prerequisites
- A Slack workspace where you have permission to install apps
- LettaBot installed and configured with at least
LETTA_API_KEY
Step 1: Create a Slack App
- Go to https://api.slack.com/apps
- Click "Create New App"
- Choose "From scratch"
- Enter:
- App Name:
LettaBot(or your preferred name) - Workspace: Select your workspace
- App Name:
- Click "Create App"
Step 2: Enable Socket Mode
Socket Mode lets your bot connect without exposing a public endpoint.
-
In the left sidebar, click "Socket Mode"
-
Toggle "Enable Socket Mode" → ON
-
You'll be prompted to create an App-Level Token:
- Token Name:
socket-token - Scopes: Add
connections:write - Click "Generate"
- Token Name:
-
Copy the token (starts with
xapp-)This is your
SLACK_APP_TOKEN
Step 3: Set Bot Permissions
- In the left sidebar, go to "OAuth & Permissions"
- Scroll to "Scopes" → "Bot Token Scopes"
- Add these scopes:
| Scope | Purpose |
|---|---|
app_mentions:read |
React when someone @mentions your bot |
chat:write |
Send messages |
im:history |
Read DM message history |
im:read |
View DM channel info |
im:write |
Start DM conversations |
Step 4: Enable Events
- In the left sidebar, go to "Event Subscriptions"
- Toggle "Enable Events" → ON
- Scroll to "Subscribe to bot events"
- Add these events:
| Event | Purpose |
|---|---|
app_mention |
Triggers when someone @mentions your bot in a channel |
message.im |
Triggers when someone DMs your bot |
- Click "Save Changes"
Important
: If you add or change events after installing the app, you must reinstall it (Step 6) for changes to take effect. The token stays the same.
Step 5: Configure App Home (Optional but Recommended)
- In the left sidebar, go to "App Home"
- Under "Show Tabs", enable:
- Messages Tab → ON (allows DMs to your bot)
- Check "Allow users to send Slash commands and messages from the messages tab"
Step 6: Install to Workspace
-
In the left sidebar, go to "Install App"
-
Click "Install to Workspace"
-
Review the permissions and click "Allow"
-
Copy the Bot Token (starts with
xoxb-)This is your
SLACK_BOT_TOKEN
Step 7: Configure LettaBot
Add these to your .env file:
# Slack Configuration
SLACK_BOT_TOKEN=xoxb-your-bot-token-here
SLACK_APP_TOKEN=xapp-your-app-token-here
# Optional: Restrict to specific Slack user IDs
# SLACK_ALLOWED_USERS=U01234567,U98765432
Step 8: Start LettaBot
npm run dev
You should see:
Registered channel: Slack
[Slack] Bot started in Socket Mode
Step 9: Test the Integration
Direct Message
- In Slack, look for your bot under Apps in the left sidebar
- Click on the bot to open a DM
- Send a message:
Hello! - The bot should respond
Channel Mention
- Invite your bot to a channel:
/invite @LettaBot - Mention the bot:
@LettaBot what time is it? - The bot should respond in the channel
Thread Replies
- If you mention the bot in a thread, it will reply in that thread
- If you mention the bot in a channel (not a thread), it starts a new thread from your message
Cross-Channel Memory
Since LettaBot uses a single agent across all channels:
- Messages you send on Slack continue the same conversation as Telegram
- The agent remembers context from both channels
- You can start a conversation on Telegram and continue it on Slack
Restricting Access
To restrict which Slack users can interact with the bot:
-
Find user IDs:
- Click on a user's profile in Slack
- Click the ⋮ menu → "Copy member ID"
- IDs look like
U01ABCD2EFG
-
Add to
.env:SLACK_ALLOWED_USERS=U01234567,U98765432
Troubleshooting
Bot not connecting
Error: "Socket Mode not enabled"
- Go to api.slack.com/apps → Your App → Socket Mode → Enable it
Error: "invalid_auth"
- Double-check your
SLACK_BOT_TOKENandSLACK_APP_TOKEN - Make sure you copied the full tokens including the
xoxb-andxapp-prefixes
Bot not responding to DMs
- Go to App Home in your Slack app settings
- Enable "Messages Tab"
- Check "Allow users to send messages from the messages tab"
- Reinstall the app if you changed these settings
"Sending messages to this app has been turned off"
Even after enabling the Messages Tab and reinstalling, Slack may cache the old state:
- Refresh Slack: Press
Cmd+R(Mac) orCtrl+R(Windows/Linux) - Or restart Slack entirely
- If still stuck, remove the bot from your Apps sidebar and re-add it
Bot not responding to @mentions
- Go to Event Subscriptions
- Make sure "Enable Events" is toggled ON
- Make sure
app_mentionis listed under "Subscribe to bot events" - Click "Save Changes" at the bottom
- Go to OAuth & Permissions
- Make sure
app_mentions:readscope is added - Reinstall the app: Install App → Reinstall to Workspace
Note
: Adding scopes only gives permission; you must also subscribe to events to receive them.
"missing_scope" error
If you see a missing scope error:
- Go to OAuth & Permissions
- Add the missing scope
- Go to Install App → Reinstall to Workspace
Bot responds slowly
This is normal - the bot needs to:
- Receive your message
- Send it to the Letta agent
- Wait for the agent to respond
- Stream the response back
First responses may take longer as the agent "wakes up".
Security Notes
- Socket Mode tokens (
xapp-) should be kept secret - Bot tokens (
xoxb-) should be kept secret - Use
SLACK_ALLOWED_USERSin production to restrict access - The bot can only see messages in channels it's invited to, or DMs sent directly to it