How to use Microsoft Flow to automatically send a weekly email of open leads in Dynamics 365
Managing leads can feel like a failing juggling act. You keep in touch with most leads but fail to respond to a question one lead has about your proposal. Enhanced sales management applications like Dynamics 365 for Sales are great for keeping track of sales contacts, notes, and dates, but are limited by a user’s ability to complete manual sales tasks.
Using Microsoft Flow to send automated reminders will help prioritize sales leads, keep them top-of-mind, and provide an overview of the sales funnel to your employees. Flow is a cloud-based workflow automation tool included in most Office 365 plans. It connects with other Office 365 and Dynamics 365 applications as well as third party services, allowing you to build custom workflows in a graphical user interface.
In our scenario outlined below, Flow will send automated weekly email to display open leads in Dynamics 365 for Sales. This flow can be adapted and customized to include other relevant lead information like next contact date, lead owner, line of business, etc.
If you are unfamiliar with how Flow works, review our blog on using Flow to automatically create a Planner Task when a lead is created in Dynamics 365. The blog also includes instructions for accessing and setting up Flow.
Creating the flow
To create a new flow, click the My Flows tab on the top bar and select Create from blank.
1. In the Add a trigger box, type in Recurrence and select Schedule – Recurrence.
2. Specify how often the flow should run (I selected weekly on Monday mornings at 6 AM, but choose a day and time that makes most sense for your schedule).
3. Insert a new step.
4. Find and select the List records in Dynamics 365 action.
5. Select a Dynamics 365 organization and the Leads entity from their corresponding drop-down menus.
Note: If you haven’t configured the connection to your Dynamics 365 environment in Flow, you’ll need to do so before continuing. To configure the connection, select the gear icon in the upper right corner of the window and choose Connections from the drop-down list.
Without further direction, Flow will gather all open and closed leads in your Dynamics 365 environment. To limit the records Flow gathers to open leads, you’ll need to use the Dynamics 365 API (with API query syntax) to filter the data.
6. Expand the window to include advanced options and enter “statuscode eq 1” into the Filter Query field.
Processing the list of items
Because this flow queries a list of records of an unknown quantity, Flow needs to know how to handle each record it receives. This is done by creating an Apply to each action that parses data from each lead record and enters requested data into the body of an email message.
Start by creating a variable to be used in the apply to each function.
7. To do so, add a step and search for “initialize variable”. Select the action and add the name “Open Lead List” and set the type as String.
8. Add another step and search for “Apply to each”. Select the Apply to Each Action.
9. In the Select an output from previous steps field select value - List of Items.
10. Within the Apply to each action, select Add an action. Search for “Append to string variable” and select the action from the list.
11. In the Append to string variable action, enter the lead information that will be sent out in the email. For simplicity, start with only the lead name and email address. You can add further customization later.
12. Select Open Lead List as the name. In the value field, insert in the dynamic records (fields that pull in whatever data is filled into the field in Dynamics 365) for the Name and Email fields with a dash in between them.
Note: We recommend adding a line break in the value field after inserting the email record to ensure each lead is put on a new line in the email body. To do this in a plain text email (the default email format in Flow), click on the space directly after the email record and press the enter key while holding down the shift key.
Create the email
1. Add a final step and search for the Send an email action.
2. Enter the email address that will receive the weekly email and add a subject line.
3. In the Body field, select the Open Lead List variable from the Dynamic content menu.
Test the flow
Verify that the flow pulls the correct information from Dynamics 365 and sends an email by testing the flow.
1. Click the Test button in the top right corner of the window.
2. Select I’ll perform the trigger action and click Test.
If set up correctly, you’ll receive an email with a list of all open leads.
Need help building this or other flows? We’d love to help! Schedule a call with a member of our Microsoft Flow team to get started.