Overview
Bots are becoming more popular nowadays with their capability to interact with end users and answer their queries. Bots can be easily set up within Microsoft Teams to help Microsoft Teams be more interactive with end users.
In this article, we will go through how we can set up a Bot and integrate it with the Microsoft teams.
What is a Bot?
At this point, most of us know what a Bot is and how to interact with it. But still, to touch upon the topic, we will quickly see the basics of Bots.
In simple words, a Bot is an application that can perform automated tasks varying from simple to complex in nature. A very simple example of a Bot is a chatbot – which answers user queries based on keywords typed in by users.
For those who are using Windows 10 operating system, Cortana is the familiar bot. Siri is also one of the popular bots for mobile users.
In this article, we will create a Bot using Microsoft Azure and use it on Microsoft Teams.
We will need the below tools/apps to get started
- MS Azure Subscription
- Microsoft Teams
- Visual Studio
Create Bot using MS Azure
- Open Azure Portal (https://portal.azure.com).
- Click New > AI + Cognitive Services > Web App bot.
- Provide the information in the form to create the Bot.
- Provide the Bot name.
- Select your pricing tier (F0 is free).
- Select the Bot template. (For this Article, I have selected Question and Answer).
- Click Create to get started with Bot creation.
- Watch the notifications tab for progress on Bot deployment. Wait until deployment succeeds.
- Click Go to Resource to open the Bot settings page.
- Click "Settings".
- Note down the Microsoft App ID.
- Click "Manage link" beside Microsoft App ID.
- You may change the password here if required.
- Click Save at the end of the page to save your changes to the application
Get the Microsoft Azure Bot Application Solution
- Click Build. Here you have a couple of options to choose how to work with your code.
- Online code editor
- Download Source Code
- Click “Download zip file” to get the source code.
- Open the source code in Visual Studio.
- Add below Key and Value pairs under App Settings in the Web.Config file.
- <add key="AzureWebJobsStorage" value="DefaultEndpointsProtocol=https;AccountName=ndazurebot;AccountKey=pyOxkkjksg6L55eYtsuBi0UG5mdPuK6H0piPuW6+4mC9xPvOUcWqFcng==;"/>
- <add key="QnASubscriptionKey" value="2b523241d6b4a5c105a6e0ad7e"/>
- <add key="QnAKnowledgebaseId" value="be5e4758-ee28-4866-8f40-1acdc70fb931"/>
- You can get all the above values from APP SERVICE SETTINGS > Application Settings.
- From Visual Studio, Press F5 or run the solution.
Troubleshoot
If your application does not run as expected, try the below options.
- Update the Nuget Packages to latest stable version
- Replace all instances of Utils.GetAppSetting with ConfigurationManager.AppSettings
Test your Bot locally
- Download and install Bot Framework Emulator from https://emulator.botframework.com
- Once installed, open installed Bot Emulator.
- Click Ellipses, click Settings.
- Download ngrok from https://ngrok.com/download.
- Specify the ngrok.exe path.
- Click "Save".
- Test your bot locally.
Publish Bot to MS Azure
- Open Azure Bot App Service.
- Click "Get Publish Profile".
- Right-click on Visual Studio solution, click “Publish…”
- Click Import and select downloaded publishing profile.
- Click "Next".
- Click "Next".
- Click "Publish".
Test Bot in Azure
- Open Azure Bot App Service.
- Click Test in Web Chat.
Deploy Bot to Teams
- Open "Azure Bot App Service".
- Click "Channels".
- Click "Teams".
- Click “I agree…” checkbox for Terms of Service.
- Click "Agree".
- Click "Done".
- Click "Microsoft Teams".
- Select any of the option to get started your Bot in MS Teams.
Hope this helps.