Twilio Flex, Twilio’s cloud-based contact center platform, offers the ability to create a truly omnichannel customer service experience. In addition to voice-based tasks, messaging channels such as SMS, live web chat, and WhatsApp can be easily integrated into the same Twilio Flex environment.
Although email is not a native digital channel in Twilio Flex, our team of Twilio experts have created the Email Connector for Twilio Flex. This lightweight middleware solution uses Twilio and Amazon Web Services (AWS) resources to expose email as a channel in Flex.
What Email Providers Are Supported?
The Email Connector is flexible enough to be connected and integrated with most email providers that expose web APIs, such as Microsoft Outlook/Office 365, GSuite/Gmail and SendGrid.
In the example integration shown in our video demo, we connect to a specific Microsoft Outlook email account, such as one configured for sales or support inquiries. After setting up a mailbox, we register an application in Azure Active Directory and configure the application with the ability to read from and write to mailboxes.
The AWS resources of the Email Connector are responsible for managing the state between Twilio Flex and the Microsoft mailbox. Once the Azure AD application has been set up and configured, we create a subscription that provides events for new email messages using the Microsoft Graph REST API.
Inbound and Outbound Messaging Flows
Once the subscription has been created, new emails that come into the mailbox will now trigger the Email Connector inbound flow. The Email Connector acts as middleware, processing the incoming message and sending it to a Twilio Function. This is an interaction point where additional processing can occur, such as intent detection, natural language processing of the message contents, enrichment with data from internal sources such as CRM or order management systems and other operations.
In Twilio, we check for previous interactions related to the email conversation. If the incoming email is a first message in a conversation with the customer, a new Programmable Chat channel and task is created to be handled by an agent. A post-event webhook is attached to the onMessageSent event scoped to the new channel, so that another Twilio Function is triggered when the agent sends a response.
Once an agent accepts a task and responds to a message, the Twilio Function triggered by the webhook sets off an outbound flow. In the Microsoft Outlook use case shown below, the Email Connector uses the Microsoft Graph API to create and send a reply email to the customer. If desired, Twilio SendGrid could also be used here for message responses to take advantage of the many features of that platform.
You’ve Got Mail! The Flex Agent Experience
Once a task has been created for an incoming email, it will be routed to an agent based on the routing rules set up in Twilio TaskRouter. Typically routing decisions might be made based on which mailbox the customer used, the subject, contents of the message or previous interactions with the customer.
From the Flex agent perspective, emails are treated as a type of chat channel. In our solution, we have used the default Flex agent UI, but modified it slightly to create a one-to-one message experience for email messages. Due to the asynchronous nature of email communications, the task is immediately put into wrap–up mode once the agent responds to the customer’s email. This helps to remove some of the complexities that can come with long message chains and threading. Instead, we would recommend using a conversation history approach to provide overall context to the agent.
The Flex UI can also be customized to surface tooling that will make it easy and efficient for agents to respond to email enquiries. In our video demo of the Email Connector, the Flex UI has been customized to add an interface for suggested email responses.
The Perficient Email Connector for Twilio Flex provides easy middleware integration between Twilio Flex and your email provider of choice.
Depending on the use cases that you are looking to support, there are several possible options to enhance the email integration with customizations:
- Multi-mailbox support — if there is more than one email account that needs to be monitored, the Email Connector can be enhanced to connect multiple inboxes into Twilio Flex. We typically suggest no more than five, as the routing rules and management can get complex with large numbers of mailboxes.
- Automated replies — instead of routing to an agent in Flex, another option would be to configure automated replies to all incoming messages. Depending on the use case, a plugin could be used to surface the ability to set, update or modify automated replies directly from the Flex agent/supervisor UI. A similar approach can be used to eliminate messages that require no response, such as a simple “thanks” reply from a customer.
- Advanced routing — Twilio TaskRouter can be used to route incoming email tasks to the most suitable agent. Tasks can be routed based on an agent’s ability to handle email tasks, on the mailbox that the message originates from, or even on keywords in the message subject and body. Additional AI and natural language processing middleware can be integrated for enhanced routing capabilities. In addition, for follow up messages, it is also possible to add “last agent” routing logic to create a more consistent customer experience.
- Attachment support — The Email Connector can be enhanced to add the ability for attachments to be sent back and forth, allowing for a more multimedia-rich email experience.
Watch a video demo of the Email Connector below.