Skip to contentSkip to navigationSkip to topbar
Rate this page:

Receive Inbound Messages with Flex Conversations Channels


(information)

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.

(information)

Info

Flex Conversations currently does not support displaying the customer's WhatsApp Profile Name.

With Flex, your customers can reach you via messaging channels, such as SMS, WhatsApp. The Flex Messaging page(link takes you to an external page) in the Console allows you to register Conversations addresses for your channels, so you can process inbound messages using Flex Conversations.

Please refer to the Conversations Webhooks page for more information on event payloads. In the event payload, you can retrieve the ConversationSid.

Now you can create an interaction and pass the ConversationSid as the media_channel_sid:

Create an Interaction

create-an-interaction page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_34
// Download the helper library from https://www.twilio.com/docs/node/install
_34
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_34
_34
// Find your Account SID and Auth Token at twilio.com/console
_34
// and set the environment variables. See http://twil.io/secure
_34
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_34
const authToken = process.env.TWILIO_AUTH_TOKEN;
_34
const client = twilio(accountSid, authToken);
_34
_34
async function createInteraction() {
_34
const interaction = await client.flexApi.v1.interaction.create({
_34
channel: {
_34
type: "sms",
_34
initiated_by: "customer",
_34
properties: {
_34
media_channel_sid: "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_34
},
_34
},
_34
routing: {
_34
properties: {
_34
workspace_sid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_34
workflow_sid: "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_34
task_channel_unique_name: "sms",
_34
attributes: {
_34
from: "+1311-555-2368",
_34
},
_34
},
_34
},
_34
});
_34
_34
console.log(interaction.sid);
_34
}
_34
_34
createInteraction();

Output

_39
{
_39
"sid": "KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_39
"channel": {
_39
"type": "sms",
_39
"sid": "UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_39
},
_39
"routing": {
_39
"reservation": null,
_39
"properties": {
_39
"date_updated": 1634845217,
_39
"task_queue_entered_date": 1634845217,
_39
"workflow_name": "Default Fifo Workflow",
_39
"age_in_queue": 0,
_39
"task_channel_unique_name": "default",
_39
"assignment_status": "pending",
_39
"queue_name": "Sample Queue",
_39
"assignmentCounter": 0,
_39
"priority": 0,
_39
"sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_39
"workflow_sid": "WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_39
"routing_target": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_39
"reason": "",
_39
"attributes": "{\"customerAddress\":\"customer phone address\",\"flexChannelInviteSid\":\"KGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"conversationSid\":\"CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"channelType\":\"sms\",\"customers\":{\"phone\":\"customer phone address\",\"name\":\"customer name\"},\"conversations\":{\"initiated_by\":\"customer\",\"conversation_id\":\"KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"media\":[{\"type\":\"ChatTranscript\",\"sid\":\"CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}]},\"customerName\":\"customer name\",\"flexInteractionChannelSid\":\"UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"initiatedBy\":\"customer\",\"flexInteractionSid\":\"KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"direction\":\"inbound\"}",
_39
"task_channel_sid": "TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_39
"age": 0,
_39
"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_39
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_39
"timeout": 86400,
_39
"date_created": 1634845217,
_39
"addons": "{}",
_39
"queue_sid": "WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_39
}
_39
},
_39
"interaction_context_sid": null,
_39
"url": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_39
"links": {
_39
"channels": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels"
_39
}
_39
}

To configure and respond to Flex Conversations messaging tasks, see:


Rate this page: