packages/docs/connectors/whatsapp.md
Connect your agent to WhatsApp for private chats and group conversations via personal or business accounts using the @elizaos/plugin-whatsapp package.
| Name | Required | Description |
|---|---|---|
WHATSAPP_AUTH_METHOD | No | Authentication method: cloudapi or baileys |
WHATSAPP_ACCESS_TOKEN | No | WhatsApp Business API access token (required for cloudapi auth) |
WHATSAPP_PHONE_NUMBER_ID | No | Phone number ID from Meta Developer Dashboard (required for cloudapi auth) |
WHATSAPP_AUTH_DIR | No | Directory for Baileys session files (required for baileys auth) |
WHATSAPP_PRINT_QR | No | Print QR code in terminal when using Baileys auth |
WHATSAPP_WEBHOOK_VERIFY_TOKEN | No | Webhook verification token |
WHATSAPP_BUSINESS_ACCOUNT_ID | No | WhatsApp Business Account ID |
WHATSAPP_API_VERSION | No | API version string |
WHATSAPP_DM_POLICY | No | DM policy (e.g., allow, deny, allowlist) |
WHATSAPP_GROUP_POLICY | No | Group message policy |
The connector auto-enables when authDir, authState, sessionPath, or accounts with at least one account having authDir is present, and enabled is not explicitly false.
In ~/.eliza/eliza.json (Baileys / QR code):
{
"connectors": {
"whatsapp": {
"accounts": {
"default": {
"enabled": true,
"authDir": "./auth/whatsapp"
}
}
}
}
}
Or with a top-level authDir (single account shorthand):
{
"connectors": {
"whatsapp": {
"authDir": "./whatsapp-auth"
}
}
}
To explicitly disable the connector even when auth config is present:
{
"connectors": {
"whatsapp": {
"authDir": "./whatsapp-auth",
"enabled": false
}
}
}
authDir in your connector config (e.g., "./auth/whatsapp").WHATSAPP_ACCESS_TOKEN, WHATSAPP_PHONE_NUMBER_ID, and WHATSAPP_AUTH_METHOD=cloudapi.Baileys connects via the WhatsApp Web multi-device protocol. No API keys or business accounts are needed. On first start, a QR code is printed to the terminal. Scan it with your phone (WhatsApp > Settings > Linked Devices > Link a Device) to authenticate.
Pros: No API costs, works with personal accounts, full feature access. Cons: Requires a phone with WhatsApp linked, session can expire if phone disconnects.
The WhatsApp Business Cloud API is Meta's official API. Requires a WhatsApp Business Account and access tokens from the Meta Developer Dashboard.
Pros: Official API, reliable uptime, webhook-based. Cons: Requires business account, per-message costs may apply, approval process.
All fields are defined under connectors.whatsapp in eliza.json.
| Field | Type | Default | Description |
|---|---|---|---|
accounts | object | -- | Named account configurations (see Multi-Account below) |
authDir | string | -- | Directory for Baileys session files (single-account shorthand) |
enabled | boolean | -- | Explicitly enable/disable |
dmPolicy | "pairing" | "allowlist" | "open" | "disabled" | "pairing" | DM acceptance policy. "open" requires allowFrom to include "*" |
allowFrom | string[] | -- | Allowlist of phone numbers (required when dmPolicy: "open") |
groupPolicy | "open" | "disabled" | "allowlist" | "allowlist" | Group message policy |
groupAllowFrom | string[] | -- | Allowlist of group JIDs |
historyLimit | number | -- | Max messages to load from conversation history |
dmHistoryLimit | number | -- | Max messages for DM history |
textChunkLimit | number | -- | Max characters per outgoing message chunk |
chunkMode | "length" | "newline" | -- | Long message splitting strategy |
mediaMaxMb | number | 50 | Max media attachment size in MB |
sendReadReceipts | boolean | -- | Send read receipts for incoming messages |
selfChatMode | boolean | -- | Respond to your own messages (for testing; avoid in production) |
messagePrefix | string | -- | Text prefix added to all outgoing messages |
debounceMs | number | 0 | Delay in ms before responding, to allow message batching |
blockStreaming | boolean | -- | Disable streaming responses |
groups | object | -- | Per-group configuration overrides |
Configure emoji reactions sent as message acknowledgments:
{
"connectors": {
"whatsapp": {
"ackReaction": {
"emoji": "eyes",
"direct": true,
"group": "mentions"
}
}
}
}
| Field | Type | Default | Description |
|---|---|---|---|
ackReaction.emoji | string | -- | Reaction emoji to send as acknowledgment |
ackReaction.direct | boolean | true | Send ack reactions in DMs |
ackReaction.group | string | "mentions" | Group ack behavior: "always", "mentions", or "never" |
The accounts field allows running multiple WhatsApp sessions from a single agent. Each account gets its own Baileys auth directory and QR code pairing flow.
{
"connectors": {
"whatsapp": {
"accounts": {
"account-1": {
"enabled": true,
"authDir": "./auth/whatsapp-1"
},
"account-2": {
"enabled": true,
"authDir": "./auth/whatsapp-2"
}
}
}
}
}
Each account under accounts.<name> supports all top-level fields plus:
| Field | Type | Description |
|---|---|---|
enabled | boolean | Enable or disable this account |
authDir | string | Directory for Baileys session files (required per account) |
name | string | Display name for this account |
When selfChatMode is true, the agent responds to messages you send to yourself (the "Message Yourself" chat). This is useful for testing without involving other contacts. Avoid enabling in production.
{
"connectors": {
"whatsapp": {
"selfChatMode": true
}
}
}
Baileys saves its session state to the directory specified by authDir. This includes:
The session persists across restarts. A new QR code is only generated when:
authDir are deleted or corruptedSecurity considerations:
auth/ should be in .gitignore)Verify that at least one of the auto-enable triggers is present in your config:
authDir at the top level, oraccounts with authDir set and enabled: trueQR codes have a short TTL (typically around 20 seconds). The connector automatically generates a new QR code when the previous one expires. Make sure your phone has internet access when scanning.
If reconnection fails with a session error:
authDir directorydmPolicy: "open" Validation ErrorWhen setting dmPolicy to "open", you must also set allowFrom: ["*"]. This is a safety requirement enforced by the config validator:
{
"dmPolicy": "open",
"allowFrom": ["*"]
}
WhatsApp has undocumented rate limits. If the agent sends messages too rapidly, the connection may be throttled or temporarily banned. Use debounceMs to add delays:
{
"debounceMs": 1000
}