Let’s Work Together



How to create Interactive Bot using Microsoft Teams?

Nowadays Microsoft Teams becoming an essential communication tool for everyday’s work for many of us. Suppose the team’s channel works like a Bot and solves our queries, it would be great, right? 

Imagine, if you have written on a team channel something like “Hey Bot, what is the status of xyz process?” and then you will get an answer like “The xyz process is in progress ” or “The xyz process is completed.” or “The xyz process has failed.” How cool is that? This process can be ETL ingestion, data transfer, the status of NiFi workflow, anything which has different stages and we want updates about those stages.

Microsoft Teams has one cool feature, an Outgoing Webhook. Outgoing webhook gives a simple way to create interactive conversational Bot. This works like a bot without being a real bot and searches for the messages in the channel using @mention, sending notifications to external web services and responding with rich messages that can include text, cards and images.

In this blog, we will check how to create a basic bot using Microsoft teams outgoing webhook and AWS cloud. 

Note –

  1. Outgoing webhook are scope at the team level.
  2. Currently not supported in the private channel.

Outgoing Webhook Integration with AWS –

Outgoing Webhooks sends an HTTP POST to a web service and gets a response.  Let’s create a web service using AWS API Gateway and Lambda

API Gateway is a fully managed service of the AWS that helps to create RESTful APIs and WebSocket APIs that enable real-time two-way communication applications and by using lambda will write serverless code which will send responses to outgoing webhook. 

Let’s create lambda function –

  1. Sign in to AWS and open lambda service.
  2. Click on Create Function. Give the function name. In the runtime select the latest version of python and keep the other properties as it is.
  3. The default lambda function code should look like this.

Create AWS API Gateway –

  1. Open API Gateway service.
  2. Click on the Create API button and build HTTP API. API Gateway also supports REST APIs and WebSocket APIs, but an HTTP API is the best choice for this exercise.
  3. For integration, choose the lambda function which was created earlier and give the name to your API. 
  1. Now configure routes, select the method as POST and give the resource path. 
  1. Configure the stage as Auto-deploy and click on next.
  1. Review the configurations and click on create.

Now you’ve created an HTTP API with a Lambda integration that’s ready to receive requests from outgoing webhook.

Create Outgoing Webhook in Microsoft Teams –  

  1. Open the teams tab from the left pane of teams application.
  2. Select team channel where you want to add the outgoing webhook. Click the ellipses beside the Team Name and select Manage Team from the dropdown.
  3. On the Apps tab, click Create an outgoing webhook in the bottom right corner.
  1. Fill out details to create the outgoing webhook. i.e. Name of the outgoing webhook, in the callback URL add the API gateway URL, description and profile picture. 
  1. Then click on the Create button. Now you will get a security token which will appear only once, so copy it and save it to a safe place. This security token will need to verify the message coming from a trusted source or not and it does not expire.

Now outgoing webhook added into the teams channel.

Test your Bot – 

Once an outgoing webhook is added to a team, it acts like a bot, listening in channels for messages using @mention. 

Since we have given the webhook name as bot, we can call simply by using a mention like @bot:

At the back end the lambda function is triggered through API gateway and the code is executed in the AWS cloud and a response is sent back to Microsoft Teams.

You can do more than this. You can send Adaptive cards, images, Hero cards, and text messages as attachments with an Outgoing Webhook.

Quite quick and useful right! What do you think?



Data Engineer with hands-on experience of 4 years. Passionate and curious about working on new technologies and helping businesses to select the right enterprise tools.

Add Comment