Receive Inbound Messages with Flex Conversations Channels
Info
Flex Conversations requires Flex UI 2.0.x. If you are on Flex UI 1.x.x, refer to the Messaging in Flex pages.
Info
Flex Conversations doesn't support displaying the customer's WhatsApp Profile Name.
Warning
WhatsApp is introducing usernames, which let users message you without sharing a phone number. Flex continues to receive messages from users who have a WhatsApp username, but the identifier in MessagingBinding.Address and Author might be a Business-Scoped User ID (BSUID) instead of a phone number. For more information about how WhatsApp usernames affect Flex, see Flex and Conversations (classic).
With Flex, your customers can reach you via messaging channels such as SMS and WhatsApp. The Flex Messaging page in the Console lets you register Conversations addresses for your channels, so you can process inbound messages using Flex Conversations.
For details on event payloads, see the Conversations Webhooks page. From the event payload, retrieve the ConversationSid.
Create an interaction and pass the ConversationSid as the media_channel_sid:
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createInteraction() {11const interaction = await client.flexApi.v1.interaction.create({12channel: {13type: "sms",14initiated_by: "customer",15properties: {16media_channel_sid: "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",17},18},19routing: {20properties: {21workspace_sid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",22workflow_sid: "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",23task_channel_unique_name: "sms",24attributes: {25from: "+1311-555-2368",26},27},28},29});3031console.log(interaction.sid);32}3334createInteraction();
Response
1{2"sid": "KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"channel": {4"type": "sms",5"initiated_by": "customer",6"properties": {7"media_channel_sid": "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"8}9},10"routing": {11"properties": {12"workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",13"workflow_sid": "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",14"task_channel_unique_name": "sms",15"attributes": {16"from": "+1311-555-2368"17}18}19},20"interaction_context_sid": null,21"webhook_ttid": "flex_interactionwebhook_00000000000000000000000000",22"url": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",23"links": {24"channels": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels"25}26}
To configure and respond to Flex Conversations messaging tasks, see: