Microsoft Dynamics 365 and Twilio integrate through the Dynamics 365 Web API, Power Automate custom connectors, and Twilio's REST API to bring programmable SMS and voice into your existing sales and service workflows within the Microsoft stack. This integration is built for enterprise organizations running Dynamics 365 as their CRM who need Twilio's carrier-grade messaging infrastructure and global number coverage rather than Microsoft's native SMS capabilities. You can build lightweight triggers using Power Automate without writing code, or go fully custom with Azure Functions and the Dynamics 365 Web API for production integrations that handle high volumes and complex routing logic.
What You Need Before You Start
Register an Azure Active Directory app in the Azure Portal under App Registrations, grant it the Dynamics CRM user_impersonation delegated API permission, and note the Application client ID and client secret for OAuth 2.0 token requests. Your Dynamics 365 organization Web API URL follows the pattern https://[orgname].api.crm.dynamics.com/api/data/v9.2/ and you will use this as the base for all entity reads and writes. From Twilio, collect your Account SID, Auth Token, and at least one SMS-enabled phone number, and consider creating a Twilio Messaging Service for campaigns to benefit from number pooling and automatic opt-out management. If you are using Power Automate, install the Twilio connector from the connector library, create a connection using your Account SID and Auth Token, and verify it by sending a test SMS through a manually triggered flow before building any production automation.
Step-by-Step Integration Guide
In Power Automate, create a flow triggered by the Dataverse connector with the When a row is added, modified, or deleted trigger on the Contacts table, set Change type to Modified, and add a filter condition checking that the Status Reason column equals the value you want to act on. Add a Twilio Send Message action from the Twilio connector, mapping To to the Contact mobilephone column from the trigger dynamic content, From to your Twilio number, and Message Body to a string composed using the contact fullname from the trigger. For a programmatic integration without Power Automate, obtain an OAuth 2.0 access token by posting to https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/token with grant_type=client_credentials and scope=https://[orgname].api.crm.dynamics.com/.default, then use the bearer token to query contacts at GET https://[org].api.crm.dynamics.com/api/data/v9.2/contacts?$filter=mobilephone ne null&$select=fullname,mobilephone. Log every SMS as a Dynamics 365 phonecall activity entity by posting to https://[org].api.crm.dynamics.com/api/data/v9.2/phonecalls with body fields subject, description, phonenumber, directioncode set to true for outbound, and regardingobjectid_contact@odata.bind set to /contacts({contactId}) to associate the log with the correct record.
Common Issues and How to Fix Them
Dynamics 365 Web API requests return 401 Unauthorized when the Azure AD app has been granted the API permission but admin consent has not been explicitly granted for the tenant, which is a separate required action from adding the permission. Navigate to the Azure Portal, open the app registration, go to API Permissions, and click Grant Admin Consent for your directory before any service-to-service call will succeed. Power Automate flows fail on the Twilio action when the phone number value from the Dynamics 365 trigger contains formatting characters like parentheses, spaces, or dashes that Twilio rejects as an invalid To number. Use a Power Automate expression to strip non-digit characters before passing to the Twilio action: replace(replace(replace(triggerOutputs()?['body/mobilephone'], '-', ''), ' ', ''), '(', '') and then prepend the country code prefix. A third common issue is duplicate phonecall activity records being created when both a Power Automate flow and an existing plugin or workflow in Dynamics fire on the same trigger event. Deactivate any overlapping native Dynamics workflow that writes to the same phonecall entity, or use a custom Dynamics solution field as a flag to prevent both paths from executing on the same record update.
How to Get More from This Integration
Build a two-way SMS channel by configuring your Twilio number's inbound webhook to post to an Azure Function that parses the From and Body fields, queries the Dynamics 365 contacts entity by mobilephone using GET https://[org].api.crm.dynamics.com/api/data/v9.2/contacts?$filter=mobilephone eq '{E164number}'&$select=contactid, and creates an inbound phonecall activity record with directioncode set to false, making every customer reply visible in the Dynamics timeline without manual entry. Extend the integration to Dynamics 365 Customer Service by implementing a custom channel provider using the Channel Integration Framework v2.0, embedding a Twilio Client JavaScript softphone in the agent desktop, and routing inbound calls through Twilio TaskRouter matched to Dynamics queue assignments read from the agent's systemuser record. Automate appointment reminders by running a scheduled Azure Function that queries the Dynamics 365 appointments entity for records in the next 24 hours using GET /api/data/v9.2/appointments?$filter=scheduledstart ge {today} and lt {tomorrow}&$expand=requiredattendees_activity, then sends a Twilio SMS to each attendee's mobile phone. Use Dynamics 365 Power BI integration to build dashboards from the phonecall entity filtered by the integration origin field you stamp on each record, reporting on SMS volume, delivery success rates, and response times segmented by sales region or service queue.
Conclusion
Twilio and Dynamics 365 together bring programmable SMS and voice into the Microsoft ecosystem your organization already depends on for customer data and operational workflows. Contact Telphi Consulting to scope and deliver this integration for your Dynamics 365 Sales or Customer Service environment.
Ready to Transform Your Business Communications?
Get a free consultation with our VoIP experts and discover how we can help you save costs, improve efficiency, and scale your business.
Comments (0)
Join the discussion and share your thoughts (AI-moderated for quality)
Be the first to comment
No comments yet. Share your thoughts below.