Dynamics 365 SMS Integration Using Microsoft Flow and Twilio
In the last few years, Microsoft Dynamics, Microsoft Office 365, and Azure have all evolved into the business technology market’s trend-setting business productivity systems. With this evolution, we received many exciting features to delight customers with – one such feature is Microsoft Flow.
Microsoft Flow is certainly the new buzzword in the Microsoft Dynamics industry. The integration between Dynamics 365 and Microsoft Flow means we can develop many cool new functionalities, including SMS Integration, approval processes, SharePoint integration, and social media platform integrations. In this blog post, I am very excited to share my experience specifically around SMS integration with Microsoft Flow and Twilio.
First things first, let’s have a quick look at Microsoft Flow and Twilio.
Microsoft Flow and Twilio
- Microsoft Flow is an Office 356 service used to create, update and manage automated workflows via UX. The USP of Flow is its UX, which is uniquely powerful, as well as simple and clean.
- Flow can integrate with most Office 365 services, Azure services, and social platforms; it can also interact in a seamless manner between applications to perform actions and collect data.
- Flow also accommodates custom connectors like custom WebAPI and on-premises application integrations. These can be included in Flow as actions or conditions, which make Flow even more flexible and powerful.
- Each Flow starts with a triggering point. In our case, the triggering point is the record-level ability to create, update, select or delete an operation in Dynamics 365.
- Microsoft Flow works based on ownership. If we have more than one owner, then it is called a Team Flow; otherwise, it is called My Flow.
- Twilio is a third party communication platform that has the capability to make calls, messaging, etc.
- It makes life easy and provides a bunch of important features, such as logs for tracking messages/calls, and simplified APIs for developers to perform communication-related actions.
Traditional SMS integration requires lot of custom development and once after all the hard work is done, there comes a monster called tracking and managing integration. We would always find it hard to manage the SMS integration post-implementation, and there were no clean ways to track and manage the same.
But now with Microsoft Flow and Twilio, we have effective ways to create, modify, manage and track SMS integration seamlessly. We can track each and every Flow run in the Flow run section, and we can optionally re-run failures if needed. The Twilio portal also provides detailed log information on all the messages that were processed by the messaging service, which is really cool.
Scenario: SMS Integration with Microsoft Flow and Twilio
Let’s get started showing our integration exercise with a real-life scenario. Whenever an account record is created in CRM, it sends a message notification of the customer phone number using Microsoft Flow and Twilio.
- Office 365 CRM subscription
- Twilio account – A trial is available
Twilio Account and Authentication Setup
- Create a trial account with Twilio. We can find the Account SID and auth token on the home page – make a note of them.
- Create a phone number in Twilio – we need to have a Twilio phone number set-up in the following page https://www.twilio.com/user/account/phone-numbers . This phone number will be used as the From number when we send texts to customers/users. Twilio also supports verified alpha-numeric IDs that are specific to a company (if we have them).
- Keep the created phone number, Account SID and Auth token handy. We need this while creating an action in Microsoft Flow.
Set-up Microsoft Flow
- Open the Microsoft Flow service in Office 365 apps, then in the resulting screen navigate to My flows.
- Now select the tile called “Create a flow from blank”. Please note that there are many pre-built templates available in Flow, so feel free to make use of the one that fits your needs.
- In the appearing window, we need to select a trigger based on which Flow should be executed; in our case it’s Dynamics 365.
- After selecting Dynamics 365, in the appearing options select the “when a record is created“ trigger option (as our goal is to send an SMS on creation of an account record in Dynamics 365).
- This is the key part in setting up a Dynamics 365 trigger – choosing a CRM connection. If we have multiple instance of Dynamics 365 (PROD, SIT, UAT and DEV), we need to make sure that we point to the proper instance that needs SMS notification.
- Once we are done with connection, we need to select Entity Name. In our scenario, Accounts will be the entity name.
- At this point, we are done with the trigger step-up that fires when an account record is created in Dynamics CRM. Now click next step and add an action; note that you can also add conditions if needed.
- The new action that we are going to add will use Twilio to send a SMS notification based on the created account record in Dynamics 365. Search for Twilio service in the search box, and select the action called Twilio – Send Text Message(SMS).
- In the resulting option, fill in the connection details. We already have these details noted down based on the above section – Twilio Account and Authentication setup. Once done, click create and proceed to the next step, which involves creating a SMS template.
- Fill in the SMS template. We have an option to insert dynamic content from a related record, and in our case the related record is an account.
- From Phone Number – Sender of the Message. Use the Twilio phone number we have created, or any other verified alphanumeric ID.
- To Phone Number – Receiver of the message. In our case, this will be mapped to a newly created account’s Main Phone
- Text – Actual message content. This will be static text with a dynamically populated account name from the newly created account record.
- Once done, click create flow and we are done with Flow set-up. Now in CRM, create a new account record, and in a minute or two a SMS will be sent to the phone number in the account.
We are all set. Let’s monitor the status of the Flow that has been triggered. We can track the workflow logs (runs) by clicking the info icon.
We can also track message logs at the Twilio level by logging into the Twilio web portal – the direct link for that is https://www.twilio.com/console/sms/logs.
Happy learning – we will meet with another exciting article soon. In the meantime, if you have any questions about SMS integration with Microsoft Flow and Twilio, please contact Hitachi Solutions today.