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.
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:
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:
- assigned in CRM (the "assigning" happens manually),
- ignored,
- 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:
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:
As you can see, there are four steps here:
- 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.
- 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".
- Wait for an hour
- 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
-
Use Microsoft Flow to Integrate Your Website's Forms with Dynamics 365
Yes please - could you share your code, this is a great solution 🙂
// 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
Thank you for sharing!
-
Use Microsoft Flow to Integrate Your Website's Forms with Dynamics 365
This is great!
Can you share details related to your comment here?:
// 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
Because I would like to test it and later change to my needs to work with my WordPress form.
Thank you very much!
Georg
-
Use Microsoft Flow to Integrate Your Website's Forms with Dynamics 365
Whoa, Trevor! This is an awesome tutorial! Thanks so much for sharing.
*This post is locked for comments