# Respond to inbound keywords

When people send you SMS messages, you can use campaigns to handle the incoming messages and trigger responses.

## How it works[](#how-it-works)

We treat inbound messages like events in Customer.io: they can trigger [campaignsCampaigns are automated workflows you set up to send people messages and perform other actions when they meet your criteria.](/journeys/campaigns-in-customerio/) and add people to [segmentsA segment is a group of people in your workspace. Use segments to trigger campaigns, track membership over time, or fine-tune your audience. There are two types of segments: data-driven and manual. Data-driven segments automatically update when people start or stop matching criteria. Manual segments are static.](/journeys/segments/).

We handle inbound messages by looking for keywords. Think of it a bit like the menu you hear when you call somewhere that has an automated phone system: the phone system prompts the user to press an option on the keypad to advance to the next message.

Except in this case, rather than pressing the right button to advance in a menu, the user responds with a keyword from a list of supported keywords, and you send them down a path based on the keyword they used.

## Set up an inbound message campaign[](#set-up-an-inbound-message-campaign)

1.  When you set up a campaign, click the **Trigger**.
2.  Select the **Event** trigger option.
3.  Change *they perform the event* to **they send an inbound SMS**.

[![Inbound SMS campaign trigger](https://docs.customer.io/images/inbound-sms-trigger-1.png)](#9d3bd218008be604c0c636d63acb4906-lightbox)

The *Inbound message event* that triggers your campaign doesn’t differentiate between replies to different phone numbers. If you want to handle inbound replies to your different sender numbers independently, you should add conditions to your trigger based on the `to` value. (Inbound messages come `from` your audience and `to` your SMS “sender” number.)

[![Inbound SMS campaign trigger with a filter for a sender number](https://docs.customer.io/images/inbound-sms-trigger.png)](#505cc7ba9faddfc8379c18819056bacd-lightbox)

### Using inbound message data[](#using-inbound-message-data)

Like other event-triggered campaigns, inbound message variables start with `event`. For example, referencing the `keyword` variable would be `{{event.keyword}}`.

Most of these values come directly from the inbound message, but there are rules to the `keyword` variable.

```json
{
    "body": "start",
    "from": "+15551234567",
    "keyword": "START",
    "messaging_service_sid": "MG1c4d997a947f60dfaddf382a32dffc11",
    "sid": "SMec32f5db600322613b0c592d4d7417f1",
    "to": "+15559876543"
}
```

Variable

Description

`body`

The body of the inbound message

`from`

The phone number of the person who sent the inbound message

`keyword`

The keyword that the person used, if we can parse it from the body of the inbound message

`messaging_service_sid`

The Twilio messaging service SID that the inbound message came from

`sid`

Twilio’s unique ID for the inbound message

`to`

The phone number that the inbound message was sent to, also the “sender” of the message the person replied to

### Keywords[](#keywords)

We support the pre-defined keywords below. A person can respond with any of the supported terms—lowercase, uppercase, or any combination of cases—and we’ll match on the appropriate keyword. This simplifies the logic when you respond to inbound messages. You don’t have to account for each possible variation of our pre-defined keywords.

Keyword

Supported terms

Description

STOP

STOP, CANCEL, UNSUBSCRIBE, OPTOUT, END, QUIT, REVOKE, STOPALL

Opt-out keywords that unsubscribe the user from SMS messages

START

START, UNSTOP

Opt-in keywords that resubscribe the user to SMS messages

HELP

HELP, INFO

Keywords that trigger help or information responses

YES

YES, Y, OK, 👍

Affirmative response keywords

NO

NO, N, 👎

Negative response keywords

Beyond our pre-defined terms, you can also tell people to respond with custom keywords. For example, if you want to run a survey, you could ask people to respond 1-5 to indicate satisfaction.

If an inbound message contains multiple words, the `keyword` variable will be empty. If this happens, you can respond with a message that tells the user to try again with one of the supported keywords.

## Example campaign and best practices[](#example-campaign-and-best-practices)

In the campaign below, you’ll see that we’ve done a few things:

1.  We’ve set up a **Multi-split branch** to handle different keywords—STOP, START, and HELP. We’ve also added another branch to handle cases where we don’t recognize the incoming keyword.
2.  For the STOP keyword, [we can’t send a follow-up message](/journeys/inbound-sms/#twilio-stop). Instead, we set an attribute on the person to help us track that they’ve opted-out of SMS messaging for that number. This lets us add people to a segment that we can include or exclude from different campaigns.

[![An example workflow for an inbound message with three keyword branches](https://docs.customer.io/images/inbound-sms-workflow.png)](#289456f80a0f408806627ce1bae0403c-lightbox)

### Filter by sender number or outbound message[](#filter-by-sender-number-or-outbound-message)

If you want to handle keywords differently based on the sender number or a specific message, you can add that as a *Filter* to your campaign trigger.

[![Inbound SMS campaign trigger with a filter for a sender number](https://docs.customer.io/images/inbound-sms-trigger.png)](#505cc7ba9faddfc8379c18819056bacd-lightbox)

### Set up branches to handle different keywords[](#set-up-branches-to-handle-different-keywords)

As you can see below, we’re handling branches for STOP, START, and HELP. We’ve also added a branch to handle cases where we don’t recognize the incoming keyword.

We automatically treat all opt-out [keywords](#keywords) as STOP and all opt-in [keywords](#keywords) as START; this means you don’t have to create conditions for every possible matching keyword.

[![An example multi-split branch for an inbound message with three keyword branches](https://docs.customer.io/images/inbound-sms-branch.png)](#0a82df6ad395d0b12d6a6de1fff910fb-lightbox)

### You cannot wait for subsequent messages in your campaign[](#no-wait-until)

In your campaign, you can’t wait for another inbound message or a follow-up event. You have to handle cascading inbound messages with subsequent campaigns.

You can still use the *Wait Until* action to wait for other conditions, but you cannot currently wait for a separate inbound message to continue through a campaign.

## When to limit send rates[](#when-to-limit-send-rates)

If you want to send an SMS broadcast or newsletter, and you want to respond to inbound messages on the same “sender” number in Customer.io, you should throttle your broadcast so that your inbound-based responses aren’t delayed by messages queued from your broadcast.

Imagine you send a broadcast to 100,000 people. SMS messages from a single phone number send at a maximum rate of 225 messages per second. This would take around 444 seconds to send, or around 7 minutes. If someone receives your message and responds immediately, and any subsequent message you try to send is added to the end of the queue. This means that any subsequent messages you send to your audience are be delayed by the time it takes to finish sending your broadcast.

Throttling broadcasts and newsletters ensures that your sender phone number can continue to send messages as it normally would, without being blocked by messages queued from your broadcast.

 You can’t limit campaign send rates this way

When you start campaigns triggered by segments or attribute changes, you can let people who already meet your conditions enter the campaign immediately. If you choose this option, you can’t limit the send rate from, or the number of people who enter, your campaign. This could cause a queue of SMS messages that delays other campaigns or broadcasts that rely on the same sender numbers.