Skip to contentSkip to navigationSkip to topbar
Page tools
Looking for more inspiration?Visit the

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 doesn't support displaying the customer's WhatsApp Profile Name.

(warning)

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(link takes you to an external 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:

Create an InteractionLink to code sample: Create an Interaction
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function createInteraction() {
11
const interaction = await client.flexApi.v1.interaction.create({
12
channel: {
13
type: "sms",
14
initiated_by: "customer",
15
properties: {
16
media_channel_sid: "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
17
},
18
},
19
routing: {
20
properties: {
21
workspace_sid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
22
workflow_sid: "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
23
task_channel_unique_name: "sms",
24
attributes: {
25
from: "+1311-555-2368",
26
},
27
},
28
},
29
});
30
31
console.log(interaction.sid);
32
}
33
34
createInteraction();

Response

Note about this 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: