Flex Conversations requires Flex UI 2.0.x. If you are on Flex UI 1.x.x, refer to the Messaging in Flex pages.
Should you build on Flex Conversations or Legacy Messaging Channels?
Flex Conversations is the next generation architecture for async channel capabilities. Because it is based on the single Twilio Conversations primitive, the developer experience is improved and the complexity of building async channel workflows is reduced. This is the platform on which we'll keep adding new functionality and channels in the future.
Furthermore, to help you decide, consider the following:
Will you require attachments for different channels?
Flex Conversations channels support attachments for SMS/MMS, WhatsApp, Chat, and Facebook Messenger (Public Beta). On the legacy channels, attachments are only available on Chat channels.
Does your use case require more than one customer in the same engagement?
Unlike legacy messaging, Flex Conversations allows you to have multiple customers during the same engagement.
Flex Conversations is based on the single Twilio Conversations primitive which reduces the complexity of building async channel workflows. You can configure addresses for your Flex Conversations channels — SMS, WhatsApp, etc. — which you can integrate with Studio or your own backend application.
In order to build your own messaging orchestration, continue to have the number or sender ID configured as a Conversations address. However, you must not use the Send To Flex widget or the Interactions API to route to Flex. You can use the TaskRouter API to create a customer task to route to Flex.
By default, agents are automatically added (upon acceptance) and removed from Conversations tasks (upon completion). To override this behavior, see WebChat Actions. Without the override, the Flex UI will attempt to add agents to your Conversations channels when they accept a task.
Flex will add new features and functionality to support future Conversations use cases. These features may not work with your custom messaging orchestration solution, or your team will need to do additional development to make the new features compatible with your custom solution.
If you don't configure Conversations addresses, remove the addresses. Don't use the Send to Flex Widget.
Additionally, you need to override the "wrapup" and "complete" actions for your custom channels.
Use known agent routing in your workflow to assign a task to a specific agent. You can also use the Interactions API to specify an agent-initiated interaction as well as add a specific agent to an existing interaction.
You can auto-accept the task using the Flex Actions Framework, like so:
1init(flex, manager) { //auto-accepts tasks2manager.workerClient.on('reservationCreated', reservation => { if3(reservation.task.attributes.autoAnswer === 'true') {4flex.Actions.invokeAction('AcceptTask', {sid: reservation.sid}); //select the task5flex.Actions.invokeAction('SelectTask', {sid: reservation.sid}); } }); }
Yes. However, you must tell Flex UI that this Task has Messaging/Chat capabilities. For example:
1const myOwnChatChannel = flex.DefaultTaskChannels.createChatTaskChannel(2"my-chat-channel", task => task.channelType === "custom" );3flex.TaskChannels.register(myOwnChatChannel);
Or, using Task Channel name:
1const myOwnChatChannel = flex.DefaultTaskChannels.createChatTaskChannel(2"my-chat-channel", task => task.taskChannelUniqueName === "custom1" );3flex.TaskChannels.register(myOwnChatChannel);
File attachments are enabled by default on your Flex account. If this is not the case, you will need to update your account service configuration with a new entry in the channel_configs
array.
1curl --location --request GET 'https://flex-api.twilio.com/v1/Configuration/' \2-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
1{2...,3"channel_configs": [4...,5{6address_type: "web",7cbm_attachments: {8enabled: false,9number_of_attachments: 1,10max_file_size: 16777216,11max_total_file_size: 67108864,12accepted_extensions: [...]13}14},15...,16]17}
For a list of address types and accepted file extensions, see Channel Attachment Limits. To disable file attachments for a channel, set "enabled" to false
for that specific channel_configs
entry. Make sure to specify your account_sid
in your POST
request.
1curl --location --request POST 'https://flex-api.twilio.com/v1/Configuration/' \2-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN \3--header 'Content-Type: application/json' \4--data-raw '{5"account_sid":"ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",6"channel_configs":[7{8"cbm_attachments":{9"max_file_size":16777216,10"max_total_file_size":67108864,11"accepted_extensions":[12"jpg",13"jpeg",14"png",15"amr",16"mp3",17"mp4",18"pdf",19"heic",20"txt",21"gif"22],23"enabled":false,24"number_of_attachments":125},26"address_type":"web"27},28...29]30}'
Note that the code sample has been clipped with ...
for brevity.
Let's assume you're testing an inbound SMS message flow that's being handled by Studio. Some questions you can consider are:
Did Twilio receive the incoming message?
Did your message trigger a Conversation to be created?
Any message to a Conversations address that is outside of a conversation should cause the auto-create functionality to create a new conversation, add the sender as a participant, and append the message to the newly-created conversation. To find if the sender has an active conversation, use the Conversation Participant resource to find the active conversation. If there is no active conversation for this participant, check that your Conversation address is configured correctly and that the Messaging and Conversations services are also configured correctly.
Does the Conversation have a webhook or Studio configured as the scoped webhook?
If you found an active conversation for the sender in the previous step, check if a Studio or Webhook integration is configured correctly by querying the Conversation Scoped Webhook resource. The configuration should have either a Studio target or webhook target as per the Conversation address. If not, this may be an "orphaned" conversation. If this happens, please consider filing a support ticket.
In the meantime, for orphaned conversations, you could manually send them to Flex by invoking the Interactions API.
Did the message hit your Studio Flow?
All Studio interactions are captured in a Flow's Execution Logs. Find "Messaging Flow" (the default flow created for Flex, or the Chat Flow if you're debugging a web chat interaction) and navigate to Studio logs to see the execution associated with the failed message.
You can inspect error messages in each step of the Studio flow. HTTP Requests and Function Widgets frequently return error codes that can terminate the entire execution.
Did Studio create an Interaction (and Task)?
You can inspect the Studio Flow logs to see the Interaction SID, the Interaction channel SID, and the Task SID.
You can inspect Tasks in the TaskRouter section of the Twilio Console. The Task should have a reference to the relevant Interaction and Conversation SID in its Attributes.
Was the agent able to accept the Reservation?
When an Agent accepts the Reservation related to this Task, the agent user will be added as a Participant to the conversation. The role linked with that Agent user is "agent".
Please do not modify the standard permissions of this role (sendMessage
, sendMediaMessage
, leaveConversation
, editConversationAttributes
, editOwnMessage
, editOwnMessageAttributes
, deleteOwnMessage
).
Any Messages sent by the Agent should be visible under the Phone Number/Messaging Logs. Optionally, you can filter messages by Outgoing Messages to find the agent's message.
Once the Agent has completed the Task, Flex will take care of the following:
If you're having trouble with Flex Conversations and need to use legacy channels for messaging, see Switch from Flex Conversations to Legacy Messaging for instructions.