Respond to inbound messages
When people send you WhatsApp messages, you can use automations to handle the incoming messages and trigger responses.
How it works
Customer.io treats inbound messages like events: they can trigger automations An automated process people enter when they meet your criteria. An automation has a trigger (who enters, and when), a workflow of messages and actions, and exit criteria (when they leave). A person's path through the workflow is their journey. A segment is a group of people in your workspace. Use segments to trigger automations, track membership over time, or fine-tune your audience. There are three types of segments: data-driven, snapshot, and manual. Data-driven segments automatically update when people start or stop matching criteria. Snapshot segments capture everyone who matches at a point in time and only change when you refresh them. Manual segments are static groups of people.
Unlike inbound SMS, we don’t parse WhatsApp messages into keywords for you. Instead, you match the contents of the message yourself. For example, you might branch an automation on the body of the message to route people who reply YES differently from people who reply NO—and you can match your own keywords inside a longer message, too.
Set up an inbound message automation
-
When you set up an automation, click the Trigger.
-
Select the Inbound message trigger option.
-
If you have more than one inbound channel enabled, set the Inbound channel to WhatsApp.
The Inbound message event that triggers your automation doesn’t differentiate between replies to different sender numbers. If you want to handle inbound replies to your different sender numbers independently, add conditions to your trigger based on the
tovalue. (Inbound messages comefromyour audience andtoyour WhatsApp sender number.)
Now you can set up message actions to respond to the inbound message or handle other updates. Remember, we don’t parse WhatsApp messages for keywords, so you need to match the contents of the message yourself. See Branch on the message body for more information.
Using inbound message data
Like other event-triggered automations, inbound message variables start with event. For example, you reference the message body with {{event.body}}.
{
"from": "+15551234567",
"to": "+15559876543",
"body": "yes",
"message_id": "wamid.HBgLMTU1NTk4NzY1NDMVAgAR",
"message_type": "text",
"in_reply_to": "01HA3K8Z9QF6N4XW2RBT5YVDPC",
"origin_action_id": 41,
"origin_campaign_id": 9
}| Variable | Description |
|---|---|
body | The body of the inbound message. For button or list replies, this is the title of the option the person selected |
from | The phone number of the person who sent the inbound message |
to | Your WhatsApp sender number that received the message, also the sender number of the message the person replied to |
message_id | WhatsApp’s unique ID for the inbound message |
message_type | The type of message the person sent, like text, image, button, or interactive |
has_media | true when the message includes a media attachment. Omitted when there’s no media |
media | Details of any media attachment, including content_type and media_id. Omitted when there’s no media |
reply_id | The ID of the quick-reply button or interactive list option the person selected. Omitted for other message types |
in_reply_to | The ID of the Customer.io delivery the person replied to, if applicable. See Attributing replies to your messages |
origin_campaign_id, origin_broadcast_id, origin_newsletter_id, origin_transactional_message_id | The ID of the automation, API-triggered broadcast, one-time send, or transactional message that started the conversation. A reply carries at most one of these, and none if we can’t attribute it to a message you sent. See Route replies to the right automation |
origin_action_id | The ID of the WhatsApp action A block in an automation workflow—like a message, delay, or attribute change. in the automation or API-triggered broadcast that sent the message that started the conversation. Only present withorigin_campaign_id or origin_broadcast_id |
Route replies to the right automation
To start an automation when people reply to a particular message, you can filter the inbound message trigger on the message that started the conversation.
Filter by the message that started the conversation
In your inbound message trigger, choose which replies start the automation with the Replying to setting:
- Anything: Every reply. This is the default.
- Not a reply: Inbound messages that we can’t attribute to a message you sent, like a person messaging your number unprompted.
- An automation, broadcast, or other send: Search for and select the automation, API-triggered broadcast, one-time send, or transactional message that started the conversation. The trigger fires for every reply in a conversation that the send started, including replies to messages that later automations sent in that conversation.
Replying to adds trigger filters on the A syntax that supports variables, letting you personalize messages for your audience. For example, if you want to reference a person's first name, you might use the variable origin_* fields of the event. You can add these filters yourself as well. For example, filter on origin_campaign_id equals 9 to handle replies in conversations started from the automation with ID 9. You can also use these fields in your messages with liquid{{customer.first_name}}.{{event.origin_campaign_id}}.
The origin of a reply
The origin is the automation, API-triggered broadcast, one-time send, or transactional message that started a conversation. An automation can send several messages, so the origin is the whole automation, not a single message in it. Each inbound event carries the origin as one origin_* ID field named for that kind, and none if we can’t attribute the reply to a message you sent. The ID in origin_broadcast_id is the ID of the API-triggered broadcast, the same ID you see in reporting webhooks and in messages from the App API.
The origin and in_reply_to differ. in_reply_to is the delivery the person replied to directly. The origin stays the same for the whole conversation, including when an inbound message triggers an automation that replies and the person responds again. In that case, in_reply_to is the automation’s reply, and the origin is still the automation, broadcast, or other send that started the conversation. An automation that a reply triggers doesn’t become the origin of its own messages, so selecting it in Replying to matches only conversations that it started itself.
How we attribute a reply to a message
If a person uses WhatsApp’s reply feature to answer a specific message, we attribute the reply to that message. Otherwise, we attribute it to the newest WhatsApp message you sent that person in the last 72 hours. If two automations send to the same person, a reply that doesn’t use WhatsApp’s reply feature goes to whichever message went out last.
Branch on the message body
Because we don’t automatically parse WhatsApp messages for keywords the same way we do for inbound SMS, you’ll need to look for the keywords you expect in the body of the inbound message yourself. You’ll often want to use a multi-split branch to look for specific text and trigger a follow-up message or action for each branch.
For example, you might ask people to reply YES or NO to confirm an appointment, then branch on the body of their reply. Add an “all others” branch to respond when a reply doesn’t match what you expect—for example, to tell people to try again or to ask them to reply with the correct option.
Match your own keywords
You can look for keywords in the body of an inbound message rather than trying to match the whole message. When you look for keywords—in a multi-split or other branch in your automation—you’ll use the same wildcard matching operators as segment conditions: *, |, and +.
- A
bodythat contains*cancel*matches any message with “cancel” in it, like “Please cancel my order.” - A
bodythat containsyes|yeah|yepmatches a reply with “yes,” “yeah,” or “yep” in it.
Matching ignores case and trims surrounding spaces, so *cancel* also matches Cancel and CANCEL. You don’t need to account for capitalization.
Filter by sender number or message
If you want to handle inbound messages differently based on who sent them or what they said, you can add a Filter to your automation trigger. In your filter, you’ll look for the from value to filter by sender number and the body value to filter by message content. To handle replies to a specific message you sent, use Replying to as described in Route replies to the right automation.
You cannot wait for subsequent messages in your automation
In your automation, you can’t wait for another inbound message or a follow-up event. You have to handle cascading inbound messages with subsequent automations.
You can still use the Wait Until action to wait for other conditions, but you can’t currently wait for a separate inbound message to continue through an automation.
When to limit send rates
If you send a WhatsApp broadcast or one-time send, and you want to respond to inbound messages on the same sender number, you should throttle your broadcast so that your inbound-based responses aren’t delayed.
Meta limits how many messages a sender number can send in a given period. Meta sets these limits for your business and can change them over time, so check Meta’s messaging limits to understand your current tier. If you send a large broadcast from a number that you expect your audience to reply to, the broadcast can use up that number’s send capacity. If an inbound message comes in while your phone number is busy, the replies you send from inbound messages take longer to go out, which makes your responses feel less timely to the people who messaged you.
Throttling broadcasts and one-time sends keeps capacity available on your sender number, so inbound-triggered replies can go out promptly.