Skip to contentSkip to navigationSkip to topbar
On this page

Flex Flow 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.

A Flex Flow is the logic linking a contact identity (e.g. SMS-enabled phone number or WhatsApp number) to Flex.

This page details the Flex Flow API Resource. Check out the additional documentation to learn more about working with Flex Flows.


FlexFlow Properties

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

Optional

Not PII

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

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

date_updatedstring<date-time>

Optional

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


sidSID<FO>

Optional

The unique string that we created to identify the Flex Flow resource.

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

friendly_namestring

Optional

PII MTL: 30 days

The string that you assigned to describe the resource.


chat_service_sidSID<IS>

Optional

The SID of the chat service.

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

channel_typeenum<string>

Optional

The channel type. One of web, facebook, sms, whatsapp, line or custom. By default, Studio’s Send to Flex widget passes it on to the Task attributes for Tasks created based on this Flex Flow. The Task attributes will be used by the Flex UI to render the respective Task as appropriate (applying channel-specific design and length limits). If channelType is facebook, whatsapp or line, the Send to Flex widget should set the Task Channel to Programmable Chat.

Possible values:
websmsfacebookwhatsapplinecustom

contact_identitystring

Optional

The channel contact's Identity.


enabledboolean

Optional

Whether the Flex Flow is enabled.


integration_typeenum<string>

Optional

The software that will handle inbound messages. Integration Type can be: studio, external, or task.

Possible values:
studioexternaltask

integrationobject

Optional

An object that contains specific parameters for the integration.


long_livedboolean

Optional

When enabled, Flex will keep the chat channel active so that it may be used for subsequent interactions with a contact identity. Defaults to false.


janitor_enabledboolean

Optional

When enabled, the Messaging Channel Janitor will remove active Proxy sessions if the associated Task is deleted outside of the Flex UI. Defaults to false.


urlstring<uri>

Optional

The absolute URL of the Flex Flow resource.


Create a FlexFlow resource

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

Request body parameters

request-body-parameters page anchor
Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
FriendlyNamestringrequired

A descriptive string that you create to describe the Flex Flow resource.


ChatServiceSidSID<IS>required

The SID of the chat service.

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

ChannelTypeenum<string>required

The channel type. One of web, facebook, sms, whatsapp, line or custom. By default, Studio’s Send to Flex widget passes it on to the Task attributes for Tasks created based on this Flex Flow. The Task attributes will be used by the Flex UI to render the respective Task as appropriate (applying channel-specific design and length limits). If channelType is facebook, whatsapp or line, the Send to Flex widget should set the Task Channel to Programmable Chat.

Possible values:
websmsfacebookwhatsapplinecustom

ContactIdentitystring

Optional

The channel contact's Identity.


Enabledboolean

Optional

Whether the new Flex Flow is enabled.


IntegrationTypeenum<string>

Optional

The software that will handle inbound messages. Integration Type can be: studio, external, or task.

Possible values:
studioexternaltask

Integration.FlowSidSID<FW>

Optional

The SID of the Studio Flow. Required when integrationType is studio.

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

Integration.Urlstring<uri>

Optional

The URL of the external webhook. Required when integrationType is external.


Integration.WorkspaceSidSID<WS>

Optional

The Workspace SID for a new Task. Required when integrationType is task.

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

Integration.WorkflowSidSID<WW>

Optional

The Workflow SID for a new Task. Required when integrationType is task.

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

Integration.Channelstring

Optional

The Task Channel SID (TCXXXX) or unique name (e.g., sms) to use for the Task that will be created. Applicable and required when integrationType is task. The default value is default.


Integration.Timeoutinteger

Optional

The Task timeout in seconds for a new Task. Default is 86,400 seconds (24 hours). Optional when integrationType is task, not applicable otherwise.


Integration.Priorityinteger

Optional

The Task priority of a new Task. The default priority is 0. Optional when integrationType is task, not applicable otherwise.


Integration.CreationOnMessageboolean

Optional

In the context of outbound messaging, defines whether to create a Task immediately (and therefore reserve the conversation to current agent), or delay Task creation until the customer sends the first response. Set to false to create immediately, true to delay Task creation. This setting is only applicable for outbound messaging.


LongLivedboolean

Optional

When enabled, Flex will keep the chat channel active so that it may be used for subsequent interactions with a contact identity. Defaults to false.


JanitorEnabledboolean

Optional

When enabled, the Messaging Channel Janitor will remove active Proxy sessions if the associated Task is deleted outside of the Flex UI. Defaults to false.


Integration.RetryCountinteger

Optional

The number of times to retry the Studio Flow or webhook in case of failure. Takes integer values from 0 to 3 with the default being 3. Optional when integrationType is studio or external, not applicable otherwise.

Create a Flex Flow with StudioLink to code sample: Create a Flex Flow with Studio
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 createFlexFlow() {
11
const flexFlow = await client.flexApi.v1.flexFlow.create({
12
channelType: "web",
13
chatServiceSid: "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
contactIdentity: "+14155551234",
15
enabled: true,
16
friendlyName: "My New Flex Flow",
17
"integration.flowSid": "FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
18
integrationType: "studio",
19
});
20
21
console.log(flexFlow.accountSid);
22
}
23
24
createFlexFlow();

Output

1
{
2
"sid": "FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"date_created": "2016-08-01T22:10:40Z",
5
"date_updated": "2016-08-01T22:10:40Z",
6
"friendly_name": "My New Flex Flow",
7
"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
8
"channel_type": "web",
9
"contact_identity": "+14155551234",
10
"enabled": true,
11
"integration_type": "studio",
12
"integration": {
13
"flow_sid": "FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
"retry_count": 1
15
},
16
"long_lived": true,
17
"janitor_enabled": true,
18
"url": "https://flex-api.twilio.com/v1/FlexFlows/FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
19
}
Create a Flex Flow with an External WebhookLink to code sample: Create a Flex Flow with an External Webhook
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 createFlexFlow() {
11
const flexFlow = await client.flexApi.v1.flexFlow.create({
12
channelType: "web",
13
chatServiceSid: "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
friendlyName: "FriendlyName",
15
"integration.url": "https://link-to-your-webhook.com/flex-message-endpoint",
16
});
17
18
console.log(flexFlow.accountSid);
19
}
20
21
createFlexFlow();

Output

1
{
2
"sid": "FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"date_created": "2016-08-01T22:10:40Z",
5
"date_updated": "2016-08-01T22:10:40Z",
6
"friendly_name": "FriendlyName",
7
"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
8
"channel_type": "web",
9
"contact_identity": "12345",
10
"enabled": true,
11
"integration_type": "studio",
12
"integration": {
13
"flow_sid": "FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
"retry_count": 1
15
},
16
"long_lived": true,
17
"janitor_enabled": true,
18
"url": "https://flex-api.twilio.com/v1/FlexFlows/FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
19
}
(information)

Info

The Studio Usage Guide is a helpful introduction to Studio Flows and the general idea of how Studio works. If you're looking for a way to power your Flex Flow with little or no code, an underlying Studio Flow might be the right way to go!

When you receive an inbound message, the Flex Flow will make a POST request containing the message body and some metadata to your chosen webhook.

1
{
2
"EventType": "onMessageSent",
3
"InstanceSid": "ISxxxxx",
4
"Attributes": "{\"proxied\":true}",
5
"DateCreated": "2019-06-01T01:01:01.000Z",
6
"Index": "1",
7
"From": "sms_xxxxxxxxxxxxx",
8
"MessageSid": "IMxxxxx",
9
"AccountSid": "ACxxxxx",
10
"Source": "API",
11
"ChannelSid": "CHxxxxx",
12
"RetryCount": "0",
13
"WebhookType": "webhook",
14
"Body": "message goes here",
15
"WebhookSid": "WHxxxxx"
16
}

Fetch a FlexFlow resource

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

Property nameTypeRequiredPIIDescription
SidSID<FO>required

The SID of the Flex Flow resource to fetch.

Pattern: ^FO[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 fetchFlexFlow() {
11
const flexFlow = await client.flexApi.v1
12
.flexFlow("FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.fetch();
14
15
console.log(flexFlow.accountSid);
16
}
17
18
fetchFlexFlow();

Output

1
{
2
"sid": "FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"date_created": "2016-08-01T22:10:40Z",
5
"date_updated": "2016-08-01T22:10:40Z",
6
"friendly_name": "friendly_name",
7
"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
8
"channel_type": "sms",
9
"contact_identity": "12345",
10
"enabled": true,
11
"integration_type": "studio",
12
"integration": {
13
"flow_sid": "FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
"retry_count": 1
15
},
16
"long_lived": true,
17
"janitor_enabled": true,
18
"url": "https://flex-api.twilio.com/v1/FlexFlows/FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
19
}

Read multiple FlexFlow resources

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

Property nameTypeRequiredPIIDescription
FriendlyNamestring

Optional

The friendly_name of the Flex Flow resources to read.


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

Output

1
{
2
"meta": {
3
"page": 0,
4
"page_size": 50,
5
"first_page_url": "https://flex-api.twilio.com/v1/FlexFlows?PageSize=50&Page=0",
6
"previous_page_url": null,
7
"url": "https://flex-api.twilio.com/v1/FlexFlows?PageSize=50&Page=0",
8
"next_page_url": null,
9
"key": "flex_flows"
10
},
11
"flex_flows": [
12
{
13
"sid": "FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
15
"date_created": "2016-08-01T22:10:40Z",
16
"date_updated": "2016-08-01T22:10:40Z",
17
"friendly_name": "friendly_name",
18
"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
19
"channel_type": "sms",
20
"contact_identity": "12345",
21
"enabled": true,
22
"integration_type": "studio",
23
"integration": {
24
"flow_sid": "FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
25
"retry_count": 1
26
},
27
"long_lived": true,
28
"janitor_enabled": true,
29
"url": "https://flex-api.twilio.com/v1/FlexFlows/FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
30
}
31
]
32
}

Update a FlexFlow resource

update-a-flexflow-resource page anchor
POST https://flex-api.twilio.com/v1/FlexFlows/{Sid}

Property nameTypeRequiredPIIDescription
SidSID<FO>required

The SID of the Flex Flow resource to update.

Pattern: ^FO[0-9a-fA-F]{32}$Min length: 34Max length: 34
Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
FriendlyNamestring

Optional

A descriptive string that you create to describe the Flex Flow resource.


ChatServiceSidSID<IS>

Optional

The SID of the chat service.

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

ChannelTypeenum<string>

Optional

The channel type. One of web, facebook, sms, whatsapp, line or custom. By default, Studio’s Send to Flex widget passes it on to the Task attributes for Tasks created based on this Flex Flow. The Task attributes will be used by the Flex UI to render the respective Task as appropriate (applying channel-specific design and length limits). If channelType is facebook, whatsapp or line, the Send to Flex widget should set the Task Channel to Programmable Chat.

Possible values:
websmsfacebookwhatsapplinecustom

ContactIdentitystring

Optional

The channel contact's Identity.


Enabledboolean

Optional

Whether the new Flex Flow is enabled.


IntegrationTypeenum<string>

Optional

The software that will handle inbound messages. Integration Type can be: studio, external, or task.

Possible values:
studioexternaltask

Integration.FlowSidSID<FW>

Optional

The SID of the Studio Flow. Required when integrationType is studio.

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

Integration.Urlstring<uri>

Optional

The URL of the external webhook. Required when integrationType is external.


Integration.WorkspaceSidSID<WS>

Optional

The Workspace SID for a new Task. Required when integrationType is task.

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

Integration.WorkflowSidSID<WW>

Optional

The Workflow SID for a new Task. Required when integrationType is task.

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

Integration.Channelstring

Optional

The Task Channel SID (TCXXXX) or unique name (e.g., sms) to use for the Task that will be created. Applicable and required when integrationType is task. The default value is default.


Integration.Timeoutinteger

Optional

The Task timeout in seconds for a new Task. Default is 86,400 seconds (24 hours). Optional when integrationType is task, not applicable otherwise.


Integration.Priorityinteger

Optional

The Task priority of a new Task. The default priority is 0. Optional when integrationType is task, not applicable otherwise.


Integration.CreationOnMessageboolean

Optional

In the context of outbound messaging, defines whether to create a Task immediately (and therefore reserve the conversation to current agent), or delay Task creation until the customer sends the first response. Set to false to create immediately, true to delay Task creation. This setting is only applicable for outbound messaging.


LongLivedboolean

Optional

When enabled, Flex will keep the chat channel active so that it may be used for subsequent interactions with a contact identity. Defaults to false.


JanitorEnabledboolean

Optional

When enabled, the Messaging Channel Janitor will remove active Proxy sessions if the associated Task is deleted outside of the Flex UI. Defaults to false.


Integration.RetryCountinteger

Optional

The number of times to retry the Studio Flow or webhook in case of failure. Takes integer values from 0 to 3 with the default being 3. Optional when integrationType is studio or external, not applicable otherwise.

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 updateFlexFlow() {
11
const flexFlow = await client.flexApi.v1
12
.flexFlow("FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.update({ longLived: false });
14
15
console.log(flexFlow.accountSid);
16
}
17
18
updateFlexFlow();

Output

1
{
2
"sid": "FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"date_created": "2016-08-01T22:10:40Z",
5
"date_updated": "2016-08-01T22:10:40Z",
6
"friendly_name": "friendly_name",
7
"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
8
"channel_type": "sms",
9
"contact_identity": "12345",
10
"enabled": true,
11
"integration_type": "studio",
12
"integration": {
13
"flow_sid": "FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
"retry_count": 1
15
},
16
"long_lived": false,
17
"janitor_enabled": true,
18
"url": "https://flex-api.twilio.com/v1/FlexFlows/FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
19
}

DELETE https://flex-api.twilio.com/v1/FlexFlows/{Sid}

Property nameTypeRequiredPIIDescription
SidSID<FO>required

The SID of the Flex Flow resource to delete.

Pattern: ^FO[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 deleteFlexFlow() {
11
await client.flexApi.v1
12
.flexFlow("FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.remove();
14
}
15
16
deleteFlexFlow();

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.