Skip to contentSkip to navigationSkip to topbar
On this page

Invites Subresource


(information)

Info

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>/Invites
2

Use this endpoint to:

  • add an agent to an ongoing interaction,
  • to find an agent that should be added by evaluating a TaskRouter workflow, or
  • to send an interaction to a queue.

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

(warning)

Warning

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.


Interaction Channel Invite properties

interaction-channel-invite-properties page anchor
ParameterSub-fieldDescription
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.
Property nameTypeRequiredDescriptionChild properties
sidSID<KG>Optional
Not PII

The unique string created by Twilio to identify an Interaction Channel Invite resource.

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

interaction_sidSID<KD>Optional

The Interaction SID for this Channel.

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

channel_sidSID<UO>Optional

The Channel SID for this Invite.

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

routingobjectOptional

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.


urlstring<uri>Optional

Create an Interaction Channel Invite

create-an-interaction-channel-invite page anchor
POST https://flex-api.twilio.com/v1/Interactions/{InteractionSid}/Channels/{ChannelSid}/Invites

Path parameters

path-parameters page anchor
Property nameTypeRequiredPIIDescription
InteractionSidSID<KD>required

The Interaction SID for this Channel.

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

ChannelSidSID<UO>required

The Channel SID for this Invite.

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

The Interaction's routing logic.

Invite an AgentLink to code sample: Invite an Agent
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 createInteractionChannelInvite() {
11
const invite = await client.flexApi.v1
12
.interaction("KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
13
.channels("UOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
14
.invites.create({
15
routing: {
16
properties: {
17
workspace_sid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
18
workflow_sid: "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
19
},
20
},
21
});
22
23
console.log(invite.sid);
24
}
25
26
createInteractionChannelInvite();

Output

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
}

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.