Skip to contentSkip to navigationSkip to topbar
Rate this page:
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 nameTypePIIDescription
account_sidSID<AC>
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>

The SID of the Flex Flow.

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

sidSID<CH>

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>

The SID of the chat user.

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

task_sidSID<WT>

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>

The absolute URL of the Flex chat channel resource.


date_updatedstring<date-time>

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.twilio.com/v1/Channels

Request body parameters

request-body-parameters page anchor
Property nameTypeRequiredPIIDescription
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.


TargetstringOptional

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


ChatUniqueNamestringOptional

The chat channel's unique name.


PreEngagementDatastringOptional

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

TaskAttributesstringOptional

The Task attributes to be added for the TaskRouter Task.


LongLivedbooleanOptional

Whether to create the channel as long-lived.

Create a Channel

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

_21
// Download the helper library from https://www.twilio.com/docs/node/install
_21
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_21
_21
// Find your Account SID and Auth Token at twilio.com/console
_21
// and set the environment variables. See http://twil.io/secure
_21
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_21
const authToken = process.env.TWILIO_AUTH_TOKEN;
_21
const client = twilio(accountSid, authToken);
_21
_21
async function createChannel() {
_21
const channel = await client.flexApi.v1.channel.create({
_21
chatFriendlyName: "ChatFriendlyName",
_21
chatUserFriendlyName: "ChatUserFriendlyName",
_21
flexFlowSid: "FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_21
identity: "Identity",
_21
});
_21
_21
console.log(channel.accountSid);
_21
}
_21
_21
createChannel();

Output

_10
{
_10
"flex_flow_sid": "FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10
"sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10
"task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10
"user_sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10
"date_created": "2016-08-01T22:10:40Z",
_10
"date_updated": "2016-08-01T22:10:40Z",
_10
"url": "https://flex-api.twilio.com/v1/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_10
}


Fetch a Channel resource

fetch-a-channel-resource page anchor
GET https://flex.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
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_18
// Download the helper library from https://www.twilio.com/docs/node/install
_18
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18
_18
// Find your Account SID and Auth Token at twilio.com/console
_18
// and set the environment variables. See http://twil.io/secure
_18
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18
const authToken = process.env.TWILIO_AUTH_TOKEN;
_18
const client = twilio(accountSid, authToken);
_18
_18
async function fetchChannel() {
_18
const channel = await client.flexApi.v1
_18
.channel("CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18
.fetch();
_18
_18
console.log(channel.accountSid);
_18
}
_18
_18
fetchChannel();

Output

_10
{
_10
"flex_flow_sid": "FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10
"sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10
"task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10
"user_sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_10
"date_created": "2016-08-01T22:10:40Z",
_10
"date_updated": "2016-08-01T22:10:40Z",
_10
"url": "https://flex-api.twilio.com/v1/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_10
}


Read multiple Channel resources

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

Property nameTypeRequiredPIIDescription
PageSizeintegerOptional

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

Minimum: 1Maximum: 1000

PageintegerOptional

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

Minimum: 0

PageTokenstringOptional

The page token. This is provided by the API.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_16
// Download the helper library from https://www.twilio.com/docs/node/install
_16
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_16
_16
// Find your Account SID and Auth Token at twilio.com/console
_16
// and set the environment variables. See http://twil.io/secure
_16
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_16
const authToken = process.env.TWILIO_AUTH_TOKEN;
_16
const client = twilio(accountSid, authToken);
_16
_16
async function listChannel() {
_16
const channels = await client.flexApi.v1.channel.list({ limit: 20 });
_16
_16
channels.forEach((c) => console.log(c.accountSid));
_16
}
_16
_16
listChannel();

Output

_23
{
_23
"meta": {
_23
"page": 0,
_23
"page_size": 50,
_23
"first_page_url": "https://flex-api.twilio.com/v1/Channels?PageSize=50&Page=0",
_23
"previous_page_url": null,
_23
"url": "https://flex-api.twilio.com/v1/Channels?PageSize=50&Page=0",
_23
"next_page_url": null,
_23
"key": "flex_chat_channels"
_23
},
_23
"flex_chat_channels": [
_23
{
_23
"flex_flow_sid": "FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_23
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_23
"sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_23
"task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_23
"user_sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_23
"date_created": "2016-08-01T22:10:40Z",
_23
"date_updated": "2016-08-01T22:10:40Z",
_23
"url": "https://flex-api.twilio.com/v1/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_23
}
_23
]
_23
}


Delete a Channel resource

delete-a-channel-resource page anchor
DELETE https://flex.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
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_16
// Download the helper library from https://www.twilio.com/docs/node/install
_16
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_16
_16
// Find your Account SID and Auth Token at twilio.com/console
_16
// and set the environment variables. See http://twil.io/secure
_16
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_16
const authToken = process.env.TWILIO_AUTH_TOKEN;
_16
const client = twilio(accountSid, authToken);
_16
_16
async function deleteChannel() {
_16
await client.flexApi.v1
_16
.channel("CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_16
.remove();
_16
}
_16
_16
deleteChannel();


Rate this page: