Skip to main content
The WhatsApp interface connects agents to WhatsApp with two transport providers:
  • Twilio — Managed webhook + REST API. Paid. Production-ready. No QR login.
  • Baileys — Self-hosted via Node.js sidecar. Free. Full protocol access (polls, reactions, groups, QR login).

Quick Start (Baileys)

The fastest way to get a WhatsApp agent running — no API keys, no webhooks, just scan a QR code.
On first run, a QR code appears in your terminal. Scan it with WhatsApp on your phone. After linking, credentials are saved to auth_dir and subsequent runs connect automatically.
Baileys requires Node.js >= 18 on the host. The bridge dependencies (@whiskeysockets/baileys, ws) are auto-installed on first run via npm install.

Quick Start (Twilio)

For production deployments using the Twilio WhatsApp Business API.
Configure your Twilio WhatsApp webhook to point to http://your-server:8000/whatsapp/webhook.

Provider Comparison

WhatsAppInterface Parameters

Provider Selection

str
default:"twilio"
Transport provider: "twilio" or "baileys".

Twilio Parameters

str
Twilio account SID. Required when provider="twilio".
str
Twilio auth token. Used for REST API calls and webhook signature validation.
str
WhatsApp sender number (format: whatsapp:+14155238886). Required for Twilio.
bool
default:"true"
Validate X-Twilio-Signature on incoming webhooks. Disable only for local testing.

Baileys Parameters

str
default:"./whatsapp-auth"
Directory for WhatsApp credential storage. Created automatically.
str
default:"node"
Path to the Node.js binary. Override if node is not on your PATH.
int
default:"0"
WebSocket port for the sidecar. 0 = auto-assign (recommended).
int
default:"12"
Maximum reconnect attempts before giving up after a disconnect.
int
default:"60"
Heartbeat interval for the sidecar connection.

Shared Parameters

WhatsAppPolicy
Sender access control policy. See Access Control below.
bool
default:"true"
Convert Markdown formatting in agent responses to WhatsApp-compatible formatting (**bold** to *bold*, etc.).
int
default:"4000"
Maximum characters per message. Long responses are split at word boundaries.
str
default:"/whatsapp/webhook"
URL path for the Twilio webhook endpoint.
bool
default:"false"
Enable verbose logging in both Python and the Node.js sidecar.

Access Control

Use WhatsAppPolicy to control which messages reach the agent.

Policy Options

str
default:"allowlist"
Direct message policy: "allowlist" (only allow_from), "open" (all DMs), or "disabled" (block all DMs).
List[str]
Allowed sender phone numbers in E.164 format. Use "*" for wildcard.
str
default:"open"
Group message policy: "open", "allowlist", or "disabled".
List[str]
Separate allowlist for group senders. Falls back to allow_from if not set.
str
Your own phone number (E.164). Used for self-chat detection.
The default dm_policy is "allowlist" with an empty allow_from list. This means no one can message your agent unless you explicitly add numbers. Set dm_policy="open" to allow all senders, or populate allow_from.

Media Support

Both providers handle media, but with different capabilities: Incoming media is converted to Definable’s Image, Audio, Video, and File types and passed to the agent.

Voice Notes

WhatsApp voice notes work with audio_transcriber=True:

Sending Media

Agents can send media back via tool responses:

Markdown Conversion

When markdown_conversion=True (default), agent responses are automatically converted to WhatsApp-compatible formatting: Fenced code blocks are preserved as-is (WhatsApp renders triple backticks natively).

Baileys Features

QR Login

The Baileys provider supports programmatic QR login:

Polls

Reactions

Health Check

Phone Number Normalization

Phone numbers are automatically normalized to bare E.164 (digits only, no +):

Complete Production Example

Imports