Send Outbound Messages with Flex Conversations Channels
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.
Info
Flex Conversations currently does not support displaying the customer's WhatsApp Profile Name.
You can use the /Interactions
endpoint to implement additional opportunities for agents to send an outbound SMS, WhatsApp, Chat, Email, Facebook message (Public Beta), and Google Business message (Public Beta).
Some practical examples include a "click-to-sms" or "click-to-email" functionality in your CRM integration.
Request body parameters
Channel
type: objectRequired
The Interaction's channel.
Routing
type: objectRequired
The Interaction's routing logic.
InteractionContextSid
type: SID<HQ>
The Interaction context sid is used for adding a context lookup sid
Pattern:
^HQ[0-9a-fA-F]{32}$
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.
_35// Download the helper library from https://www.twilio.com/docs/node/install
_35// Find your Account SID and Auth Token at twilio.com/console
_35// and set the environment variables. See http://twil.io/secure
_35const accountSid = process.env.TWILIO_ACCOUNT_SID;
_35const authToken = process.env.TWILIO_AUTH_TOKEN;
_35const client = require('twilio')(accountSid, authToken);
_35client.flexApi.v1.interaction
_35 workspace_sid: 'WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
_35 workflow_sid: 'WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
_35 queue_sid: 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
_35 worker_sid: 'WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
_35 task_channel_unique_name: 'sms',
_35 customerName: 'silly name',
_35 customerAddress: '+1311-555-2368'
_35 initiated_by: 'agent',
_35 address: '+13115552368',
_35 proxy_address: '+192555512345',
_35 .then(interaction => console.log(interaction.sid));
_35 "sid": "KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_35 "initiated_by": "agent",
_35 "address": "+13115552368",
_35 "proxy_address": "+192555512345",
_35 "workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_35 "workflow_sid": "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_35 "queue_sid": "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_35 "worker_sid": "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_35 "task_channel_unique_name": "sms",
_35 "customerName": "silly name",
_35 "customerAddress": "+1311-555-2368"
_35 "interaction_context_sid": null,
_35 "url": "https://flex-api.twilio.com/v1/Interactions/KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_35 "channels": "https://flex-api.twilio.com/v1/Interactions/KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels"
Please note, creating outbound WhatsApp interactions is very similar to outbound SMS. However, you will need to create outbound templates in order for an agent to initiate contact.
_34// Download the helper library from https://www.twilio.com/docs/node/install
_34// Find your Account SID and Auth Token at twilio.com/console
_34// and set the environment variables. See http://twil.io/secure
_34const accountSid = process.env.TWILIO_ACCOUNT_SID;
_34const authToken = process.env.TWILIO_AUTH_TOKEN;
_34const client = require('twilio')(accountSid, authToken);
_34client.flexApi.v1.interaction
_34 workspace_sid: 'WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
_34 workflow_sid: 'WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
_34 queue_sid: 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
_34 worker_sid: 'WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
_34 customerName: 'Test Customer',
_34 customerAddress: 'whatsapp:+1311-555-2368'
_34 initiated_by: 'agent',
_34 address: 'whatsapp:+1311-555-2368',
_34 proxy_address: 'whatsapp:+19251235555',
_34 .then(interaction => console.log(interaction.sid));
_34 "sid": "KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_34 "initiated_by": "agent",
_34 "address": "whatsapp:+1311-555-2368",
_34 "proxy_address": "whatsapp:+19251235555",
_34 "workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_34 "workflow_sid": "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_34 "queue_sid": "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_34 "worker_sid": "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_34 "customerName": "Test Customer",
_34 "customerAddress": "whatsapp:+1311-555-2368"
_34 "interaction_context_sid": null,
_34 "url": "https://flex-api.twilio.com/v1/Interactions/KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_34 "channels": "https://flex-api.twilio.com/v1/Interactions/KDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels"
Once your interaction is created, grab the conversation SID (prefixed by CH) and pass it as a parameter when you create a conversation message.
_10curl -X POST https://conversations.twilio.com/v1/Conversations/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages \
_10--data-urlencode "Author=agentname" \
_10--data-urlencode "Body=Hello world" \
_10-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN