Make a bot for simple interactions in Teams using a Webhook

Published Jan 18 2022 05:05 AM 2,175 Views

Introduction

Have you ever had an idea to ask a bot to perform a simple interaction? Then this article is for you.

A simple interaction could be an answer to a question you asked:

  • You: What time is it?
  • Bot: It's 3.56PM

You could achieve this (and more) by building a bot using tools such as Power Virtual Agents or Bot Framework, but that is a little overkill for a simple interaction.

Instead, let's use Webhooks to achieve this.

The idea

Before we begin, let's fictionalise a use case. The idea is that users need to quickly be able to check the current and forecasted for any location from within a Team.

image

The solution

image

The solution is a Webhook in Teams and a Bot (surprised?). This works as follows:

  1. User @ mentions the Webhook (same as a would any other bot) in a Team channel
  2. This will trigger some external service (bot) HTTP, in this case an Azure Function
  3. The external service (Bot) will call a weather API and then return the weather information to the Team channel

Let's break this down by component.

Webhook

A Webhook is a way for two applications that can communicate with each other. In our case, a simple bot and Teams.

Teams supports two types of Webhooks:

  • Incoming Webhook - An application sends a message to Teams using a Webhook address generated in Teams. This could be used if you wanted to automate some sort of alert or notification in to a Team
  • Outgoing Webhook - Teams sends a message (request) to a Webhook address created outside of Teams. The external Webhook address is an application that then responds to your request with message (response)

For this solution, it is an Outgoing Webhook.

There are some limitations to using a Webhook in Teams, so bear these in mind when choosing Webhooks for your own idea:

  • Webhooks are associated to a single Team. You cannot deploy the same Webhook to multiple Teams or outside of a Team (personal context)
  • Everybody in the Team can see the interaction. If the interaction should be private (between the user and the bot), this should not be used
  • This will work with a simple request and response, or question and answer. It will not work with branching dialogs, or multiple questions

The API

To get the weather information, OpenWeatherMap API will be used. You can register for an API key.

The Bot

The bot is where the magic happens. It is code hosted externally to Teams that can be called over HTTP (via the Webhook). What that code does, where it is hosted, is all up to you. For this scenario, there is an Azure Function HTTP Trigger (written in TypeScript), which can be found here.

You are free to use the linked code as a basis for your own idea, or create your own code in your choice of programming language. The basic construct of a bot behaviour needs to be as follows:

  1. Authenticate request (using a token from Teams)
  2. Get weather information from API
  3. Send response to request. This MUST be a bot "Activity", with an attached Adaptive Card otherwise Teams will not handle the response correctly

Setup

The setup of this solution comprises of two parts:

  • Bot code accessible via HTTP
  • Outgoing Webhook in Teams

Bot

A Azure Function HTTP Trigger hosting the code is created. The URL of the trigger needs to be copied for the next step

image

Disregard the trailing question mark and any other text past this

Teams Webhook

To add an Outgoing Webhook, the following is done:

  1. Find the Team to host the Webhook

  2. Click the ellipsis (...) on the Team and choose Manage team

    image

  3. Under the Apps tab, at the bottom right of the page, there will be an option to Create an outgoing webhook

    image

  4. Provide the following:

    • Name: A short name that will be used to @ mention the Webhook. Keep it to one word if you can e.g. Weather

    • Callback URL: This is where the URL of the bot is entered (e.g. URL of the Azure Functions HTTP Trigger)

    • Description: A description of the purpose and functionality of the webhook e.g. Provides current and forecasted weather for any location

    • Icon: Image that will appear next to the Webhook

      image

  5. Once the Webhook is created, take a note of the Security token of the Webhook as it will only be shown once and will be required for authentication to the bot

    image

Configure Bot

With the bot and webhook created, one final step is to configure the bot. In this case, the following is added under Configuration on the Azure Function:

  • TeamsSecurityToken: The Security token from the Teams Outgoing Webhook. This is used for the bot to validate requests are from a trusted source (your Team)
  • WeatherAPIKey: The API key to grant access to the OpenWeatherMap API

image

To simplify this example, I have stored these in application settings. In a production environment, please ensure this is held somewhere more secure, such as Azure KeyVault references that can be accessed using Managed Identity

Demo time

With everything in place, all that is left is to try it! Simply mention the Webhook and enter a location, and the weather is returned!

demo

%3CLINGO-SUB%20id%3D%22lingo-sub-3064378%22%20slang%3D%22en-US%22%3EMake%20a%20bot%20for%20simple%20interactions%20in%20Teams%20using%20a%20Webhook%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3064378%22%20slang%3D%22en-US%22%3E%3CH2%20dir%3D%22auto%22%20id%3D%22toc-hId-335575225%22%20id%3D%22toc-hId-338262025%22%3E%3CA%20id%3D%22user-content-introduction%22%20class%3D%22anchor%22%20href%3D%22%23introduction%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%20aria-hidden%3D%22true%22%3E%20%3C%2FA%3EIntroduction%3C%2FH2%3E%0A%3CP%3EHave%20you%20ever%20had%20an%20idea%20to%20ask%20a%20bot%20to%20perform%20a%20%3CEM%3Esimple%20interaction%3C%2FEM%3E%3F%20Then%20this%20article%20is%20for%20you.%3C%2FP%3E%0A%3CP%3EA%20%3CEM%3Esimple%20interaction%3C%2FEM%3E%20could%20be%20an%20answer%20to%20a%20question%20you%20asked%3A%3C%2FP%3E%0A%3CUL%20dir%3D%22auto%22%3E%0A%3CLI%3E%3CSTRONG%3EYou%3A%3C%2FSTRONG%3E%20%3CEM%3EWhat%20time%20is%20it%3F%3C%2FEM%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EBot%3A%3C%2FSTRONG%3E%20%3CEM%3EIt's%203.56PM%3C%2FEM%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EYou%20could%20achieve%20this%20(and%20more)%20by%20building%20a%20bot%20using%20tools%20such%20as%20Power%20Virtual%20Agents%20or%20Bot%20Framework%2C%20but%20that%20is%20a%20little%20overkill%20for%20a%20simple%20interaction.%3C%2FP%3E%0A%3CP%3EInstead%2C%20let's%20use%20%3CSTRONG%3EWebhooks%3C%2FSTRONG%3E%20to%20achieve%20this.%3C%2FP%3E%0A%3CH2%20dir%3D%22auto%22%20id%3D%22toc-hId--1471879238%22%20id%3D%22toc-hId--1469192438%22%3E%3CA%20id%3D%22user-content-the-idea%22%20class%3D%22anchor%22%20href%3D%22%23the-idea%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%20aria-hidden%3D%22true%22%3E%20%3C%2FA%3EThe%20idea%3C%2FH2%3E%0A%3CP%3EBefore%20we%20begin%2C%20let's%20fictionalise%20a%20use%20case.%20The%20idea%20is%20that%20users%20need%20to%20quickly%20be%20able%20to%20check%20the%20current%20and%20forecasted%20for%20any%20location%20from%20within%20a%20Team.%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fuser-images.githubusercontent.com%2F472320%2F149214689-3bf95faa-11dc-466d-999d-731f41c6d8f3.png%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20nofollow%22%3E%3CIMG%20style%3D%22max-width%3A%20100%25%3B%22%20src%3D%22https%3A%2F%2Fuser-images.githubusercontent.com%2F472320%2F149214689-3bf95faa-11dc-466d-999d-731f41c6d8f3.png%22%20border%3D%220%22%20alt%3D%22image%22%20%2F%3E%3C%2FA%3E%3C%2FP%3E%0A%3CH2%20dir%3D%22auto%22%20id%3D%22toc-hId-1015633595%22%20id%3D%22toc-hId-1018320395%22%3E%3CA%20id%3D%22user-content-the-solution%22%20class%3D%22anchor%22%20href%3D%22%23the-solution%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%20aria-hidden%3D%22true%22%3E%20%3C%2FA%3EThe%20solution%3C%2FH2%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fuser-images.githubusercontent.com%2F472320%2F149226058-e5b23a26-ab06-4197-a93e-0343ee3fbbf6.png%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20nofollow%22%3E%3CIMG%20style%3D%22max-width%3A%20100%25%3B%22%20src%3D%22https%3A%2F%2Fuser-images.githubusercontent.com%2F472320%2F149226058-e5b23a26-ab06-4197-a93e-0343ee3fbbf6.png%22%20border%3D%220%22%20alt%3D%22image%22%20%2F%3E%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EThe%20solution%20is%20a%20Webhook%20in%20Teams%20and%20a%20Bot%20(surprised%3F).%20This%20works%20as%20follows%3A%3C%2FP%3E%0A%3COL%20dir%3D%22auto%22%3E%0A%3CLI%3EUser%20%40%20mentions%20the%20Webhook%20(same%20as%20a%20would%20any%20other%20bot)%20in%20a%20Team%20channel%3C%2FLI%3E%0A%3CLI%3EThis%20will%20trigger%20some%20external%20service%20(bot)%20HTTP%2C%20in%20this%20case%20an%20Azure%20Function%3C%2FLI%3E%0A%3CLI%3EThe%20external%20service%20(Bot)%20will%20call%20a%20weather%20API%20and%20then%20return%20the%20weather%20information%20to%20the%20Team%20channel%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3ELet's%20break%20this%20down%20by%20component.%3C%2FP%3E%0A%3CH3%20dir%3D%22auto%22%20id%3D%22toc-hId-1706195069%22%20id%3D%22toc-hId-1708881869%22%3E%3CA%20id%3D%22user-content-webhook%22%20class%3D%22anchor%22%20href%3D%22%23webhook%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%20aria-hidden%3D%22true%22%3E%20%3C%2FA%3EWebhook%3C%2FH3%3E%0A%3CP%3EA%20Webhook%20is%20a%20way%20for%20two%20applications%20that%20can%20communicate%20with%20each%20other.%20In%20our%20case%2C%20a%20simple%20bot%20and%20Teams.%3C%2FP%3E%0A%3CP%3ETeams%20supports%20two%20types%20of%20Webhooks%3A%3C%2FP%3E%0A%3CUL%20dir%3D%22auto%22%3E%0A%3CLI%3E%3CSTRONG%3EIncoming%20Webhook%3C%2FSTRONG%3E%20-%20An%20application%20sends%20a%20message%20to%20Teams%20using%20a%20Webhook%20address%20generated%20in%20Teams.%20This%20could%20be%20used%20if%20you%20wanted%20to%20automate%20some%20sort%20of%20alert%20or%20notification%20in%20to%20a%20Team%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EOutgoing%20Webhook%3C%2FSTRONG%3E%20-%20Teams%20sends%20a%20message%20(request)%20to%20a%20Webhook%20address%20created%20outside%20of%20Teams.%20The%20external%20Webhook%20address%20is%20an%20application%20that%20then%20responds%20to%20your%20request%20with%20message%20(response)%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EFor%20this%20solution%2C%20it%20is%20an%20%3CSTRONG%3EOutgoing%20Webhook%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CP%3EThere%20are%20some%20limitations%20to%20using%20a%20Webhook%20in%20Teams%2C%20so%20bear%20these%20in%20mind%20when%20choosing%20Webhooks%20for%20your%20own%20idea%3A%3C%2FP%3E%0A%3CUL%20dir%3D%22auto%22%3E%0A%3CLI%3EWebhooks%20are%20associated%20to%20a%20single%20Team.%20You%20cannot%20deploy%20the%20same%20Webhook%20to%20multiple%20Teams%20or%20outside%20of%20a%20Team%20(personal%20context)%3C%2FLI%3E%0A%3CLI%3EEverybody%20in%20the%20Team%20can%20see%20the%20interaction.%20If%20the%20interaction%20should%20be%20private%20(between%20the%20user%20and%20the%20bot)%2C%20this%20should%20not%20be%20used%3C%2FLI%3E%0A%3CLI%3EThis%20will%20work%20with%20a%20simple%20request%20and%20response%2C%20or%20question%20and%20answer.%20It%20will%20not%20work%20with%20branching%20dialogs%2C%20or%20multiple%20questions%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CH3%20dir%3D%22auto%22%20id%3D%22toc-hId--101259394%22%20id%3D%22toc-hId--98572594%22%3E%3CA%20id%3D%22user-content-the-api%22%20class%3D%22anchor%22%20href%3D%22%23the-api%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%20aria-hidden%3D%22true%22%3E%20%3C%2FA%3EThe%20API%3C%2FH3%3E%0A%3CP%3ETo%20get%20the%20weather%20information%2C%20%3CA%20href%3D%22https%3A%2F%2Fopenweathermap.org%2Fapi%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EOpenWeatherMap%20API%3C%2FA%3E%20will%20be%20used.%20You%20can%20register%20for%20an%20API%20key.%3C%2FP%3E%0A%3CH3%20dir%3D%22auto%22%20id%3D%22toc-hId--1908713857%22%20id%3D%22toc-hId--1906027057%22%3E%3CA%20id%3D%22user-content-the-bot%22%20class%3D%22anchor%22%20href%3D%22%23the-bot%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%20aria-hidden%3D%22true%22%3E%20%3C%2FA%3EThe%20Bot%3C%2FH3%3E%0A%3CP%3EThe%20bot%20is%20where%20the%20magic%20happens.%20It%20is%20code%20hosted%20externally%20to%20Teams%20that%20can%20be%20called%20over%20HTTP%20(via%20the%20Webhook).%20What%20that%20code%20does%2C%20where%20it%20is%20hosted%2C%20is%20all%20up%20to%20you.%20For%20this%20scenario%2C%20there%20is%20an%20Azure%20Function%20HTTP%20Trigger%20(written%20in%20TypeScript)%2C%20which%20can%20be%20found%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fleeford%2Fteams-webhook-weatherbot-sample%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3EYou%20are%20free%20to%20use%20the%20linked%20code%20as%20a%20basis%20for%20your%20own%20idea%2C%20or%20create%20your%20own%20code%20in%20your%20choice%20of%20programming%20language.%20The%20basic%20construct%20of%20a%20bot%20behaviour%20needs%20to%20be%20as%20follows%3A%3C%2FP%3E%0A%3COL%20dir%3D%22auto%22%3E%0A%3CLI%3EAuthenticate%20request%20(using%20a%20token%20from%20Teams)%3C%2FLI%3E%0A%3CLI%3EGet%20weather%20information%20from%20API%3C%2FLI%3E%0A%3CLI%3ESend%20response%20to%20request.%20This%20%3CSTRONG%3EMUST%3C%2FSTRONG%3E%20be%20a%20bot%20%22Activity%22%2C%20with%20an%20attached%20Adaptive%20Card%20otherwise%20Teams%20will%20not%20handle%20the%20response%20correctly%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CH2%20dir%3D%22auto%22%20id%3D%22toc-hId--1919216961%22%20id%3D%22toc-hId--1916530161%22%3E%3CA%20id%3D%22user-content-setup%22%20class%3D%22anchor%22%20href%3D%22%23setup%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%20aria-hidden%3D%22true%22%3E%20%3C%2FA%3ESetup%3C%2FH2%3E%0A%3CP%3EThe%20setup%20of%20this%20solution%20comprises%20of%20two%20parts%3A%3C%2FP%3E%0A%3CUL%20dir%3D%22auto%22%3E%0A%3CLI%3EBot%20code%20accessible%20via%20HTTP%3C%2FLI%3E%0A%3CLI%3EOutgoing%20Webhook%20in%20Teams%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CH3%20dir%3D%22auto%22%20id%3D%22toc-hId--1228655487%22%20id%3D%22toc-hId--1225968687%22%3E%3CA%20id%3D%22user-content-bot%22%20class%3D%22anchor%22%20href%3D%22%23bot%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%20aria-hidden%3D%22true%22%3E%20%3C%2FA%3EBot%3C%2FH3%3E%0A%3CP%3EA%20Azure%20Function%20HTTP%20Trigger%20hosting%20the%20code%20is%20created.%20The%20URL%20of%20the%20trigger%20needs%20to%20be%20copied%20for%20the%20next%20step%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fuser-images.githubusercontent.com%2F472320%2F149174368-58562d12-5554-4625-a902-0df103e00cff.png%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20nofollow%22%3E%3CIMG%20style%3D%22max-width%3A%20100%25%3B%22%20src%3D%22https%3A%2F%2Fuser-images.githubusercontent.com%2F472320%2F149174368-58562d12-5554-4625-a902-0df103e00cff.png%22%20border%3D%220%22%20alt%3D%22image%22%20%2F%3E%3C%2FA%3E%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3EDisregard%20the%20trailing%20question%20mark%20and%20any%20other%20text%20past%20this%3C%2FP%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CH3%20dir%3D%22auto%22%20id%3D%22toc-hId-1258857346%22%20id%3D%22toc-hId-1261544146%22%3E%3CA%20id%3D%22user-content-teams-webhook%22%20class%3D%22anchor%22%20href%3D%22%23teams-webhook%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%20aria-hidden%3D%22true%22%3E%20%3C%2FA%3ETeams%20Webhook%3C%2FH3%3E%0A%3CP%3ETo%20add%20an%20Outgoing%20Webhook%2C%20the%20following%20is%20done%3A%3C%2FP%3E%0A%3COL%20dir%3D%22auto%22%3E%0A%3CLI%3E%3CP%3EFind%20the%20Team%20to%20host%20the%20Webhook%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3EClick%20the%20ellipsis%20(...)%20on%20the%20Team%20and%20choose%20%3CSTRONG%3EManage%20team%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fuser-images.githubusercontent.com%2F472320%2F149214507-8e0f6fac-4fc7-4901-b121-4cdab13d7aae.png%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20nofollow%22%3E%3CIMG%20style%3D%22max-width%3A%20100%25%3B%22%20src%3D%22https%3A%2F%2Fuser-images.githubusercontent.com%2F472320%2F149214507-8e0f6fac-4fc7-4901-b121-4cdab13d7aae.png%22%20border%3D%220%22%20alt%3D%22image%22%20%2F%3E%3C%2FA%3E%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3EUnder%20the%20%3CSTRONG%3EApps%3C%2FSTRONG%3E%20tab%2C%20at%20the%20bottom%20right%20of%20the%20page%2C%20there%20will%20be%20an%20option%20to%20%3CSTRONG%3ECreate%20an%20outgoing%20webhook%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fuser-images.githubusercontent.com%2F472320%2F149138950-b86db5c1-cef7-4334-bd3e-c52f90a49e75.png%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20nofollow%22%3E%3CIMG%20style%3D%22max-width%3A%20100%25%3B%22%20src%3D%22https%3A%2F%2Fuser-images.githubusercontent.com%2F472320%2F149138950-b86db5c1-cef7-4334-bd3e-c52f90a49e75.png%22%20border%3D%220%22%20alt%3D%22image%22%20%2F%3E%3C%2FA%3E%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3EProvide%20the%20following%3A%3C%2FP%3E%0A%3CUL%20dir%3D%22auto%22%3E%0A%3CLI%3E%3CP%3E%3CSTRONG%3EName%3C%2FSTRONG%3E%3A%20A%20short%20name%20that%20will%20be%20used%20to%20%40%20mention%20the%20Webhook.%20Keep%20it%20to%20one%20word%20if%20you%20can%20e.g.%20%3CEM%3EWeather%3C%2FEM%3E%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3E%3CSTRONG%3ECallback%20URL%3C%2FSTRONG%3E%3A%20This%20is%20where%20the%20URL%20of%20the%20bot%20is%20entered%20(e.g.%20URL%20of%20the%20Azure%20Functions%20HTTP%20Trigger)%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3E%3CSTRONG%3EDescription%3C%2FSTRONG%3E%3A%20A%20description%20of%20the%20purpose%20and%20functionality%20of%20the%20webhook%20e.g.%20%3CEM%3EProvides%20current%20and%20forecasted%20weather%20for%20any%20location%3C%2FEM%3E%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3E%3CSTRONG%3EIcon%3C%2FSTRONG%3E%3A%20Image%20that%20will%20appear%20next%20to%20the%20Webhook%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fuser-images.githubusercontent.com%2F472320%2F149214338-c8217ed4-bdb9-468d-be26-ccac553a735f.png%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20nofollow%22%3E%3CIMG%20style%3D%22max-width%3A%20100%25%3B%22%20src%3D%22https%3A%2F%2Fuser-images.githubusercontent.com%2F472320%2F149214338-c8217ed4-bdb9-468d-be26-ccac553a735f.png%22%20border%3D%220%22%20alt%3D%22image%22%20%2F%3E%3C%2FA%3E%3C%2FP%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3EOnce%20the%20Webhook%20is%20created%2C%20take%20a%20note%20of%20the%20%3CSTRONG%3ESecurity%20token%3C%2FSTRONG%3E%20of%20the%20Webhook%20as%20it%20will%20only%20be%20shown%20once%20and%20will%20be%20required%20for%20authentication%20to%20the%20bot%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fuser-images.githubusercontent.com%2F472320%2F149213977-50ff69b7-cb4a-44fb-bfc6-277e8214a605.png%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20nofollow%22%3E%3CIMG%20style%3D%22max-width%3A%20100%25%3B%22%20src%3D%22https%3A%2F%2Fuser-images.githubusercontent.com%2F472320%2F149213977-50ff69b7-cb4a-44fb-bfc6-277e8214a605.png%22%20border%3D%220%22%20alt%3D%22image%22%20%2F%3E%3C%2FA%3E%3C%2FP%3E%0A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CH3%20dir%3D%22auto%22%20id%3D%22toc-hId--548597117%22%20id%3D%22toc-hId--545910317%22%3E%3CA%20id%3D%22user-content-configure-bot%22%20class%3D%22anchor%22%20href%3D%22%23configure-bot%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%20aria-hidden%3D%22true%22%3E%20%3C%2FA%3EConfigure%20Bot%3C%2FH3%3E%0A%3CP%3EWith%20the%20bot%20and%20webhook%20created%2C%20one%20final%20step%20is%20to%20configure%20the%20bot.%20In%20this%20case%2C%20the%20following%20is%20added%20under%20%3CSTRONG%3EConfiguration%3C%2FSTRONG%3E%20on%20the%20Azure%20Function%3A%3C%2FP%3E%0A%3CUL%20dir%3D%22auto%22%3E%0A%3CLI%3E%3CSTRONG%3ETeamsSecurityToken%3C%2FSTRONG%3E%3A%20The%20%3CSTRONG%3ESecurity%20token%3C%2FSTRONG%3E%20from%20the%20Teams%20Outgoing%20Webhook.%20This%20is%20used%20for%20the%20bot%20to%20validate%20requests%20are%20from%20a%20trusted%20source%20(your%20Team)%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EWeatherAPIKey%3C%2FSTRONG%3E%3A%20The%20%3CSTRONG%3EAPI%20key%3C%2FSTRONG%3E%20to%20grant%20access%20to%20the%20OpenWeatherMap%20API%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fuser-images.githubusercontent.com%2F472320%2F149180772-e8942bd0-217d-4ee9-b734-9f1910ad2535.png%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20nofollow%22%3E%3CIMG%20style%3D%22max-width%3A%20100%25%3B%22%20src%3D%22https%3A%2F%2Fuser-images.githubusercontent.com%2F472320%2F149180772-e8942bd0-217d-4ee9-b734-9f1910ad2535.png%22%20border%3D%220%22%20alt%3D%22image%22%20%2F%3E%3C%2FA%3E%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3ETo%20simplify%20this%20example%2C%20I%20have%20stored%20these%20in%20application%20settings.%20In%20a%20production%20environment%2C%20please%20ensure%20this%20is%20held%20somewhere%20more%20secure%2C%20such%20as%20Azure%20KeyVault%20references%20that%20can%20be%20accessed%20using%20Managed%20Identity%3C%2FP%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CH2%20dir%3D%22auto%22%20id%3D%22toc-hId-1114669518%22%20id%3D%22toc-hId-1117356318%22%3E%3CA%20id%3D%22user-content-demo-time%22%20class%3D%22anchor%22%20href%3D%22%23demo-time%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%20aria-hidden%3D%22true%22%3E%20%3C%2FA%3EDemo%20time%3C%2FH2%3E%0A%3CP%3EWith%20everything%20in%20place%2C%20all%20that%20is%20left%20is%20to%20try%20it!%20Simply%20mention%20the%20Webhook%20and%20enter%20a%20location%2C%20and%20the%20weather%20is%20returned!%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fuser-images.githubusercontent.com%2F472320%2F149221643-96f50590-dd93-4616-83f5-98ff9d219a4b.gif%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20nofollow%22%3E%3CIMG%20style%3D%22max-width%3A%20100%25%3B%22%20src%3D%22https%3A%2F%2Fuser-images.githubusercontent.com%2F472320%2F149221643-96f50590-dd93-4616-83f5-98ff9d219a4b.gif%22%20border%3D%220%22%20alt%3D%22demo%22%20%2F%3E%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-3064378%22%20slang%3D%22en-US%22%3E%3CP%3EHave%20you%20ever%20had%20an%20idea%20to%20ask%20a%20bot%20to%20perform%20a%20%3CEM%3Esimple%20interaction%3C%2FEM%3E%3F%20Then%20this%20article%20is%20for%20you.%3C%2FP%3E%0A%3CDIV%20id%3D%22lia-teaserTinyMceEditorLuiseFreese_0%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Co-Authors
Version history
Last update:
‎Jan 18 2022 05:06 AM
Updated by: