Twilio: SMS and WhatsApp
Pro PlusEvents Manager ConnectConnect is an add-on included in the Pro Plus plan, with its own license. You also need a Twilio account, which Twilio bills separately.
Twilio is a messaging provider that can send both SMS and WhatsApp messages from one account. Connect uses your Twilio credentials to send booking notifications and reminders. SMS text is written in Connect. WhatsApp messages use templates you create in Twilio and have approved for WhatsApp.
- Turn on international phone numbers, so numbers are stored in the format Twilio expects. See Phone numbers and consent.
- Your site needs a public HTTPS address if you want Twilio to pass WhatsApp replies back to it.
What to create at Twilio
Twilio's console changes often, so this section names what you need and links to Twilio's own instructions.
| You need | For | Where to get it |
|---|---|---|
| Account SID and Auth Token | SMS and WhatsApp | The account dashboard in the Twilio Console |
| An SMS-capable phone number | SMS | Buy one under Phone Numbers in the console |
| A Messaging Service | WhatsApp, optional for SMS | Messaging Services. Add your SMS number or WhatsApp sender to its sender pool. Its SID starts with MG. |
| A WhatsApp sender | WhatsApp in production | Register a number for WhatsApp through Twilio. See Twilio's WhatsApp self sign-up guide. |
| The WhatsApp sandbox | WhatsApp testing | Twilio Sandbox for WhatsApp |
| Content templates approved for WhatsApp | WhatsApp notifications and reminders | The Content Template Builder. Each template has a Content SID starting with HX. |
A Twilio trial account can only send to numbers you have added as verified caller IDs.
Enter your Twilio details in Connect
-
Go to Events then Settings then Connect and open the Twilio box under Connection Settings.
-
Tick Enable Twilio. Enable SMS and Enable WhatsApp are ticked along with it.
-
Paste your Account SID and Auth Token.
-
If you use a Messaging Service, paste its SID into Messaging Service SID. It is needed for WhatsApp. For SMS you can leave it empty, and messages are sent from your number through Twilio's standard API.
-
For SMS, enter your Twilio number in Twilio SMS number in international format, for example
+15550100100. -
For WhatsApp, enter your sender's number in Twilio WhatsApp number, also in international format and without the
whatsapp:prefix. Connect adds the prefix itself. -
Click Save Changes (All).
The Twilio box. The Auth Token and Messaging Service SID fields hide what you type.
Fields in the Twilio box
| Field | What to enter |
|---|---|
| Enable Twilio | Turns the Twilio transports on. |
| Account SID | Your account identifier from the Twilio Console. It starts with AC. |
| Auth Token | The token shown beside the Account SID in the console. Connect uses it to send, and to check that incoming webhooks are from Twilio. |
| Messaging Service SID | Optional for SMS, needed for WhatsApp. When filled in, it is sent with every Twilio message. |
| Enable SMS | Shows or hides the SMS number and test fields. |
| Twilio SMS number | The SMS-capable number messages are sent from. Without a number, SMS can't be sent. |
| Test Messages | A phone number field and the Send Test SMS button. |
| Enable WhatsApp | Shows or hides the WhatsApp number and test fields. |
| Twilio WhatsApp number | The number of your WhatsApp sender, or the sandbox number while testing. |
| Test WhatsApp | A template field, a phone number field and the Send Test WhatsApp button. |
Set the webhook URL at Twilio
At the top of the Twilio box, Connect prints the address Twilio should call when a customer replies:
Your webhook URL to receive responses is https://example.com/wp-json/events-manager/v1/connect/twilio/webhook
The same URL serves SMS and WhatsApp. Copy it from your own settings screen and paste it at Twilio as the URL for incoming messages, using the HTTP POST method:
- For a WhatsApp sender, in the sender's settings, as the webhook for incoming messages.
- For the sandbox, in the sandbox settings, in the field for when a message comes in.
- For a Messaging Service, in its Integration settings, by choosing to send a webhook and entering the URL as the request URL.
You only need this for WhatsApp. Connect doesn't act on SMS replies.
Connect checks every incoming request against the signature Twilio adds to it, using your Auth Token and the exact webhook URL shown in the settings. A request that fails the check is ignored. If your site sits behind a proxy or a tunnel that changes its public address, the check fails until the URL Connect expects matches the URL Twilio calls. You can set that address in wp-config.php:
define( 'EM_CONNECT_WEBHOOK_DOMAIN', 'https://public-address.example.com/wp-json/' );
Sandbox or approved sender
| Sandbox | Approved WhatsApp sender | |
|---|---|---|
| Purpose | Testing | Live use |
| Number | A shared Twilio number | Your own number, registered for WhatsApp |
| Who can receive | Only phones that have joined your sandbox by sending it the join phrase Twilio shows you | Anyone with WhatsApp |
| Templates | Twilio's pre-approved sandbox templates, or free text to a phone that messaged the sandbox in the last 24 hours | Your own approved content templates |
To test with the sandbox, enter the sandbox number as Twilio WhatsApp number, set the webhook URL in the sandbox settings, and join the sandbox from your own phone. When you move to an approved sender, replace the number, set the webhook on the sender or its Messaging Service, and switch your template IDs to your approved templates.
Write the messages
Messages are set up further down the Connect tab, in the SMS via Twilio and WhatsApp via Twilio boxes under Booking Status Notifications and Booking Reminders. The Notifications and Reminders page covers statuses, placeholders and timing. The parts specific to Twilio are below.
SMS
Tick Enable Notifications in the SMS via Twilio box and type a Message for each status you want to send. The text can contain placeholders and is sent as plain text. Leave a message empty to send nothing for that status.
WhatsApp templates and variables
WhatsApp only lets a business start a conversation with a pre-approved template. In the WhatsApp via Twilio box, each status has two fields:
Each status takes the Content SID of a Twilio template and one line per template variable.
| Field | What to enter |
|---|---|
| Template ID | The Content SID of the template, copied from Twilio's Content Template Builder. It starts with HX. Leave it empty to send nothing for that status. |
| Variables | One line per variable in the template, in order. Line 1 fills {{1}}, line 2 fills {{2}}, and so on. Each line can contain placeholders. |
For example, a template whose body is Hi {{1}}, your booking for {{2}} on {{3}} is confirmed. needs these three lines in Variables:
#_BOOKINGNAME
#_EVENTNAME
#_EVENTDATES
The number of lines must equal the number of variables in the template. Twilio rejects the message otherwise.
Connect recognizes a Content SID by its shape: a single word starting with a capital H. Anything else in Template ID is sent as the message text itself, which WhatsApp only delivers to someone who has messaged you within the last 24 hours. For notifications, always use a Content SID.
What happens when customers reply
| Channel | Replies |
|---|---|
| SMS | Not processed by Connect. |
| WhatsApp through Twilio | Typed commands such as opt-out and opt-in are answered in plain text. |
The booking menus described in Customer commands are built from buttons and lists, which Connect creates for the WhatsApp Cloud API and Telegram. If you want customers to manage bookings by message, use one of those.
Test your setup
Send a test SMS
- In the Twilio box, fill in the credentials and Twilio SMS number. You don't have to save first: the test uses what is typed in the form.
- Enter your own mobile number in the Test Messages field.
- Click Send Test SMS. The message reads This is a test message from Events Manager, it works!
Send a test WhatsApp message
- Fill in the credentials, Messaging Service SID and Twilio WhatsApp number.
- Under Test WhatsApp, replace
hello_worldin the first field with the Content SID of one of your templates. - Enter a WhatsApp number in the second field. With the sandbox, it must be a phone that has joined.
- Click Send Test WhatsApp.
In Connect 1.0.2 both test buttons answer Message Sent! even when Twilio refused the message. Treat the test as passed only when the message arrives. If it doesn't, the reason is in your Twilio Console under the messaging logs.
Test a real notification
Enable a message for the Confirmed or Pending status, then book a place on one of your events as a visitor, with your own number. This tests the whole chain: the phone field, consent, the status and the template.
Troubleshooting
The test says Message Sent! but nothing arrives
Look up the message in the Twilio Console's messaging logs. Common causes are a trial account sending to a number that isn't a verified caller ID, a Twilio SMS number that isn't in your account, and a WhatsApp recipient who hasn't joined the sandbox.
WhatsApp notifications fail but the test worked
Count the lines in Variables against the variables in the template, and check that the template is approved for WhatsApp and belongs to the same account.
Replies on WhatsApp get no answer
Check the webhook URL at Twilio, that it uses POST, and that it is identical to the URL shown in the Twilio box.
More cases are on the Connect troubleshooting page.