· Feb 23 5m read

Using an Azure bot to access IRIS

I have challenged to create a bot application using Azure Bot that can retrieve and post data to IRIS for Health.


A patient's data has already been registered in the FHIR repository of IRIS for Health.

The patient's MRN is 1001. His name is Taro Yamada. (in Japanese :山田 太郎)

This bot can post new pulse oximeter readings as an observation resource linked to the patient.

Overview of how the bot application works below:



(1) In an application like Teams, a user asks "Hello".

Teams sends the message to the "Bot Framework Channel Service" , which is hosted by Microsoft.

(2) The Bot Framework Channel Service asks the Bot.

The service asks the Bot "Where is the endpoint ?"

(3) The bot returns information about the endpoint to the service.

Bot knows the endpoint.

(4) The service asks the user's request to the endpoint.

The endpoint is a web application that is published on Azure we app.

(My sample is written in Python.)  

​​(5) The endpoint makes answer and send the answer to the service.

(6) The service receives the answer from the endpoint and pass to it to the user.


IRIS has not appeared in the above flow.

I add a call from the python web application to IRIS for Health interoperability. And I prepared FHIR repository in the IRIS like this:



IRIS interoperability samples is here 👉

You can build and start the container with "docker-compose up -d". (It includes sample patient data (MRN=1001) and settings as needed.) 

Note: The python web application needs to call applications over https. But I'm removing the certificate files from my repository to avoid violating of git policy.

Python web application calls to IRIS REST dispatch class using this URL "https://webserveraddress/production/request".


Below are the instructions for creating an Azure Bot application.

(1) Create a resource group on Azure.

(2) Create an Azure Bot in the resource group.

You'll need to confirm your "MicrosoftAppId" and "MicrosoftAppPassword". I'll describe this later.

If you want to use the bot from Teams, you need to add the Teams channell to the bot. (The gif above uses the Teams channel.)

(3) Create a web application in the same resource group as the bot on Azure.

You'll get the web server address after creating it.

(4) Set endpoint on your bot configuration.

(5) Deploy your code to the web application.

You can choose Git repository.

(6) Test it!


Let's see the details!

(1) Create a resource group on Azure.

You can create new resource group from this page (Resource groups - Microsoft Azure)

I have created a new resource "202312ISJBotRG".


(2) Create an Azure Bot in the resource group.

After moving the resource group, you can select the "Create" menu.


After creating the bot, you need to set "New client secret" in the [Configuration] page as follows:

You should make a note of the secret character and the value of "Microsoft App ID".

This information is required to set your web application.


If you want to use the bot from Teams, you should add the Teams channel to your bot.

You can add the Teams channel from the [Channels] menu on your bot. (just clicking on the Teams icon.)



(3) Create an web application in the same resource group as the bot on Azure.

Create an web application for your resource group. 

Go back to your resource group page. And create a web application such as follows:


You can select your favorite "Runtime stack" (example is Python 3.8) and "Region" and "Pricing plan".

After creating the application, you can get the web server address on the web application page.

We need to set the address to the python application code. So make it note of this string. (Example is "")


Next , we need to set the bot id, secret and deployment details.

Go to the [Configuraion] page on the web application page.

You need to add "MicrosoftAppId" and "MicrosoftAppPassword" from "New application setting" in "Application settings".

(MicrosoftAppPassword is the bot secret which you copy in step (2).)


The next thing we need to do it set "General settings" for deployment.


I have referred this sample code 👉

The example is simple and it's easy to understand what  I should write about web application communicating with bot.

I update some codes under bots , data_models directories.

If you run it on your local environment, you don't need to update the code.

But if you run it on Azure web application, you need to update code of like this:

def init_func(argv):
    APP = web.Application(middlewares=[aiohttp_error_middleware])
    APP.router.add_post("/api/messages", messages)
    return APP

if __name__ == "__main__":
        #web.run_app(APP, host="localhost", port=CONFIG.PORT)
        web.run_app(APP, host="", port=CONFIG.PORT)
    except Exception as error:
        raise error

I added this call "python3.8 -m aiohttp.web -H -P 8000 app:init_func" to start a python web application on Azure.

If you want to know the details, please refer to this URL👉


My code is here 👉

If you want to run it, you need to update some codes.

  • Line  15 , 16 of : you need to update to your bot information.
  • Line 10 of : you need to update the endpoint which is IRIS REST server.


(4) Set endpoint on your bot configuration.

Go to the Configuration page of your bot.

Set your web server address + "/api/messages" to "Messaging endpoint".



(5) Deploy your code to the web application.

I use git repository. It's easy to deploy to web application on Azure!!

You can set the information in the [Deployment Center] of the web application page.

Once deployes, you can test now!


(6) Test it!

You can test your application using the "Test in Web Chat" on your bot page.


If you add the Teams channel, you can test at Teams.


Once you have clicked on [Open in Teams], you can open your teams chat and try it out.😀



You can test without deploying your application as an Azure web application.

When your python application and IRIS interoprability are ready, you can publish your python application using ngrok like this:

ngrok http 8000 --host-header=

ngrok can provide a tunneling service.  I can access my local port directly from the public area using the ngrok tunneling service. 

And we need to change the endpoint in the bot configuration like this:

Once set up, I can test using web chat.

Discussion (1)2
Log in or sign up to continue