Twilio Flex is an open contact center platform based on web technologies that enable integration with just about any CRM. So why not Microsoft Dynamics 365?
Lots of organizations use CRM applications to store customer information and up to the minute contextual information about a customer’s past engagement with the organization.To provide a better experience when engaging with their customers, organizations should use this information to increase the timeliness and relevance of their conversations.
In this tutorial you will learn how to use customer data within Dynamics 365 to provide a contextually relevant conversation during self service and escalations to agents using Dynamics 365 with Twilio Flex. We’ll cover the steps required to integrate Twilio Flex with Dynamics 365 by leveraging Microsoft Dynamics 365 Channel Integration Framework, as well as Twilio components including Studio and the Runtime environment.
We’ll also show you how to create a Twilio Flex Plugin to enable screen pop and click-to-call all from within Dynamics 365.
Tutorial Requirements
To follow this tutorial you’ll need the following items:
- A Twilio account – If you sign up and upgrade through this link, you'll get an additional $10 credit.
- A Twilio Flex Project – see this link for more info and to create a Flex project
- A Microsoft Dynamics 365 – find out more here
- A local Node JS environment set up
- The create-flex-plugin application
How the Twilio and Microsoft Dynamics integration works
Before we dive into the setup, let’s walk through how it works.
When a call is placed to your Twilio phone number, we’ll route this call to a Studio Flow. The Studio Flow will then execute a number of steps, starting with calling a Twilio Function that passes the Customers Phone number to Dynamics to lookup a record. Once this record has been received, we are able to use this information during the rest of the Flow – for example, we can greet the customer by name and inquire if they’re calling about a particular case. From here we can deliver the call (interaction) to a Twilio Flex agent within Dynamics.
We included an example screenshot below to give you an idea of the integrated solution:
Dynamics Setup
Install the Channel Integration Framework
Before you can complete this step, you’ll need to ensure you have a fully functional Dynamics 365 environment. The first step is to install the Channel Integration Framework (CIF). See this guide for instructions to complete this step.
Once you have the CIF installed we need to configure it for Twilio Flex. See the screenshot below as an example:
Important fields to note are the following:
- Channel URL:
https://flex.twilio.com/agent-desktop
- Trusted Domain:
https://flex.twilio.com/
- Select Unified Interface Apps for the Channel: Assign the required Dynamic Apps where you’d like to make the CIF available. We have used the Customer Service Hub in this example.
Once the CIF is installed and configured, go to your Dynamics App that you assigned in the step above and you should see something similar to the screenshot below. Note the Flex UI on the right hand side of the screen.
Don’t worry if it doesn’t look exactly like this just yet, we’ll walk you through the Flex Plugin to customise the view and other details in the Twilio Flex section below.
(Optional) Register an Application with Microsoft Identity Platform to enable retrieval of Contact and Case records
In the next section, we’ll go through integrating Twilio with Dynamics to retrieve a customer's Contact Record and Case Number if applicable.
Before we can do that, we need to first register our application with Microsoft’s identity platform. This step will enable us to leverage the Microsoft Dynamics Web API to retrieve this information. This Microsoft article titled Register an application with the Microsoft identity platform describes the process to register an application with Microsoft’s identity Platform.
Once the application is registered, you’ll need to expose an Application ID and create a Client Secret. Follow this Microsoft article titled Configure a Client Application to access Web API’s for full details.
Take note of your Application (client) ID, Directory (tenant) ID and Client Secret as we’ll be using these in the next section:
The Screenshot below shows an example of this:
Twilio Functions and Studio
Create Your Twilio Functions
We’re going to need to create a few Functions that we’ll use later in our Studio Flow.
We’re going to create new Functions from the Blank Template as shown below:
Also, note that all of this code is available in the repo here.
Get_Dynamics_Token
The first Function we’ll create leverages the Application and API permissions we created in the “Registering an Application” step above. This Function is used to get an Access Token that we can then use with our requests to the Microsoft Dynamics Web API to retrieve the required records.
We’ve called this Function Get_Dynamics_Token and defined the path as https://<YourRuntimeDomain>.twil.io/getDynamicsToken
. (You’ll use this in your Studio Flow in the following sections.)
Copy the code below into your Function and replace the required fields with your specific Dynamics details. You’ll need to substitute your Application (client) ID in APPLICATION_(CLIENT)_ID
, Directory (tenant) ID in <DIRECTORY_(TENANT)_ID>
, and Dynamics Organization name in <YOUR_ORG>
.