Create an AI Chatbot on a Microsoft Teams Channel with Power Automate! — A Step-by-Step Guide

Jazz Lien
6 min readNov 9, 2023

--

Generated by Leonardo.Ai

This article introduces how to create an AI Chatbot on a Microsoft Teams channel using a powerful automation tool — Power Automate.

Power Automate allows users to design and execute automated workflows with ease using drag-and-drop functions and parameter settings, enabling the creation of an intelligent chatbot effortlessly.

Follow this step-by-step guide to learn how to use Power Automate’s features in conjunction with the Azure OpenAI service on the Azure platform. Soon, members in your Teams channel will be able to call upon and utilize the Chatbot, giving everyone an AI assistant!

This implementation spans across three platforms, and I will divide it into three main phases for explanation, as follows:

  1. Data Preparation
  2. Building Power Automate Flow
  3. Testing the Flow

#1 Data Preparation Phase

We will demonstrate how to gather the necessary data on each platform during this phase. If you already have the required data, such as a Teams channel or the key to the Azure OpenAI resource, you may skip this stage and proceed to the next phase of building the workflow.

Power Automate

Azure OpenAI Resource

We need access to the Key and Endpoint of the Azure OpenAI resource.

  • Go to the resource’s “Keys and Endpoint”
  • Copy and save the Key value for later use
  • Enter Azure OpenAI Studio
  • Model Deployment: The model used for this demonstration is “gpt-3.5-turbo-instruct” (currently available only in regions: East US and Sweden Central). After deployment, go to “Playground” under “Completions”
  • Click on “View code,” copy the “Endpoint” and save it for later use

Microsoft Teams

Create a basic test channel. It’s a simple demonstration on how to create a new channel, you can also adjust according to your needs.

  • Click on “Create team” in Teams
  • Choose “From scratch”
  • Choose “Private”
  • Name the channel of your choice, I name it “ChatGPT”.
  • Ensure the channel is successfully created

#2 Building Power Automate Flow Phase

Once the data is prepared, we can start building our AI Chatbot!

  • First, go to Power Automate
  • Click on “My flows” on the left and create an “Automated cloud flow”
  • Give the flow a name, and for the trigger, choose “When keywords are mentioned”
  • Choose to execute in a “Channel” and set the keyword. I’m using “ChatGPT” here, then select the channel to execute in. After completion, click “+ New step”
  • Search and select “Get message details,” choose “Message ID” for the message field, and “Reply to message ID” for the Parent message ID field. Then click “Add an action”
  • Search and select “HTTP,” which also requires a PREMIUM account. You can apply for a trial account first and later decide if you want to apply for a subscription.
  • For the Method, choose “POST,” paste the “Endpoint” saved earlier, and add two Headers: “api-key” and “Accept”
  • Paste the Key value in the value of “api-key”, and add “application/json” to the Accept header
  • In the Body part, the value for “prompt” needs to include “Body Content”
  • After completion, click “Add an action.”
  • Search and select “Reply with a message in a channel,”
  • Choose “Reply to message ID” for the Message ID field.
  • For the Message part, select “Expression” and we want to extract only the text part of the ChatGPT model’s response, add the value:
body('HTTP')['choices'][0]?['text']

Once the above steps are completed, click “Save,” and our AI Chatbot is all set!

Now let’s go to the Teams channel and test it out!

#3 Testing the Flow Phase

Go to the designated channel and add “ChatGPT” (or the keyword you chose) before the message you send.

The model will then generate a reply (completions) based on the prompt you provided!

We can also return to Power Automate and click on “Flow checker” to see if the automation has been successfully executed.

Conclusion

This article has shown how to easily create a powerful AI Chatbot in a Microsoft Teams channel without writing any code, just by dragging and dropping with Power Automate’s tools and setting parameters, we experienced the convenience of Power Automate as an automation tool and its powerful functionality when combined with Azure OpenAI service.

Now, your Teams channel has an AI assistant on standby, ready to answer queries, execute commands, and interact in various ways.

Go and experience the changes what AI can bring to our world!

Thank you so much for reading my article, feedback is welcome!

Feel free to leave any feedback in the comments😀

If you like the article, please don't forget to give me claps, thank you!👏👏👏

--

--

Jazz Lien

AI | Azure | Cloud | Python | 5x Microsoft Azure Certified