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.
The SID of the Account that created the Flex Flow resource and owns this Workflow.
^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The date and time in GMT when the resource was created specified in ISO 8601 format.
The date and time in GMT when the resource was last updated specified in ISO 8601 format.
The unique string that we created to identify the Flex Flow resource.
^FO[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the chat service.
^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
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.
web
sms
facebook
whatsapp
line
custom
The software that will handle inbound messages. Integration Type can be: studio
, external
, or task
.
studio
external
task
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
.
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
.
The absolute URL of the Flex Flow resource.
POST https://flex-api.twilio.com/v1/FlexFlows
application/x-www-form-urlencoded
A descriptive string that you create to describe the Flex Flow resource.
The SID of the chat service.
^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
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.
web
sms
facebook
whatsapp
line
custom
The software that will handle inbound messages. Integration Type can be: studio
, external
, or task
.
studio
external
task
The SID of the Studio Flow. Required when integrationType
is studio
.
^FW[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The URL of the external webhook. Required when integrationType
is external
.
The Workspace SID for a new Task. Required when integrationType
is task
.
^WS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The Workflow SID for a new Task. Required when integrationType
is task
.
^WW[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
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
.
The Task timeout in seconds for a new Task. Default is 86,400 seconds (24 hours). Optional when integrationType
is task
, not applicable otherwise.
The Task priority of a new Task. The default priority is 0. Optional when integrationType
is task
, not applicable otherwise.
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.
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
.
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
.
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/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createFlexFlow() {11const flexFlow = await client.flexApi.v1.flexFlow.create({12channelType: "web",13chatServiceSid: "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14contactIdentity: "+14155551234",15enabled: true,16friendlyName: "My New Flex Flow",17"integration.flowSid": "FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",18integrationType: "studio",19});2021console.log(flexFlow.accountSid);22}2324createFlexFlow();
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": 115},16"long_lived": true,17"janitor_enabled": true,18"url": "https://flex-api.twilio.com/v1/FlexFlows/FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"19}
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createFlexFlow() {11const flexFlow = await client.flexApi.v1.flexFlow.create({12channelType: "web",13chatServiceSid: "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14friendlyName: "FriendlyName",15"integration.url": "https://link-to-your-webhook.com/flex-message-endpoint",16});1718console.log(flexFlow.accountSid);19}2021createFlexFlow();
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": 115},16"long_lived": true,17"janitor_enabled": true,18"url": "https://flex-api.twilio.com/v1/FlexFlows/FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"19}
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}
GET https://flex-api.twilio.com/v1/FlexFlows/{Sid}
The SID of the Flex Flow resource to fetch.
^FO[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function fetchFlexFlow() {11const flexFlow = await client.flexApi.v112.flexFlow("FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.fetch();1415console.log(flexFlow.accountSid);16}1718fetchFlexFlow();
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": 115},16"long_lived": true,17"janitor_enabled": true,18"url": "https://flex-api.twilio.com/v1/FlexFlows/FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"19}
GET https://flex-api.twilio.com/v1/FlexFlows
How many resources to return in each list page. The default is 50, and the maximum is 1000.
1
Maximum: 1000
The page token. This is provided by the API.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function listFlexFlow() {11const flexFlows = await client.flexApi.v1.flexFlow.list({ limit: 20 });1213flexFlows.forEach((f) => console.log(f.accountSid));14}1516listFlexFlow();
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": 126},27"long_lived": true,28"janitor_enabled": true,29"url": "https://flex-api.twilio.com/v1/FlexFlows/FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"30}31]32}
POST https://flex-api.twilio.com/v1/FlexFlows/{Sid}
The SID of the Flex Flow resource to update.
^FO[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
application/x-www-form-urlencoded
A descriptive string that you create to describe the Flex Flow resource.
The SID of the chat service.
^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
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.
web
sms
facebook
whatsapp
line
custom
The software that will handle inbound messages. Integration Type can be: studio
, external
, or task
.
studio
external
task
The SID of the Studio Flow. Required when integrationType
is studio
.
^FW[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The URL of the external webhook. Required when integrationType
is external
.
The Workspace SID for a new Task. Required when integrationType
is task
.
^WS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The Workflow SID for a new Task. Required when integrationType
is task
.
^WW[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
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
.
The Task timeout in seconds for a new Task. Default is 86,400 seconds (24 hours). Optional when integrationType
is task
, not applicable otherwise.
The Task priority of a new Task. The default priority is 0. Optional when integrationType
is task
, not applicable otherwise.
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.
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
.
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
.
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/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function updateFlexFlow() {11const flexFlow = await client.flexApi.v112.flexFlow("FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.update({ longLived: false });1415console.log(flexFlow.accountSid);16}1718updateFlexFlow();
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": 115},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}
The SID of the Flex Flow resource to delete.
^FO[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function deleteFlexFlow() {11await client.flexApi.v112.flexFlow("FOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.remove();14}1516deleteFlexFlow();