Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

Send Outbound Messages via SMS, WhatsApp and Other Channels

Flex allows your agents to initiate conversations with your customers via any Twilio Messaging Channel, including SMS, WhatsApp, Facebook Messenger and LINE.

Currently, outbound messages require additional development work. This page outlines some of the work you'll need to do for the backend but outbound messages will also require a Flex UI Plugin to expose the functionality in the Flex interface.

Managing Task Creation

There are two ways to handle task creation for outbound messages: when the agent messages the customer (immediately) or when the customer responds to the outbound message (delayed).

Outbound messages require a Flex Flow ChannelType of sms, whatsapp, facebook, line or custom.

Create Task When Agent Messages Customer

1. Define a Flex Flow

First, define an outbound Flex Flow with an Integration type of task. You only need to do this once. Please ensure you are also defining your Flex Flow to use a Messaging capable Task Channel such as sms or chat. If you already have a Flex Flow that's using Studio, then enabled parameter must be set to false.


        2. Create a Flex Chat Channel

        Next, create a Flex Chat Channel to initate messaging with the customer. In this example, Task Attributes have been added, which will allow the channel to route the task to a specific agent (using the targetWorker Workflow expression).


              3. Set up a Twilio Proxy Session

              Now that you have a channel, you'll want to associate it with a Proxy Session. Sessions offer a useful layer of state and metadata that Flex uses to ensure that your customers' messages stay properly threaded as they are processed by bots, Task Router and agents.


                    3. Start chatting

                    Your agent can directly message into the Chat interface, and messages are routed to the customer on their Twilio Channel.

                    Create Task When Customer Responds

                    1. Configure inbound messages

                    Make sure you set up an inbound message handler, and that it's configured to create a Task. This will handle the customer's response to the outbound message. Please ensure you are also defining your Flex Flow to use a Messaging capable Task Channel such as sms or chat.

                    2. Create a Channel

                    Create a channel that uses the Flex Flow for outbound messages.


                          3. Send the message

                          Now we need to manually send our outbound message with the Messaging API.


                                4. Update the Chat Channel with the REST API

                                You can add a Chat message to the Agent's Chat Channel to keep them informed about any automated outbound messages. Any message that is only in the chat channel will not be visible to your customer until you create an outbound request with the messaging API.

                                Note that the Chat Channel SID comes from the channel you created in the first step of creating an outbound message, and begins with CH.

                                      Rate this page:

                                      Need some help?

                                      We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.