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

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>

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
PII MTL: 30 days

The string that you assigned to describe the resource.


chat_service_sidSID<IS>

The SID of the chat service.

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

channel_typeenum<string>

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

The channel contact's Identity.


enabledboolean

Whether the Flex Flow is enabled.


integration_typeenum<string>

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

Possible values:
studioexternaltask

integrationobject

An object that contains specific parameters for the integration.


long_livedboolean

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

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>

The absolute URL of the Flex Flow resource.


Create a FlexFlow resource

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

Request body parameters

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

ContactIdentitystringOptional

The channel contact's Identity.


EnabledbooleanOptional

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.ChannelstringOptional

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.TimeoutintegerOptional

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.PriorityintegerOptional

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


Integration.CreationOnMessagebooleanOptional

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.


LongLivedbooleanOptional

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.


JanitorEnabledbooleanOptional

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.RetryCountintegerOptional

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 Studio

create-a-flex-flow-with-studio page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_24
// Download the helper library from https://www.twilio.com/docs/node/install
_24
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_24
_24
// Find your Account SID and Auth Token at twilio.com/console
_24
// and set the environment variables. See http://twil.io/secure
_24
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_24
const authToken = process.env.TWILIO_AUTH_TOKEN;
_24
const client = twilio(accountSid, authToken);
_24
_24
async function createFlexFlow() {
_24
const flexFlow = await client.flexApi.v1.flexFlow.create({
_24
channelType: "web",
_24
chatServiceSid: "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_24
contactIdentity: "+14155551234",
_24
enabled: true,
_24
friendlyName: "My New Flex Flow",
_24
"integration.flowSid": "FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_24
integrationType: "studio",
_24
});
_24
_24
console.log(flexFlow.accountSid);
_24
}
_24
_24
createFlexFlow();

Output

_19
{
_19
"sid": "FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19
"date_created": "2016-08-01T22:10:40Z",
_19
"date_updated": "2016-08-01T22:10:40Z",
_19
"friendly_name": "My New Flex Flow",
_19
"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19
"channel_type": "web",
_19
"contact_identity": "+14155551234",
_19
"enabled": true,
_19
"integration_type": "studio",
_19
"integration": {
_19
"flow_sid": "FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19
"retry_count": 1
_19
},
_19
"long_lived": true,
_19
"janitor_enabled": true,
_19
"url": "https://flex-api.twilio.com/v1/FlexFlows/FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_19
}

Create a Flex Flow with an External Webhook

create-a-flex-flow-with-an-external-webhook 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 createFlexFlow() {
_21
const flexFlow = await client.flexApi.v1.flexFlow.create({
_21
channelType: "whatsapp",
_21
chatServiceSid: "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_21
friendlyName: "FriendlyName",
_21
"integration.url": "https://link-to-your-webhook.com/flex-message-endpoint",
_21
});
_21
_21
console.log(flexFlow.accountSid);
_21
}
_21
_21
createFlexFlow();

Output

_19
{
_19
"sid": "FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19
"date_created": "2016-08-01T22:10:40Z",
_19
"date_updated": "2016-08-01T22:10:40Z",
_19
"friendly_name": "FriendlyName",
_19
"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19
"channel_type": "whatsapp",
_19
"contact_identity": "12345",
_19
"enabled": true,
_19
"integration_type": "studio",
_19
"integration": {
_19
"flow_sid": "FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19
"retry_count": 1
_19
},
_19
"long_lived": true,
_19
"janitor_enabled": true,
_19
"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 simple way to power your Flex Flow, 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.

Flex Flow External Webhook

flex-flow-external-webhook page anchor
json

_16
{
_16
"EventType": "onMessageSent",
_16
"InstanceSid": "ISxxxxx",
_16
"Attributes": "{\"proxied\":true}",
_16
"DateCreated": "2019-06-01T01:01:01.000Z",
_16
"Index": "1",
_16
"From": "sms_xxxxxxxxxxxxx",
_16
"MessageSid": "IMxxxxx",
_16
"AccountSid": "ACxxxxx",
_16
"Source": "API",
_16
"ChannelSid": "CHxxxxx",
_16
"RetryCount": "0",
_16
"WebhookType": "webhook",
_16
"Body": "message goes here",
_16
"WebhookSid": "WHxxxxx"
_16
}


Fetch a FlexFlow resource

fetch-a-flexflow-resource page anchor
GET https://flex.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

Fetch a Flex Flow resource

fetch-a-flex-flow-resource page anchor
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 fetchFlexFlow() {
_18
const flexFlow = await client.flexApi.v1
_18
.flexFlow("FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18
.fetch();
_18
_18
console.log(flexFlow.accountSid);
_18
}
_18
_18
fetchFlexFlow();

Output

_19
{
_19
"sid": "FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19
"date_created": "2016-08-01T22:10:40Z",
_19
"date_updated": "2016-08-01T22:10:40Z",
_19
"friendly_name": "friendly_name",
_19
"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19
"channel_type": "sms",
_19
"contact_identity": "12345",
_19
"enabled": true,
_19
"integration_type": "studio",
_19
"integration": {
_19
"flow_sid": "FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19
"retry_count": 1
_19
},
_19
"long_lived": true,
_19
"janitor_enabled": true,
_19
"url": "https://flex-api.twilio.com/v1/FlexFlows/FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_19
}


Read multiple FlexFlow resources

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

Property nameTypeRequiredPIIDescription
FriendlyNamestringOptional

The friendly_name of the Flex Flow resources to read.


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.

Read multiple Flex Flow resources

read-multiple-flex-flow-resources page anchor
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 listFlexFlow() {
_16
const flexFlows = await client.flexApi.v1.flexFlow.list({ limit: 20 });
_16
_16
flexFlows.forEach((f) => console.log(f.accountSid));
_16
}
_16
_16
listFlexFlow();

Output

_32
{
_32
"meta": {
_32
"page": 0,
_32
"page_size": 50,
_32
"first_page_url": "https://flex-api.twilio.com/v1/FlexFlows?PageSize=50&Page=0",
_32
"previous_page_url": null,
_32
"url": "https://flex-api.twilio.com/v1/FlexFlows?PageSize=50&Page=0",
_32
"next_page_url": null,
_32
"key": "flex_flows"
_32
},
_32
"flex_flows": [
_32
{
_32
"sid": "FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_32
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_32
"date_created": "2016-08-01T22:10:40Z",
_32
"date_updated": "2016-08-01T22:10:40Z",
_32
"friendly_name": "friendly_name",
_32
"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_32
"channel_type": "sms",
_32
"contact_identity": "12345",
_32
"enabled": true,
_32
"integration_type": "studio",
_32
"integration": {
_32
"flow_sid": "FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_32
"retry_count": 1
_32
},
_32
"long_lived": true,
_32
"janitor_enabled": true,
_32
"url": "https://flex-api.twilio.com/v1/FlexFlows/FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_32
}
_32
]
_32
}


Update a FlexFlow resource

update-a-flexflow-resource page anchor
POST https://flex.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
Property nameTypeRequiredPIIDescription
FriendlyNamestringOptional

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

ContactIdentitystringOptional

The channel contact's Identity.


EnabledbooleanOptional

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.ChannelstringOptional

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.TimeoutintegerOptional

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.PriorityintegerOptional

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


Integration.CreationOnMessagebooleanOptional

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.


LongLivedbooleanOptional

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.


JanitorEnabledbooleanOptional

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.RetryCountintegerOptional

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.

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 updateFlexFlow() {
_18
const flexFlow = await client.flexApi.v1
_18
.flexFlow("FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18
.update({ longLived: false });
_18
_18
console.log(flexFlow.accountSid);
_18
}
_18
_18
updateFlexFlow();

Output

_19
{
_19
"sid": "FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19
"date_created": "2016-08-01T22:10:40Z",
_19
"date_updated": "2016-08-01T22:10:40Z",
_19
"friendly_name": "friendly_name",
_19
"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19
"channel_type": "sms",
_19
"contact_identity": "12345",
_19
"enabled": true,
_19
"integration_type": "studio",
_19
"integration": {
_19
"flow_sid": "FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_19
"retry_count": 1
_19
},
_19
"long_lived": false,
_19
"janitor_enabled": true,
_19
"url": "https://flex-api.twilio.com/v1/FlexFlows/FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_19
}


DELETE https://flex.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

Delete a Flex Flow resource

delete-a-flex-flow-resource page anchor
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 deleteFlexFlow() {
_16
await client.flexApi.v1
_16
.flexFlow("FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_16
.remove();
_16
}
_16
_16
deleteFlexFlow();


Rate this page: