Azure bots: integration with Teams
As we are heading towards the modern workplace model, we are thriving a lot on reducing the first level of tasks. One of the preferred feasible solution is to create a self-query knowledge base through which the end users can attempt to address their issues on their own before contacting the IT Team. Eventually API integrations with bots can reduce the first level of recurring tasks. Through Microsoft Bot Framework quite a lot of organizations are filling these requirements and increasing the operational excellence values.
In this article we will focus on how to create a bot in Azure and integrate them with Microsoft Teams.
In summary Bot usually comprises of three concepts dialog, channels and state. In my point of view dialog play a fundamental role in the Bot Framework. The dialogues will be organized in a natural sequence based on the input from the user it can respond, skip to next answer or even go in a sequential loop. In the back-end the programs will be configured to respond to the dialogues in a consecutive manner. Currently the underlying solution can be via C# , Node.Js or Rest API
Channels are the medium through which a user can communicate with the bots. There are more than 15 channels at this moment that can be integrated with Azure Bots. There is also an option to run our bot via our own client application using the direct line as our channel.
The Bot state service basically stores and retrieves state data that can be associated with User, conversation or a specific user. The former 2 are fully dependent on this data and state remains a database for them.
Bot Builder remains as a SDK framework which can be on C#, Node.Js or in RestAPI. Bot Service is used to build the bots, develop, test them and finally deploy on Azure.
In order to create a Bot login to Azure Portal and look for Bot service – and create Web app Bot.We require a web app bot because Bot is basically a web service that is exposed to a RestAPI.
https://exchangequery.files.wordpress.com/2019/05/1.png?w=600
Choose Web App Bot and create them
Now we can create a web app bot – provide them a name
https://exchangequery.files.wordpress.com/2019/05/2.png?w=600
Choose the language . In this example node.js is been chosen.
https://exchangequery.files.wordpress.com/2019/05/3.png?w=600
Provide all the basic required information. Here it is strongly recommended to turn on the application insights and this will provide the statistical consumption of the Bot service utilization. This utilization report is definitely required at a later stage to measure the utility of this service. We can select the option auto-create app ID an password. After this we are done with creating the Azure Bot.
We see here something called LUIS App Location. Microsoft uses LUIS(Language Understanding Intelligent Service).It is an AI service used to build natural language into apps, bots and IOT devices. This makes all the end user queries to learn easily and subsequently improve without manual intervention.
https://exchangequery.files.wordpress.com/2019/05/image.png?w=600
Once the validation is successful we can go ahead and create the bot.
The bot have been created and we need to plan, build, test and publish them. There are lot of many ways to create and publish them.
Here i have followed this Microsoft article and is straight forward to create and make your bot up and running with JavaScript.
https://exchangequery.files.wordpress.com/2019/05/4.png?w=600
Once the above is completed we need to deploy the bot in azure. We can follow the steps in this Microsoft Article. Also there are lots of articles available in the internet to make up running first bot in the internet. Here is one example.
Below is an example of hello world bot. This bot will respond hello world for all user input. The below node.js and package.json can also be used for creating the first bot. We need to have all the prerequisites for this on the local PC Visual Studio, Node Js Modules and bot builder modules installed. The Microsoft article linked previously have all the prerequisites and readiness.
https://exchangequery.files.wordpress.com/2019/05/capture-6.png?w=600
Create nodejs and this is the nodejs for helloworld bot.
https://exchangequery.files.wordpress.com/2019/05/capture-2.png?w=600
Install them from nodejs command prompt
https://exchangequery.files.wordpress.com/2019/05/capture-3.png?w=600
Create index.js and below is the indexjs for helloworld bot.
https://exchangequery.files.wordpress.com/2019/05/capture-4.png?w=600
Once after everything is done we can start
https://exchangequery.files.wordpress.com/2019/05/capture-5.png?w=600
Later we can use the same steps mentioned in the Microsoft article to publish them on Azure Bots.
Having followed the above article with the prerequisites , we can test our bot in web chat.
https://exchangequery.files.wordpress.com/2019/05/5.png?w=600
Having tested this once we navigate to channels tab now we have option to integrate our bot with more than 15 channels. Only the web chat will be enabled by default.
https://exchangequery.files.wordpress.com/2019/05/6.png?w=600
Here we will focus on integrating our bot with Teams.
After we click on Microsoft Teams, we will be getting the below option. In our case it will be only messaging channel since the bot which is used here for testing is 1:1 messaging bot.
https://exchangequery.files.wordpress.com/2019/05/7.png?w=600
We need to agree for the terms of service
https://exchangequery.files.wordpress.com/2019/05/8.png?w=600
We could see the Teams added into our channel.
https://exchangequery.files.wordpress.com/2019/05/9.png?w=600
It is time to test our bot in Teams. In-order to test them in teams we need to take the app id from the settings page of the bot.
https://exchangequery.files.wordpress.com/2019/05/capture.png?w=600
Once we search with the app ID in teams we would be able to see this bot as a contact in Microsoft Teams and we can also interact with them.
https://exchangequery.files.wordpress.com/2019/05/capture-1.png?w=600
Finally the Bot is up running and integrated with teams the next step is we need to create an app package for this bot and publish in teams. We will look in the next article on how to create a custom app package and publish them on Microsoft Teams.