Skip to content
Microsoft Industry Blogs - United Kingdom

An illustration that represents AI, next to a drawing of Bit the Raccoon.

This tutorial demonstrates how to add Logic App integration to your chatbot, specifically, adding email functionality. It may seem difficult to begin with, but once you are shown how to do it, it is actually quite simple.


This tutorial would not have been made possible without the guidance and support of Saranya Ravichander (CSA), and Gregory Lisiak (Architect).


Getting started

The tutorial is split into three parts; Healthcare Bot Scenario Set Up, Logic App Set Up and the Healthcare Bot & Logic App Integration.

I’m using the following resources: Azure Healthcare Bot Service (Azure Marketplace), Logic Apps (Portal), and an Outlook account (Office 365).

You must have:

  • a working Healthcare Bot Scenario
  • access to the Scenario Editor
  • access to the Azure Portal
  • an office 365 Outlook account


1. Healthcare Bot Scenario Set Up

To begin, you will need to create the representative JSON payload in order to populate the dynamic content for the Logic App to use for generating the email. This could be as simple as simply sending contact information to the Logic App to send a basic email or as detailed as sending the information collected during the bot conversation as a conversation transcript. At the end of your scenario:

1. Add an Action element to build an array containing all of the variables needed such as; It may be beneficial to save this in a text file as you will need the array information in a later step. For example:

scenario.testVar = 
"patientAge": scenario.patientAge,
"smokerOrNot": scenario.smokerOrNot,
"alcoholAmount": scenario.patientAlcohol.entity,
"riskLevel": scenario.riskLevel,
"riskScore": scenario.riskScore,

1.1 Add a Statement element that simply displays the array information which will be needed by the Logic App to build the dynamic content inventory that it will need to support. The statement element would look like this in the editor:


1.2 Run the Bot scenario and copy the resulting statement. It will look like this:

"alcoholAmount":"> 14 units/week",
"riskLevel":"high level",  

Keep a copy of this. We will use this later.

1.3 You will need to use a text editor to change the quote marks to be consumable by the Logic App. For example:

A screenshot showing an edit to quotation marks to make them compatible.

Your scenario editor should now have the following new elements: 1 x Action element, 1 x Statement element and 1 x Data Connection element. Take a look at the image below for an example:

A screenshot of the scenario editor so far.

Note: You can ignore the final “Thank You” statement element.


2. Logic App Set Up

1. Now go to the Azure Portal and create a Logic App resource.

1.1.1 Go to the Logic Apps Designer and choose the “When a HTTP request is received” as the trigger.

A screenshot of the Logic Apps Designer website.

1.1.2 Click on “Use sample payload to generate schema”

The “Use sample payload to generate schema” in the

1.1.3 This is where you will paste in the output you generated in the Bot scenario and cleaned up the quotes in the text editor.

The output being pasted into the JSON payload section.

Once you click done, the Request Body JSON Schema will look something like this:

A screenshot of how the Request Body JSON Schema should look.

1.1.4 Save this step, and the HTTP POST URL will be generated. You should see something like this:

A screenshot of the newly generated HTTP POST URL.

1.2 On the Logic App Designer, click on “+ New Step”

1.2.1 Search for “Outlook”.

1.2.2 Under Actions, select “Send an email (V2)” — it will ask you to sign in

A screenshot of the

A screenshot showing the need to sign in to create a connection to Office 365 Outlook.

1.2.3 Once signed in, you can format the email. The fields from the JSON payload can be selected from the Dynamic Content list.

An email being drafted in the

You will notice that if you leave this composer and go back into the step, the order of the fields change. You will find that it is much easier to use Word to craft the base message and paste it into the Body before adding the dynamic content. Formatting options are a bit limited (e.g. Tables cannot be added for instance).

1.2.4 Enter whatever you want in the email body/subject/recipient. Regarding the dynamic content, all the blocks you can see in the image below are classed as dynamic content. It will be dependant on the values you input in the bot conversation. The way you input dynamic content is simple: Clicking anywhere in the body/subject/to sections leads to a pop-up section on the right-hand side. You can then search for fields that you specified in the sample payload. Now in the email, those fields will show whatever you input in the bot conversation. Here is an example of “Send an email (V2)” step:

An example email, featuring numerous blocks of dynamic content.

Once you complete the email template, you are ready to return to Bot. Don’t forget to copy the HTTP Post URL before leaving the Logic App Designer.


3. Healthcare Bot & Logic App Integration

1. Add a Data Connection element to your Bot scenario, choose “POST” and paste your Base URL (this is the HTTP Post URL we just copied) into the Data Connection Call. If you copied your array assignment to a text file, find it and copy it into the Payload section. If you didn’t, you can save the Data Connection Call, go to the Action Block and copy it and come back to the Data Connection. Assign the variables for the response and error and click OK. For example:

A screenshot of the Data Connection Call dialog.

1.1 If you haven’t done so already, you can delete the Statement Block created in step 2 and connect the Action Block from Step 1 to your Data Connection Call.

A screenshot showing the connection between the Action Block from Step 1 and the Data Connection Call.

1.2 Here is a sample email:

A sample email, populated by dynamic content.


Going Forward

Using this tutorial, you should now be able to send a variety of different emails for your use cases. Logic Apps makes the integration and flow between these Azure services incredibly simple, yet effective.

If there are any questions or ideas for a follow up blog, please drop a message.


Useful Resources

More from Jalal Uddin:

Join the conversation

Leave a reply

Your email address will not be published. Required fields are marked *

Loading comments...