Unlock Your Microsoft Dynamics 365 CRM Data with Segment

For many organisations, CRM systems are integral to their operations. Yet these tools often become data silos, preventing valuable customer insights from being made available to downstream tools. For example, when the sales team updates a user’s contact info in the CRM, it's crucial to get those updates into downstream tools in real-time. Alternatively, your CRM may record customer service interactions and it’s important to ensure that any queries your teams handle, along with customer satisfaction scores, are transferred to your data warehouse to provide business intelligence. In this guide, we will exploring how you can use a no-code approach to send new and updated Contact records from Dynamics 365 to Segment.

Made by Carl Chambers

What do you need?

  • Dynamics 365

  • Power Automate

  • Microsoft Dataverse

Easily personalize customer experiences with first-party data

With a huge integration catalog and plenty of no-code features, Segment provides easy-to-maintain capability to your teams with minimal engineering effort. Great data doesn't have to be hard work!

On this page

Create a new HTTP API Segment source

First, create a new HTTP API source in your Segment workspace. Make a note of the write key, as you’ll need this later when configuring Power Automate. 

cc1

Create a new Microsoft Dynamics 365 CRM trial (optional)

Head over to the trials section of the Microsoft Dynamics website and select the edition of Dynamics you’d like to integrate with Segment. For the purposes of this guide, we’ll be using Microsoft Dynamics Sales 365. Once you’ve setup a trial, it’s a few simple steps to start sending data to Segment.  

Create a new Power Automate Flow 

To create a new Power Automate flow, navigate to the Contacts tab within Microsoft Dynamics and select See your flows from the Flow menu using the top navigation menu.  This will open a new window for Power Automate.

cc2

Use the New Flow button at the top of the page, select Automated Cloud Flow from the list of options.  Give your flow a name and search for the Microsoft Dataverse trigger for when a row is added, modified, or deleted.

cc3

Next, define when your flow should trigger and select New step.  In this example, we are triggering a flow when a Contact is added or modified across the entire organization. 

cc4

Select + New step to add a new step to your flow. The second step of the flow will send the new or updated contact data from Microsoft Dynamics to Segment’s HTTP API. Search for and select HTTP from the list of available connectors.

cc5

Next, configure the HTTP connector to send data to a Segment HTTP API source. 

cc6

Set the Method as “POST” and the URL to “https://api.segment.io/v1/identify”.   

Next, add the Authorization and Content-Type headers. The Authorization header should contain the value "Basic", followed by your base64 encoded write key (appended with a colon), which we obtained from your Segment HTTP API source. You can easily find online tools to help encode the write key. For more on how to authenticate with the HTTP API, refer to the Segment documentation.

  •  Set the Content-Type header to “application/json”.

The body of your request should include a JSON object that aligns to the Segment Spec. In this example, we are making an identify call, which is used to create and update users. This call require the userId and traits that should be passed to your downstream tools. 

Here’s an example of an identify call with real values:

{
  "userId": "97980cfea0067"
  "traits": {
    "email": "peter@example.com",
    "first_name": "Peter",
    "last_name": "Gibbons",
    "crm_id": "97980cfea0067",
    "mobile": "0452222589"
  },
}

When defining the body of your API call, Power Automate allows you to insert dynamic content into your request. Save when you’re finished mapping your data. 

cc7

Testing your Flow

To test your integration, update a contact record in Dynamics 365 and view the Segment Debugger for your HTTP API source to view the request.  If the integration is successful, you will see your identify call with the user’s traits.  

cc8

If you aren't finding any activity in the Segment debugger, you have the option to view the run history within Power Automate for any failed requests. This area allows you to view the status and any error codes that may have been returned by Segment's API.

cc9

Wrapping up

In this recipe you’ve seen how no code is required to sync your contacts data from Dynamics 365 with Segment and make that data available for every other tool in your stack.  But that’s not the end of the journey!  You could try this with all sorts of other data sets within your Dynamics 365 environment:  Leads, accounts, opportunities, or even send events to your downstream tools when a customer service case is closed.  How could you better use the data in your CRM if it were piped to other systems in this manner?

Getting started is easy

Start connecting your data with Segment.