You may have already built a custom chat experience with Programmable Chat or from scratch. You can integrate these chat experiences with Flex and hand off incoming Chat messages to your agents.
Custom chat integrations require a Flex Flow
First, initialize the Twilio Chat SDK using an access token that links a user with a unique identity - for example:
abc123. The Chat SDK is going to help you pass messages back and forth with Flex.
Make sure this identity uniquely identifies your end user and avoid using personally identifiable information like names.
Now you need to:
- Ensure you have a relevant Message Handler. You can add Studio to the communication flow, immediately create a task, or do something else entirely depending on how you've configured your Flex Flow.
- Create a Flex Chat Channel (or reuse one if this is a return customer and you're using Long Lived channels)
- Creating a Channel will also automatically create a Chat User and place it in the Channel.
This configuration could require a minimum of four API requests, but with Flex you can do everything with a single request to Flex Chat Channels API.
Now you can use the Twilio Chat SDK to manage communications on the Chat Channel you created with Flex:
- When a message comes in, you'll receive a
messageAddedevent and can render it in your custom UI.
- When you need to send a message, the SDK includes a
sendMessage()method that you can use to publish media over the Twilio Chat Channel.