Microsoft Flow: Import web forms into Dynamics 365

Microsoft Flow to Dynamics 365 Overview

In my previous post about Microsoft Flow, I ran through the basics of a Flow and why you should use it with Dynamics 365. In this post, I plan to run through how you can automatically create a Lead in Dynamics 365 by making some simple changes to your existing web form email output.

Before we start

Before we begin, you need to make sure you have access to the following:

  • You must have access to change the format of the email that is sent when a form is submitted on your website.
  • You must have access to a mailbox that the email is sent to, I’m using a shared mailbox on Office 365.

Basic Process

The basic process will work as follows.

The web user completes a web form submission which then triggers an email to a shared mailbox in Office 365. Microsoft Flow picks up this email message and parses the data contained in the form to creates a new Lead in Dynamics 365.

Microsoft Flow Process Diagram

Web Form Changes

The first thing I need to do is update the email output. The sample form I’m using has the following fields:

  • First Name
  • Last Name
  • Company
  • Email
  • Phone
  • Message

What I need to do is to add this data in the message body in a JSON format. For a non-developer, this may sound very technical but it’s not. I needed to format each field in a “Label” : “Value” format, where ‘Label’ is what you want to call the field and ‘Value’ is the merge field from the web form. In my example, the merge fields were represented with numerical ID’s. The output below is what appears in the body of the email message template.

{
“FirstName” : “[18]”,
“LastName” : “[19]”,
“Company” : “[20]”,
“Email” : “[21]”,
“Phone” : “[22]”,
“Country” : “[23]”,
“Message” : “[24]”
}

An example of the message that comes through when someone completes the form, will pull through something like this:

{
“FirstName” : “Jason”,
“LastName” : “Smith”,
“Company” : “Jason Consulting”,
“Email” : “jason@jconsulting.com”,
“Phone” : “0800 100 1000”,
“Country” : “UK”,
“Message” : “Hi, Can someone please contact me about product XYZ. Thanks”
}

Microsoft Flow Steps

Once the output is set, the Flow steps are fairly simple.

Microsoft Flow to Dynamics 365 Overview

First, we add the Trigger ‘Office 365 Outlook – When a new email arrives in a shared mailbox’. I’ve specified which shared mailbox to poll (step 1), which folder to monitor (step 2) and I’ve added a subject filter (step 3). This is because in my example, we get email from other sources into this mailbox and I only wanted this Flow to trigger on a message from a specific web form.

Microsoft Flow Poll Shared Mailbox

Next, I added the ‘Content Conversion – HTML to text’ action. I wanted to strip out any HTML in the message to make sure that only the body text was left. Clicking into the Content section loaded the Dynamic content window and I selected the email Body message.

Microsoft Flow Strip HTML Action

I then added the ‘Data Operations – Parse JSON’ action and added the plain text content in the Content box. We have to tell flow what the JSON schema is so that it can parse the data correctly. I did this by using jsonschema.net but if you prefer, you can use the ‘Use sample payload to generate schema’ option (step 2) and paste in an example message and click done.

Microsoft Flow Parse JSON Action

Microsoft Flow Parse JSON Payload

The final step was to add the action to create the Dynamics 365 Lead record. I added the ‘Dynamics 365 – Create a new record’ action and selected the appropriate Organisation name and Entity name. I then used the Dynamic Content to map in the field data I needed.

Microsoft Flow to Dynamics 365 Field Mapping

That’s it! Now any email that comes into the shared mailbox from that web form is processed into Dynamics 365 as a Lead record.

Confused about when to use Microsoft Flow, Dynamics 365 workflows or business rules?

Contact Rocket CRM to discuss Dynamics 365 training that can be tailored around your needs.

share with your friends

Facebook
Twitter
LinkedIn