Twilio
The Twilio integration allows you to connect your ChatBotKit AI bot to Twilio's communication platform, enabling your bot to communicate via SMS, phone calls, WhatsApp, and other supported messaging channels. This means your AI assistant can respond to text messages, handle inbound calls, start outbound conversations, and provide automated support through mobile channels.
What You Can Do
With the Twilio integration, you can:
- SMS Conversations: Let customers text your phone number and get AI-powered responses
- Voice Calls: Let customers call your phone number and speak with a voice-enabled AI agent
- WhatsApp Business: Connect your bot to WhatsApp Business API for rich messaging experiences
- Multi-Channel Support: Handle conversations across SMS, WhatsApp, and other Twilio-supported channels
- Phone Number Management: Use your existing Twilio phone numbers or acquire new ones for your bot
- Automated Responses: Provide 24/7 support through text and phone conversations without manual intervention
- Two-Way Communication: Your bot can both receive and send messages, creating natural conversations
How It Works
When someone sends a message or calls your Twilio phone number, Twilio forwards that interaction to ChatBotKit through a webhook. Your AI bot processes the message or transcribed speech, generates an appropriate response using its knowledge and configuration, and sends the reply back through Twilio as either text or spoken TwiML.
The integration maintains conversation context, so your bot remembers previous messages within a session. This allows for natural, coherent conversations where the bot can reference earlier parts of the discussion, just like it would in a web chat.
You can restrict inbound access with the allowed senders setting. Add one or
more E.164 phone numbers, separated by commas or new lines, to accept only
those SMS messages and calls. Use * to allow everyone, or leave the field
empty to block all inbound senders.
Getting Started
To set up your Twilio integration:
- Create the Integration: Click "Create Integration" and give it a descriptive name (like "Customer Support SMS")
- Select Your Bot: Choose which AI bot will handle the conversations on this channel
- Configure Twilio Credentials: Enter the Account SID and Auth Token for the Twilio account that owns your messaging number
- Configure Basic Settings: Add a description and adjust settings like session duration
- Get Your Webhook URL: After creating the integration, you'll see a webhook URL in the setup section
- Configure Twilio: In your Twilio Console, add the webhook URL to your phone number's messaging configuration
- Test It Out: Send a test message or place a test call to your phone number and watch your bot respond!
The Account SID and Auth Token let ChatBotKit send delayed SMS replies and initiate outbound SMS or phone-call conversations through Twilio.
Setting Up the Twilio Webhook
The webhook is how Twilio communicates with ChatBotKit. Here's what you need to do in your Twilio Console:
- Log into the Twilio Console
- Navigate to Phone Numbers > Active Numbers and select your number
- Scroll to the Messaging or Voice section
- Set the incoming message or call webhook to HTTP POST
- Paste your ChatBotKit webhook URL (shown in the integration page)
- Save your configuration
For WhatsApp, the process is similar but you'll configure the webhook in your WhatsApp Business API settings instead.
Best Practices
Start Simple: Begin with a straightforward bot configuration and test thoroughly before adding complexity. Send test messages to ensure responses are appropriate and helpful.
Set Clear Expectations: In your bot's backstory or instructions, include guidelines for SMS and voice conversations. Text messages are typically shorter and more informal than web chats, while spoken replies should be concise and easy to understand.
Monitor Costs: Both Twilio and ChatBotKit have usage-based pricing. Keep an eye on message volumes and conversation lengths to manage costs effectively.
Handle Session Duration: SMS conversations often have longer pauses than web chats. Consider setting a longer session duration (like 1-2 hours) so users can return to the conversation without losing context.
Test Different Scenarios: Try various message and call types - questions, commands, typos, pauses, and interruptions - to ensure your bot handles them gracefully.
Compliance Matters: If you're texting customers, make sure you're following regulations like TCPA (in the US) and GDPR (in Europe). Get proper consent before sending marketing messages.
Practical Use Cases
Customer Support: Let customers text a support number to get instant help with common questions, troubleshooting, or account inquiries. Your bot can handle the routine questions while escalating complex issues.
Appointment Reminders: Use your bot with Twilio to send automated appointment reminders and allow customers to confirm, reschedule, or cancel via text.
Order Status Updates: Customers can text your number to check on order status, tracking information, or delivery estimates without calling or visiting a website.
Restaurant Reservations: Accept table reservations via SMS, with your bot asking for party size, date, time, and special requests.
Lead Qualification: Capture leads through SMS campaigns, with your bot asking qualifying questions and gathering contact information for your sales team.
The Twilio integration brings the power of conversational AI to mobile messaging and phone calls, meeting your customers where they already spend much of their time.