Skip to contentSkip to navigationSkip to topbar
On this page

Flex Chat Channel Resource


(information)

Info

This guide is for Flex UI 1.x.x and channels that use Programmable Chat and Proxy. If you are using Flex UI 2.x.x or you are starting out, we recommend that you build with Flex Conversations.

Flex Chat Channels allow agents to communicate with your customers across multiple channels like Webchat, SMS, and WhatsApp through a single chat interface. You can create a chat channel in Flex whenever you want to initiate a new communication flow between an agent and a customer. The Flex Chat Channel is an implementation of the Chat Channel Resource orchestrated for Flex.


Channel Properties

channel-properties page anchor
Property nameTypeRequiredDescriptionChild properties
account_sidSID<AC>

Optional

Not PII

The SID of the Account that created the Channel resource and owns this Workflow.

Pattern: ^AC[0-9a-fA-F]{32}$Min length: 34Max length: 34

flex_flow_sidSID<FO>

Optional

The SID of the Flex Flow.

Pattern: ^FO[0-9a-fA-F]{32}$Min length: 34Max length: 34

sidSID<CH>

Optional

The unique string that we created to identify the Channel resource.

Pattern: ^CH[0-9a-fA-F]{32}$Min length: 34Max length: 34

user_sidSID<US>

Optional

The SID of the chat user.

Pattern: ^US[0-9a-fA-F]{32}$Min length: 34Max length: 34

task_sidSID<WT>

Optional

The SID of the TaskRouter Task. Only valid when integration type is task. null for integration types studio & external

Pattern: ^WT[0-9a-fA-F]{32}$Min length: 34Max length: 34

urlstring<uri>

Optional

The absolute URL of the Flex chat channel resource.


date_updatedstring<date-time>

Optional

The date and time in GMT when the Flex chat channel was last updated specified in ISO 8601(link takes you to an external page) format.


Create a Channel resource

create-a-channel-resource page anchor
POST https://flex-api.twilio.com/v1/Channels

Request body parameters

request-body-parameters page anchor
Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
FlexFlowSidSID<FO>required

The SID of the Flex Flow.

Pattern: ^FO[0-9a-fA-F]{32}$Min length: 34Max length: 34

Identitystringrequired

The identity value that uniquely identifies the new resource's chat User.


ChatUserFriendlyNamestringrequired

The chat participant's friendly name.


ChatFriendlyNamestringrequired

The chat channel's friendly name.


Targetstring

Optional

The Target Contact Identity, for example the phone number of an SMS.


ChatUniqueNamestring

Optional

The chat channel's unique name.


PreEngagementDatastring

Optional

The pre-engagement data.


TaskSidSID<WT>

Optional

The SID of the TaskRouter Task. Only valid when integration type is task. null for integration types studio & external

Pattern: ^WT[0-9a-fA-F]{32}$Min length: 34Max length: 34

TaskAttributesstring

Optional

The Task attributes to be added for the TaskRouter Task.


LongLivedboolean

Optional

Whether to create the channel as long-lived.

Create a ChannelLink to code sample: Create a Channel
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 createChannel() {
11
const channel = await client.flexApi.v1.channel.create({
12
chatFriendlyName: "ChatFriendlyName",
13
chatUserFriendlyName: "ChatUserFriendlyName",
14
flexFlowSid: "FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
15
identity: "Identity",
16
});
17
18
console.log(channel.accountSid);
19
}
20
21
createChannel();

Output

1
{
2
"flex_flow_sid": "FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
5
"task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
6
"user_sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
7
"date_created": "2016-08-01T22:10:40Z",
8
"date_updated": "2016-08-01T22:10:40Z",
9
"url": "https://flex-api.twilio.com/v1/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
10
}

Fetch a Channel resource

fetch-a-channel-resource page anchor
GET https://flex-api.twilio.com/v1/Channels/{Sid}

Property nameTypeRequiredPIIDescription
SidSID<CH>required

The SID of the Flex chat channel resource to fetch.

Pattern: ^CH[0-9a-fA-F]{32}$Min length: 34Max length: 34
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 fetchChannel() {
11
const channel = await client.flexApi.v1
12
.channel("CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.fetch();
14
15
console.log(channel.accountSid);
16
}
17
18
fetchChannel();

Output

1
{
2
"flex_flow_sid": "FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
5
"task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
6
"user_sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
7
"date_created": "2016-08-01T22:10:40Z",
8
"date_updated": "2016-08-01T22:10:40Z",
9
"url": "https://flex-api.twilio.com/v1/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
10
}

Read multiple Channel resources

read-multiple-channel-resources page anchor
GET https://flex-api.twilio.com/v1/Channels

Property nameTypeRequiredPIIDescription
PageSizeinteger

Optional

How many resources to return in each list page. The default is 50, and the maximum is 1000.

Minimum: 1Maximum: 1000

Pageinteger

Optional

The page index. This value is simply for client state.

Minimum: 0

PageTokenstring

Optional

The page token. This is provided by the API.

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 listChannel() {
11
const channels = await client.flexApi.v1.channel.list({ limit: 20 });
12
13
channels.forEach((c) => console.log(c.accountSid));
14
}
15
16
listChannel();

Output

1
{
2
"meta": {
3
"page": 0,
4
"page_size": 50,
5
"first_page_url": "https://flex-api.twilio.com/v1/Channels?PageSize=50&Page=0",
6
"previous_page_url": null,
7
"url": "https://flex-api.twilio.com/v1/Channels?PageSize=50&Page=0",
8
"next_page_url": null,
9
"key": "flex_chat_channels"
10
},
11
"flex_chat_channels": [
12
{
13
"flex_flow_sid": "FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
15
"sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
16
"task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
17
"user_sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
18
"date_created": "2016-08-01T22:10:40Z",
19
"date_updated": "2016-08-01T22:10:40Z",
20
"url": "https://flex-api.twilio.com/v1/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
21
}
22
]
23
}

Delete a Channel resource

delete-a-channel-resource page anchor
DELETE https://flex-api.twilio.com/v1/Channels/{Sid}

Property nameTypeRequiredPIIDescription
SidSID<CH>required

The SID of the Flex chat channel resource to delete.

Pattern: ^CH[0-9a-fA-F]{32}$Min length: 34Max length: 34
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 deleteChannel() {
11
await client.flexApi.v1
12
.channel("CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.remove();
14
}
15
16
deleteChannel();

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.