Back to Blog
Integration Guides

How to Integrate Twilio with Chatfuel: Step-by-Step Guide

Add Twilio SMS to Chatfuel bot flows so conversations started on Messenger can continue via text when users leave the platform.

DA
Danial A
Senior Twilio Consultant, Telphi Consulting
June 22, 2026
7 min read
Twilio
Integration
Messaging
AI Bots
How to Integrate Twilio with Chatfuel: Step-by-Step Guide

Chatfuel and Twilio integrate through Chatfuel's JSON API plugin and external HTTP request blocks to add Twilio SMS as an outbound channel from your Chatfuel Messenger bot flows, allowing your bot to send a text message to a subscriber's phone when a key event occurs in the Messenger conversation such as a purchase, appointment booking, or account action. This integration is used by businesses running Chatfuel bots for customer acquisition and support on Facebook Messenger who want to extend the conversation to SMS when the 24-hour Messenger window closes or when the subscriber explicitly requests a text reminder. The connection routes subscriber phone numbers collected within the Chatfuel flow to a middleware endpoint or Zapier webhook that dispatches the Twilio SMS and optionally stores the result in your CRM.

What You Need Before You Start

Confirm your Chatfuel account has access to the JSON API plugin or the HTTP Request block, which are available on Chatfuel's paid plans and allow your bot to call external services including your Twilio SMS middleware. Add a phone number collection step to your Chatfuel flow by inserting a User Input block set to collect a phone type, which validates the format and saves the value to a Chatfuel user attribute named phone or a custom attribute name you define in the block settings. From Twilio, collect your Account SID, Auth Token, and an SMS-capable phone number registered under an A2P 10DLC campaign, and optionally set up a Twilio Messaging Service in the Console under Messaging, then Services for improved deliverability on high-volume sends. Deploy a lightweight middleware server or Zapier webhook that receives the subscriber's phone and message payload from Chatfuel and calls the Twilio Messages API, returning a valid JSON response in the Chatfuel JSON API format so the block succeeds and the flow continues without error.

Step-by-Step Integration Guide

Insert a JSON API plugin block in your Chatfuel flow at the point where you want to trigger the Twilio SMS, set the URL to your middleware endpoint, the HTTP method to POST, and the request body to a JSON object containing the subscriber's phone attribute using the Chatfuel dynamic variable syntax such as {"phone": "{{phone}}", "name": "{{first name}}", "message": "Your appointment is confirmed for tomorrow at 10am"}, which sends the subscriber's stored attribute values to your middleware. In your middleware, receive the Chatfuel POST, extract the phone, name, and message fields, normalize the phone to E.164 format, and dispatch a Twilio SMS by calling POST https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Messages.json with Basic authentication, To set to the normalized phone, From set to your Twilio number, and Body set to a personalized message composed from the received fields. Return a valid Chatfuel JSON API response from your middleware with HTTP 200 and a JSON body containing messages as an array with at least one text block such as {"messages": [{"text": "SMS sent to your phone."}]} so Chatfuel displays a confirmation message to the subscriber in Messenger after the SMS is dispatched. For the Zapier path, use a Chatfuel flow step to save the subscriber phone and message to a Google Sheet row via Zapier, then trigger a second Zap on new Google Sheet rows that dispatches the Twilio SMS, avoiding the need for a custom middleware server.

Common Issues and How to Fix Them

Chatfuel JSON API blocks fail silently when the middleware endpoint returns any HTTP status other than 200 or returns a malformed JSON response that is not in the Chatfuel JSON API format, causing the flow to show an error state to the subscriber without displaying a useful error message. Always return a properly structured Chatfuel JSON API response body from your middleware even when the Twilio SMS dispatch fails, including an error_message text block in the messages array that explains the failure to the subscriber so they know the SMS was not sent. The phone attribute collected by Chatfuel's User Input block may contain a formatted number with spaces, hyphens, or parentheses that is not E.164-compatible and causes Twilio to return a 21211 error when your middleware passes it unchanged to the To parameter. Add a phone normalization step in your middleware before the Twilio call that strips all non-digit characters using a regex and prepends the country code prefix based on the subscriber's locale if available from the Chatfuel context, and validate the resulting number using the Twilio Lookup API before dispatching. Chatfuel does not provide a built-in mechanism to retry failed JSON API calls, so if your middleware is temporarily unavailable when the block fires the SMS is never sent and the subscriber receives the bot's fallback error message. Implement a queue in your middleware that stores each SMS request and processes it with retry logic using exponential backoff, so temporary failures are automatically retried rather than permanently lost.

How to Get More from This Integration

Build an abandoned cart SMS recovery by connecting Chatfuel to your e-commerce platform via the JSON API block, detecting when a subscriber views a product but does not complete checkout within 30 minutes using a Chatfuel scheduled condition, and dispatching a Twilio SMS to the subscriber's phone with the product name and a checkout link, reaching them on a channel they will see even if they have closed Messenger. Add a two-way SMS reply handler by configuring your Twilio inbound SMS webhook to call the Chatfuel API at POST https://api.chatfuel.com/bots/{botId}/users/{userId}/send with your bot token and a text message block, re-entering the subscriber into a specific Chatfuel flow block based on their SMS keyword, bridging the SMS reply back into the Chatfuel conversation context. Create a cross-channel reactivation campaign by identifying subscribers in Chatfuel whose last bot interaction was more than 7 days ago using the Chatfuel People tab export, importing their phones into a Twilio bulk SMS campaign that drives them back to the Chatfuel bot via a m.me link in the SMS body, reactivating dormant subscribers through a channel they are more likely to engage with. Extend the integration to Twilio WhatsApp by changing the To prefix in your middleware from a plain E.164 number to whatsapp:{phone} and the From to whatsapp:{twilioWhatsAppNumber}, allowing your Chatfuel Messenger bot to trigger a WhatsApp follow-up for subscribers who have opted in, adding a third channel to the Chatfuel SMS extension without changing the Chatfuel flow structure.

Conclusion

Chatfuel and Twilio together let your Messenger bot extend its reach to SMS when subscribers leave Facebook, ensuring your follow-up messages arrive on the most personal channel available rather than being missed in a closed Messenger thread. Reach out to Telphi Consulting to configure and build the Chatfuel Twilio SMS bridge for your bot automation workflows.

Share this article:
0 views

Ready to Transform Your Business Communications?

Get a free consultation with our VoIP experts and discover how we can help you save costs, improve efficiency, and scale your business.

Comments (0)

Join the discussion and share your thoughts (AI-moderated for quality)

Protected by AI moderation

Be the first to comment

No comments yet. Share your thoughts below.