Flex Conversations requires Flex UI 2.0.x. If you are on Flex UI 1.x.x, refer to the Messaging in Flex pages.
The Interaction Channel Invite subresource allows you to add an agent as a new participant to an existing interaction channel.
1/Interactions/<interaction_sid>/Channels/<channel_sid>/Invites2
Use this endpoint to:
The invite creates a new task for the existing interaction which will result in reservations offered to the agent(s). Note the example JSON response on this page is not representative of the actual API response. See example response on "Park an Interaction".
Remember to handle certain terminal TaskRouter events according to your application's needs, as conversations may stay orphaned with an open
state.
See Conversations Best Practices for details.
Parameter | Sub-field | Description |
---|---|---|
Routing [required] | A JSON Object representing the routing rules for the Interaction Channel. See Outbound SMS Example for an example Routing object. The Interactions resource uses TaskRouter for all routing functionality. | |
properties [required] | Fields needed to create a task: workspace_sid [required] The TaskRouter Workspace SID which starts with WS. workflow_sid [optional] The Workflow SID prefixed by WW. Optional if there's only one workflow defined otherwise it's mandatory queue_sid [required for agent-initiated], the Task router Queue SID prefixed by WQ. worker_sid [required for agent-initiated] task_channel_sid [optional] task_channel_unique_name [optional] attributes [optional] : The task attributes. priority [optional]: The priority of the task in the queue. timeout [optional]: The task/reservation timeout interval in seconds. All attributes in the Routing object on your Interaction request body are added "as is" to the task. For a list of known attributes consumed by the Flex UI and/or Flex Insights, see Known Task Attributes. |
The unique string created by Twilio to identify an Interaction Channel Invite resource.
^KG[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The Interaction SID for this Channel.
^KD[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The Channel SID for this Invite.
^UO[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
A JSON object representing the routing rules for the Interaction Channel. See Outbound SMS Example for an example Routing object. The Interactions resource uses TaskRouter for all routing functionality. All attributes in the Routing object on your Interaction request body are added “as is” to the task. For a list of known attributes consumed by the Flex UI and/or Flex Insights, see Known Task Attributes.
POST https://flex-api.twilio.com/v1/Interactions/{InteractionSid}/Channels/{ChannelSid}/Invites
application/x-www-form-urlencoded
The Interaction's routing logic.
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 createInteractionChannelInvite() {11const invite = await client.flexApi.v112.interaction("KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")13.channels("UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")14.invites.create({15routing: {16properties: {17workspace_sid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",18workflow_sid: "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",19},20},21});2223console.log(invite.sid);24}2526createInteractionChannelInvite();
1{2"sid": "KGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"channel_sid": "UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",4"interaction_sid": "KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",5"routing": {6"reservation": null,7"properties": {8"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",9"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",10"sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",11"date_created": 1634845217,12"date_updated": 1634845217,13"attributes": "{\"customerAddress\":\"customer phone address\",\"flexChannelInviteSid\":\"KGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"conversationSid\":\"CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"channelType\":\"sms\",\"customers\":{\"phone\":\"customer phone address\",\"name\":\"customer name\"},\"conversations\":{\"conversation_id\":\"KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"media\":[{\"type\":\"ChatTranscript\",\"sid\":\"CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}]},\"customerName\":\"customer name\",\"flexInteractionChannelSid\":\"UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"flexInteractionSid\":\"KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}",14"assignment_status": "pending",15"workflow_sid": "WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",16"workflow_name": "Default Fifo Workflow",17"queue_sid": "WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",18"queue_name": "Sample Queue",19"priority": 0,20"age": 0,21"reason": "",22"timeout": 86400,23"assignmentCounter": 0,24"task_channel_sid": "TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",25"task_channel_unique_name": "default",26"routing_target": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",27"task_queue_entered_date": 1634845217,28"age_in_queue": 0,29"addons": "{}"30}31},32"url": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites/KGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"33}