Prerequisites
- A Twilio account (free trial works for testing)
- A Twilio phone number with WhatsApp enabled, or the Twilio WhatsApp Sandbox
- Your agent created and tested in thinnestAI
Setup
Step 1: Get Twilio Credentials
- Log in to Twilio Console
- Copy your Account SID and Auth Token from the dashboard
Step 2: Configure Your Agent
- Open your agent in thinnestAI
- Go to the Deploy tab
- Select WhatsApp
- Enter your Twilio credentials:
- Account SID — Your Twilio Account SID
- Auth Token — Your Twilio Auth Token
- Phone Number — Your Twilio WhatsApp number (e.g.,
+14155238886for sandbox)
- Click Save & Enable
Step 3: Set the Webhook URL
- In Twilio Console, go to Messaging > Try it out > Send a WhatsApp message (for sandbox) or your WhatsApp sender configuration
- Set the webhook URL to:
- Set the HTTP method to POST
Step 4: Test It
- Sandbox: Send the join code shown in Twilio to
+1 415 523 8886via WhatsApp - Production: Message your WhatsApp Business number directly
How It Works
Session Persistence
Each phone number gets its own conversation session with your agent. When a user messages again, the agent remembers the full conversation history. Session ID format:twilio_{agent_id}_{phone_number}
Automatic Lead Capture
Every WhatsApp user is automatically captured as a lead with:- Phone number from the sender’s WhatsApp number
- Platform:
whatsapp - Deduplication: One lead per phone number per agent (no duplicates)
Message Limits
WhatsApp/Twilio has these constraints:
Messages longer than 1,500 characters are automatically truncated with
....
Security
- Signature verification: Every incoming webhook is verified using the
X-Twilio-Signatureheader and your Auth Token - Credentials encrypted: Your Twilio credentials are encrypted at rest in the database
- No plaintext storage: Auth tokens are never stored in plaintext
Sandbox vs Production
Testing with Sandbox
- Go to Twilio WhatsApp Sandbox
- Follow the “join” instructions to connect your phone
- Send a test message — your agent should respond
- Check the Leads dashboard for the auto-captured lead

