Skip to contentSkip to navigationSkip to topbar

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 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();

Output

1
{
2
"sid": "KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"channel": {
4
"type": "sms",
5
"sid": "UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
6
},
7
"routing": {
8
"reservation": null,
9
"properties": {
10
"date_updated": 1634845217,
11
"task_queue_entered_date": 1634845217,
12
"workflow_name": "Default Fifo Workflow",
13
"age_in_queue": 0,
14
"task_channel_unique_name": "default",
15
"assignment_status": "pending",
16
"queue_name": "Sample Queue",
17
"assignmentCounter": 0,
18
"priority": 0,
19
"sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
20
"workflow_sid": "WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
21
"routing_target": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
22
"reason": "",
23
"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\"}",
24
"task_channel_sid": "TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
25
"age": 0,
26
"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
27
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
28
"timeout": 86400,
29
"date_created": 1634845217,
30
"addons": "{}",
31
"queue_sid": "WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
32
}
33
},
34
"interaction_context_sid": null,
35
"url": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
36
"links": {
37
"channels": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels"
38
}
39
}

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

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.