Some practical examples include a "click-to-sms" or "click-to-email" functionality in your CRM integration.
Encoding type:application/x-www-form-urlencoded
Property nameTypeRequiredDescriptionChild properties
The Interaction's channel.
The Interaction's routing logic.
InteractionContextSidSID<HQ>Optional The Interaction context sid is used for adding a context lookup sid
Pattern: ^HQ[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
{
"Channel": "{\"type\":\"sms\",\"initiated_by\":\"customer\"}",
"Routing": "{}",
"InteractionContextSid": "interaction_context_sid"
}
On your outbound request, you must set the initiated_by
property to "agent". Also, there are specific field requirements depending on your channel type. See Interactions resource request parameters for the different properties you can set.
_44// Download the helper library from https://www.twilio.com/docs/node/install
_44const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_44// Find your Account SID and Auth Token at twilio.com/console
_44// and set the environment variables. See http://twil.io/secure
_44const accountSid = process.env.TWILIO_ACCOUNT_SID;
_44const authToken = process.env.TWILIO_AUTH_TOKEN;
_44const client = twilio(accountSid, authToken);
_44async function createInteraction() {
_44 const interaction = await client.flexApi.v1.interaction.create({
_44 initiated_by: "agent",
_44 address: "+13115552368",
_44 proxy_address: "+192555512345",
_44 workspace_sid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_44 workflow_sid: "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_44 queue_sid: "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_44 worker_sid: "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_44 task_channel_unique_name: "sms",
_44 customerName: "silly name",
_44 customerAddress: "+1311-555-2368",
_44 console.log(interaction.sid);
_39 "sid": "KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_39 "sid": "UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_39 "date_updated": 1634845217,
_39 "task_queue_entered_date": 1634845217,
_39 "workflow_name": "Default Fifo Workflow",
_39 "task_channel_unique_name": "default",
_39 "assignment_status": "pending",
_39 "queue_name": "Sample Queue",
_39 "assignmentCounter": 0,
_39 "sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_39 "workflow_sid": "WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_39 "routing_target": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_39 "attributes": "{\"customerAddress\":\"customer phone address\",\"flexChannelInviteSid\":\"KGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"conversationSid\":\"CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"channelType\":\"sms\",\"customers\":{\"phone\":\"customer phone address\",\"name\":\"customer name\"},\"conversations\":{\"initiated_by\":\"customer\",\"conversation_id\":\"KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"media\":[{\"type\":\"ChatTranscript\",\"sid\":\"CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}]},\"customerName\":\"customer name\",\"flexInteractionChannelSid\":\"UOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"initiatedBy\":\"customer\",\"flexInteractionSid\":\"KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"direction\":\"inbound\"}",
_39 "task_channel_sid": "TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_39 "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_39 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_39 "date_created": 1634845217,
_39 "queue_sid": "WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_39 "interaction_context_sid": null,
_39 "url": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_39 "channels": "https://flex-api.twilio.com/v1/Interactions/KDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels"