Twilio
Use Twilio to send text messages (SMS) from your Twilio number and WhatsApp messages from your WhatsApp sender, such as reminders and confirmations. To connect, you need your Twilio Account SID and a Twilio API key.
A Twilio trial account can’t send your app’s own text messages, so upgrade your Twilio account before you build a feature that sends texts. To text numbers in the US or Canada, Twilio also needs your sender number registered in the Twilio Console. A text over 160 characters, or 70 with emoji or non-Latin letters, is sent and billed as several messages.
Connect Twilio
Only a project owner can connect Twilio, and everyone on the project can use it after that. To connect Twilio, first create a Standard API key in the Twilio Console under Settings › Account settings › API keys & auth tokens. Copy its SID, which starts with SK, and its secret. Twilio shows the secret only once. Your Account SID, which starts with AC, is on the Twilio Console home page.
- Open Project Settings › Connections, and then turn on the switch for Twilio.
- If you already connected Twilio in another of your apps, the dialog first shows Use the key from and that app’s name. To paste a different key, click Paste your Twilio details.
- In the Connect Twilio dialog, paste your Account SID, your API key SID, and your API key secret. To open Twilio’s help on API keys, click Find it beside the first label.
- Click Connect.
Twilio checks the key before FlutterFlow saves the connection. For more about connecting, see Connect a service.
What to ask
Ask the agent for the message you want, who gets it, and what triggers it. With Twilio connected, your app can list your Twilio phone numbers and WhatsApp senders, send a text or WhatsApp message, and check a message’s status, such as delivered or failed.
When a booking is confirmed, text the customer a confirmation from my Twilio number with the date and time.
Add a Send a text button to the customer screen that texts the customer from my Twilio number.
Add an admin screen that shows whether each reminder text was delivered.
Phone numbers go in international format: a +, the country code, and then the number, such as +14155550123. A long text is sent and billed as several messages.
Your app sends WhatsApp messages from a WhatsApp sender in your Twilio account. A sender of your own needs an upgraded Twilio account, a Meta business and WhatsApp’s approval of its name; the WhatsApp senders page in the Twilio Console walks you through it. To try WhatsApp first, use the Twilio Sandbox for WhatsApp, which sends only to phones that joined your Sandbox. A phone stays joined for 72 hours.
Your app can send free-form text only within 24 hours of the person’s last message to your sender. Anything your app starts later, such as a reminder the next day, must be a template that WhatsApp approved. Create one in the Twilio Console’s Content Template Builder, and give the agent its Content SID, which starts with HX.
The day before an appointment, send the customer a WhatsApp reminder with my approved template, filling in the day and the time.
Agent questions
If Twilio isn’t connected, the agent asks you to connect it in a card above the message box. If you aren’t a project owner, ask one to connect it. See Connect when the agent asks.
Review
After the agent finishes, read the turn’s Summary and review its Changes. Check the affected screens in Screens, and try the change in Preview. If the change uses records or sign-in, test it with the thread’s own data in Data.
After you push a backend change, check the result in Backend.
Calls from the preview are real, so testing the feature sends real messages. Test with a phone number that you own. See How connections work.
Twilio first reports a message as queued or accepted, and delivers it shortly after. A WhatsApp message outside the 24 hours, or to a phone that hasn’t joined your Sandbox, is accepted at first and fails later. To see what happened, ask the agent to check the message’s status.
Call limit
Your app and the agent share a limit of 60 calls a minute to Twilio through your app’s connection. See Limits.
Push
After you test the feature, push the changes to your app.
Next steps
- To replace the API key or disconnect Twilio, see Manage connections. If you disconnect Twilio, your app stops sending text and WhatsApp messages.
- For other services your app can use, see Available services.
Troubleshooting
- The dialog says “That’s an API key SID.”: you pasted the API key SID into Account SID. Paste the Account SID, which starts with
AC, from the Twilio Console home page. - The dialog says “That’s the Account SID.”: you pasted the Account SID into API key SID. Paste the SID of your API key, which starts with
SK. - You lost the API key secret: Twilio shows it only once. Create a new API key, and paste its SID and secret.
- A WhatsApp message fails with error 63016: the person hasn’t messaged your sender in the last 24 hours. Send an approved template instead.
- A WhatsApp message fails with error 63015: the phone hasn’t joined your Twilio Sandbox, or it joined more than 72 hours ago. From the phone, send the Sandbox the join message shown in the Twilio Console, or send from a WhatsApp sender of your own.
- Texts to US or Canadian numbers don’t arrive: register your sender number in the Twilio Console.
- For a key that’s refused or a connection that needs attention, see Troubleshoot connections.