cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous

Use Microsoft Flow to Integrate Your Website's Forms with Dynamics 365

As a marketer, one of the most tedious business processes is dealing with all of the people that submit forms on a website. Many marketing automation platforms offer some kind of webform integration to your CRM system, but these come with downsides. For instance, some forms aren't suitable for creating in the marketing automation system. Also, these forms are often ugly and can slow down your site.

 

Here's how we integrated our website's forms with Microsoft Dynamics 365 for Sales, and further optimized with decision-making, email-follow ups, and more. 

 

Our Website

 

Our website is built on Wordpress, and it uses a form plug-in called Ninja Forms. We wanted people that submitted the "contact us", "free consultation", or other select forms to be entered in Dynamics 365 for Sales as a lead. You can see one of the forms on our Dynamics 365 page (we're a Microsoft Partner). My solution required a bit of Wordpress knowledge, but I'll do my best to explain how it works below.

 

The Trigger

 

1 - HTTP Request

 

The first step is to create a new flow, then search for "Request/Response" and choose "Request". This trigger allows us to send a message to the Flow.

 

http request.PNG

 

The message will contain all the data we want to add to Dynamics 365, in "JSON" format. Add/modify these JSON properties depending on the form fields that you want to sync with Dynamics 365:

 

 

{ "properties": { "topic": { "type": "string" }, "email": { "type": "string" }, "first name": { "type": "string" },
"last name":{
"type": "string"
}, "description": { "type": "string" }, "source": { "type": "string" }, "company": { "type": "string" }, "phone": { "type": "string" } }, "type": "object" }

 

 

The result of this step is that we have instructed Flow to keep its ears open for a particularly-formatted message to a particular place. It is very important to keep both the "HTTP POST URL" and your JSON Schema private; or anyone could trigger this flow.

 

2 - Sending The Message

 

So: Flow has its ears open for a message from your webform. You now have to send that message to Flow everytime someone fills out a form. This will be the most technical part that varies the most from site to site. What you need to do is send an "HTTP POST Request" to the "HTTP POST URL" that was generated by the "Request" trigger you just set up. This POST request will contain the JSON-formatted data from your form.

 

As I mentioned, I used Wordpress and the Ninja Forms plugin. Here's the PHP code I used to send the message to my Flow. You might want to skip past this as it's not 100% complete, but there are some good bits of code that will help you if you're going to send the message with PHP:

 

 

function create_consultation_in_crm_callback( $form_data ){ //this function will run every time a free consultation form is submitted 
// For brevity, I have removed a section here where I assigned each of the Ninja Form fields to the variables I use below. Please leave a comment if you'd like this code.

$post_url = '<my HTTP POST url>'; // Replace this with your url

//Now, we're going to build all of the form fields in a PHP array. You will have created the variables earlier on in the function
$arg_data = array( 'topic' => $topic, 'email' => $email, 'name' => $name, 'description' => $description, 'company' => $company, 'phone' => $phone, );
$data = json_encode( $arg_data ); // take that PHP array and make it a JSON array
$args = array( 'headers' => array( 'Content-Type' => 'application/json' ), 'body' => $data ); // this line completes the formatting of your message to Flow $response = wp_remote_post( esc_url_raw( $post_url ), $args ); // This line actually sends the message to your Flow }

 

Now, every time someone submits the "Free Consultation" form, Microsoft Flow will receive a message with a topic, email address, name, description, company name, and phone number.

 

Take Action

 

So far so good. Every time someone submits the Free Consultation form, our Flow will be triggered. Now, it's really up to you in regards to what you want to do with that data; what's awesome about the "HTTP Request" trigger is that all of the JSON data is available later on in your Flow.

 

You could add them to an Excel Sheet, send them an email, or compose a tweet to alert the world that they've been on your website (don't do this). Here's what we did.

 

1 - Deal With Spam and Create Different Options For the Next Step

 

First things first: our forms get a lot of spam. Some of it is caught by our forms plugin, but some slips through the cracks. 

 

Also, we have two kinds of leads: qualified, or unqualified. Qualified leads get assigned to a sales rep, and unqualified leads go to marketing.

 

To accomodate our flow for these scenarios, I added a "Send Email With Options" action from Outlook:

 

options.PNG

 

 

 

This decision email is sent to several people at our company, so that the first one to see it can decide what happens to the lead.

 

2 - Conditions

 

Next, we need to interperet the "selected option", and send our lead down one of three paths. As I mentioned above, the lead will be:

  1. assigned in CRM (the "assigning" happens manually),
  2. ignored,
  3. or sent a generic follow-up email. 

I'm going to go down path #3 because it's the most interesting. This step saves our sales team some time; if it's an unqualified lead that "might or might not" be interested in working with us, we can have Flow follow-up with them and see if we get a response.

 

First, we set up the condition: 

 

ifthis.PNG

 

 

 

If the condition is "no", there's another nested condition that checks if we want the the lead to be assigned in CRM (path 1) or ignored (path 2), and then takes action.

 

From there, we send the generic follow-up:

 

followup.PNG

 

As you can see, there are four steps here:

  1. The first step sends an email to our team to let them know 1) that the lead has been dealt with, and 2) what action will be taken. I used Sendgrid so it didn't show up in my Outlook "Sent" folder.
  2. Create a lead in Dynamics 365 for Sales. You'll notice that you have to enter a value for each field that is required in Dynamics 365. Hitting "advanced options" allows you to enter more fields. You'll also notice that I set the "lead source" to "8". That sets the dropdown field to the 8th option, which in our case is "Website".
  3. Wait for an hour
  4. Send an email "From" our VP of Sales to the lead. It contains a generic message and a call to action.

 

Conclusion

 

The HTTP Request trigger is a very powerful tool that can be used to integrate almost any application to any of the Microsoft Flow connectors. In this example, I showed how to integrate your website's forms to Microsoft Dynamics 365 for Sales. The Flow prevents me from having to manually enter leads, allows for user feedback, and saves my sales team a couple minutes every day.

 

Feel free to message me with any questions!

Comments
About the Author
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • I am a Microsoft Business Applications MVP and a Senior Manager at EY. I am a technology enthusiast and problem solver. I work/speak/blog/Vlog on Microsoft technology, including Office 365, Power Apps, Power Automate, SharePoint, and Teams Etc. I am helping global clients on Power Platform adoption and empowering them with Power Platform possibilities, capabilities, and easiness. I am a leader of the Houston Power Platform User Group and Power Automate community superuser. I love traveling , exploring new places, and meeting people from different cultures.
  • Read more about me and my achievements at: https://ganeshsanapblogs.wordpress.com/about MCT | SharePoint, Microsoft 365 and Power Platform Consultant | Contributor on SharePoint StackExchange, MSFT Techcommunity
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Founder of SKILLFUL SARDINE, a company focused on productivity and the Power Platform. You can find me on LinkedIn: https://linkedin.com/in/manueltgomes and twitter http://twitter.com/manueltgomes. I also write at https://www.manueltgomes.com, so if you want some Power Automate, SharePoint or Power Apps content I'm your guy 🙂
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 15 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • Big fan of Power Platform technologies and implemented many solutions.
  • Passionate #Programmer #SharePoint #SPFx #M365 #Power Platform| Microsoft MVP | SharePoint StackOverflow, Github, PnP contributor
  • Web site – https://kamdaryash.wordpress.com Youtube channel - https://www.youtube.com/channel/UCM149rFkLNgerSvgDVeYTZQ/