Build A Bot With Microsoft Teams


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

  1. Open Azure Portal (

  2. Click New > AI + Cognitive Services > Web App bot.

    Microsoft Teams
  1. Provide the information in the form to create the Bot.

    Microsoft Teams
  1. Provide the Bot name.

  2. Select your pricing tier (F0 is free).

  3. Select the Bot template. (For this Article, I have selected Question and Answer).

  4. Click Create to get started with Bot creation.

  5. Watch the notifications tab for progress on Bot deployment. Wait until deployment succeeds.

  6. Click Go to Resource to open the Bot settings page.
    Microsoft Teams

  7. Click "Settings".

  8. Note down the Microsoft App ID.

    Microsoft Teams

  9. Click "Manage link" beside Microsoft App ID.

  10. You may change the password here if required.

    Microsoft Teams

  11. Click Save at the end of the page to save your changes to the application

Get the Microsoft Azure Bot Application Solution

  1. Click Build. Here you have a couple of options to choose how to work with your code.
    • Online code editor
    • Download Source Code
  1. Click “Download zip file” to get the source code.

  2. Open the source code in Visual Studio.

  3. Add below Key and Value pairs under App Settings in the Web.Config file.
    1. <add key="AzureWebJobsStorage" value="DefaultEndpointsProtocol=https;AccountName=ndazurebot;AccountKey=pyOxkkjksg6L55eYtsuBi0UG5mdPuK6H0piPuW6+4mC9xPvOUcWqFcng==;"/>  
    2. <add key="QnASubscriptionKey" value="2b523241d6b4a5c105a6e0ad7e"/>  
    3. <add key="QnAKnowledgebaseId" value="be5e4758-ee28-4866-8f40-1acdc70fb931"/>   
  1. You can get all the above values from APP SERVICE SETTINGS > Application Settings.

    Microsoft Teams

  2. From Visual Studio, Press F5 or run the solution.

    Microsoft Teams


If your application does not run as expected, try the below options.

  1. Update the Nuget Packages to latest stable version
  2. Replace all instances of Utils.GetAppSetting with ConfigurationManager.AppSettings

Test your Bot locally

  1. Download and install Bot Framework Emulator from

    Microsoft Teams

  2. Once installed, open installed Bot Emulator.

  3. Click Ellipses, click Settings.

    Microsoft Teams
  1. Download ngrok from

  2. Specify the ngrok.exe path.

    Microsoft Teams

  3. Click "Save".

  4. Test your bot locally.

    Microsoft Teams

    Microsoft Teams
Publish Bot to MS Azure
  1. Open Azure Bot App Service.

  2. Click "Get Publish Profile".

    Microsoft Teams

  3. Right-click on Visual Studio solution, click “Publish…”

    Microsoft Teams 
  1. Click Import and select downloaded publishing profile.

    Microsoft Teams 
  1. Click "Next".

    Microsoft Teams 
  1. Click "Next".

    Microsoft Teams 
  1. Click "Publish".

    Microsoft Teams

Test Bot in Azure

  1. Open Azure Bot App Service.

  2. Click Test in Web Chat.

    Microsoft Teams

Deploy Bot to Teams

  1. Open "Azure Bot App Service".

  2. Click "Channels".

  3. Click "Teams".

    Microsoft Teams 
  1. Click “I agree…” checkbox for Terms of Service.

  2. Click "Agree".
    Microsoft Teams
  3. Click "Done".
    Microsoft Teams
  4. Click "Microsoft Teams".
    Microsoft Teams
  5. Select any of the option to get started your Bot in MS Teams.

    Microsoft Teams

Hope this helps.