Channels β
OpenSpider communicates with users through WhatsApp via the Baileys library. This page covers how to set up and configure the WhatsApp channel.
Voice Messages π€ β
OpenSpider supports voice-in, voice-out interaction. Users send voice notes which are transcribed locally via Whisper, and agents can reply with ElevenLabs-powered voice notes.
See Voice Messages for full setup and configuration.
Signal Session Management β
OpenSpider automatically manages WhatsApp's end-to-end encryption sessions:
- Stale session cleanup β On each startup, all
session-*.jsonfiles inbaileys_auth_info/are deleted to force fresh E2E negotiation and prevent "Bad MAC" errors - Cacheable key store β Uses
makeCacheableSignalKeyStorefor proper session renegotiation - Sent message store β Caches outgoing message content so Baileys can re-relay messages on retry requests
- Lock management β Processing locks are properly released on all early-return paths to prevent message drops
WhatsApp Setup β
Initial Connection β
During onboarding (openspider onboard), you'll be prompted to connect WhatsApp by scanning a QR code. If you skipped this step, connect later:
From a running gateway:
openspider channels loginThis polls the gateway for QR codes and displays them in your terminal. Scan with your phone's WhatsApp.
Standalone connection:
openspider channels whatsapp loginInitiates a direct connection without a running gateway.
Authentication Persistence β
After the first scan, authentication credentials are stored in baileys_auth_info/. Subsequent starts reconnect automatically β no QR scan needed unless the session is revoked.
WARNING
Don't delete the baileys_auth_info/ directory unless you want to re-authenticate.
DM Policies β
Control which phone numbers can send direct messages to the agent.
Allowlist Mode (Default) β
Only specified phone numbers can message the agent:
{
"dmPolicy": "allowlist",
"allowedDMs": ["14155551234", "447700900000"]
}Phone numbers are stored without the + prefix.
Open Mode β
Any phone number can message the agent:
{
"dmPolicy": "open"
}::: caution Open mode has no access control. Only use this in trusted environments or for testing. :::
Group Policies β
Control which WhatsApp groups the agent participates in and how it responds.
Group Allowlist β
{
"groupPolicy": "allowlist",
"allowedGroups": [
{
"jid": "120363423460684848@g.us",
"mode": "mention"
},
{
"jid": "120363556677889900@g.us",
"mode": "listen"
}
]
}Per-Group Modes β
Each group can be configured independently:
| Mode | Behavior |
|---|---|
mention | Agent responds only when @mentioned in the group |
listen | Agent responds to every message in the group |
Legacy Compatibility β
Older configurations used a simple string array for allowedGroups:
{
"allowedGroups": ["120363423460684848@g.us"]
}This format is automatically migrated to the object format on load, using the global botMode as the default mode for each group.
Global Bot Mode β
The botMode field serves as a fallback for groups that don't have a per-group mode set:
{
"botMode": "mention"
}| Value | Behavior |
|---|---|
mention | Default. Agent only responds when @tagged |
listen | Agent responds to all messages in allowed groups |
Finding Group JIDs β
To add a group to your allowlist, you need its JID (WhatsApp group ID). You can find this:
- Dashboard β WhatsApp Security tab β shows connected groups with JIDs
- Logs β Group message events include the group JID
Group JIDs follow the format: [number]@g.us
Configuration via Dashboard β
The WhatsApp Security tab in the dashboard provides a visual interface for managing:
- DM allowlist (add/remove phone numbers)
- Group allowlist (add/remove groups)
- Per-group mention/listen toggles
Changes made in the dashboard are saved directly to workspace/whatsapp_config.json.
See Dashboard for more details.
LID Identity Resolution β
WhatsApp has migrated DMs from phone-based JIDs (1234@s.whatsapp.net) to LID-based JIDs (177472511426665@lid). OpenSpider's firewall handles this seamlessly through a multi-layer resolution system.
How It Works β
When an incoming DM arrives from an @lid JID, OpenSpider resolves it through 4 layers:
- LID Cache Lookup β checks
workspace/lid_cache.jsonfor a known mapping - Config Field Match β checks if any
allowedDMsentry has a matchinglidfield - Group Participant Scan β cross-references the LID against group participant lists
- Block + Admin Notify β if all layers fail, the message is blocked and the admin receives a WhatsApp notification with:
- The LID number
- The sender's push name
- A ready-to-use
map <LID> <PHONE>command
Mapping LIDs (3 Methods) β
1. Dashboard UI (recommended)
Navigate to Channels β Configure WhatsApp β LID Identity Mappings. Pending blocked LIDs appear as amber cards. Type the phone number and click Map.
2. WhatsApp Command
Reply to the bot via WhatsApp DM:
map 177472511426665 61423475992The admin (first entry in allowedDMs) can send this command. The bot confirms with β
.
3. CLI Command
openspider lid-map 177472511426665 61423475992Maps the LID to the phone number via the running gateway API.
LID Configuration Files β
| File | Purpose |
|---|---|
workspace/lid_cache.json | Persistent LIDβphone mappings |
workspace/lid_notified_cache.json | LIDs already notified to admin (dedup, survives restarts) |
workspace/whatsapp_config.json | allowedDMs[].lid field on mapped contacts |
Email Notification Settings β
Configure email delivery for automated outputs and outbound emails.
Dashboard Configuration β
In Channels β Configure WhatsApp β Email Notification Settings, set:
| Field | Purpose |
|---|---|
| Cron Job Results To | Email address where automated cron job results are delivered |
| Vendor & Friends To | Default email address for outbound emails to vendors/contacts |
Leave a field empty to disable that email destination.
Settings are stored in workspace/email_config.json.
API β
# Read current config
curl http://localhost:4001/api/email/config -H "x-api-key: YOUR_KEY"
# Save config
curl -X POST http://localhost:4001/api/email/config \
-H "x-api-key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"cronResultsTo":"admin@example.com","vendorEmailTo":"vendor@example.com"}'Outbound Message Deduplication β»οΈ β
OpenSpider features a node-wide cryptographic deduplication cache across both the WhatsApp and Gmail pipelines.
When the agent attempts to send multiple identically structured messages to the same exact recipient during a single workflow or interval step (often caused by duplicated prompt delivery rules), the Gateway securely evaluates a SHA-256 rolling hash of the outbound payload.
Any exact outbound payload duplicates sent within a 10-minute sliding window are silently suppressed and dropped at the final network mile. This natively protects your WhatsApp and Email inboxes from accidental multi-part bot spam!
Message Handling Flow β
Incoming Message
β
βΌ
Is it a DM? ββyesβββΈ Check dmPolicy βββΈ allowlist? βββΈ Is sender in allowedDMs?
β β
no yes / no
β β β
βΌ Process Ignore
Is it a Group? ββyesβββΈ Check groupPolicy βββΈ Is group in allowedGroups?
β β
no (ignore) yes / no
β β
Check mode Ignore
β
βββββββββββββ΄ββββββββββββ
β β
mention listen
β β
Is @mentioned? Process all
β β
yes no
β β
Process Ignore