Introduction
In this post, I’ll share how I automated interactions with a Microsoft Teams bot using the MS Graph API and Power Automate. To demonstrate the process, I worked with "Billy - The Birthday Bot," which has two simple commands: "help" and "upcoming." While your bot's commands might differ, the process remains adaptable.
I relied heavily on
this video on YouTube by Dennis Goedegebuure | @expiscornovus
Mention a bot from a Power Automate flow
Step 1: Setting Up the Bot
I started by installing "Billy - The Birthday Bot" in my DEV Tenant, and added it to the "Sales and Marketing" Team and the "General" channel. You’ll want to ensure that your bot is installed in a similar environment for testing purposes.
Step 2: Testing MS Graph API
To interact with the bot programmatically, I tested various MS Graph API endpoints using the Graph Explorer tool. Here's what I did:
a) Accessing MS Graph Explorer

b) Locating Teams API Calls
Explore the API calls available for Microsoft Teams within the Graph Explorer tool.

c) Retrieving the Team ID using "my joined teams"
I called the API endpoint https://graph.microsoft.com/v1.0/me/joinedTeams to retrieve the teams I’ve joined. After consenting to the required permissions, I received a "200" response. I then searched for "Sales and Marketing" in the response (using CTRL-F) to find the team ID.
d) Retrieving the Channel ID using "channels of a team which I am a member of"
Next, I used the team ID to call the API endpoint https://graph.microsoft.com/v1.0/teams/{team-id}/channels. After consenting to permissions, I located the "General" channel and obtained its ID.
e) Retrieving the Bot Details using "apps in a team"
Using the API endpoint https://graph.microsoft.com/v1.0/teams/{team-id}/installedApps?$expand=teamsAppDefinition, I retrieved the details of the installed apps (bots) in the team. I searched for "Billy - The Birthday Bot" and found this section of the response:
{ "id": "NOT THIS VALUE", "consentedPermissionSet": null, "teamsAppDefinition": { "id": "NOT THIS VALUE", "teamsAppId": "NOT THIS VALUE", "displayName": "Billy - The Birthday Bot", "version": "1.1.1", "publishingState": "published", "shortDescription": "Automate birthdays and work anniversaries celebrations 🎉", "description": "**How it works?**\", "lastModifiedDateTime": null, "createdBy": null, "authorization": { "clientAppId": "<<<<----- THIS ONE IS THE ID TO USE", "requiredPermissionSet": { "resourceSpecificPermissions": [] } } } |
|
Get the clientAppId. That is the value you want under "authorization". It is crucial for interacting with the bot.
f) Sending a Test Message using "send channel message"
I sent a test message to the "General" channel using the API endpoint https://graph.microsoft.com/v1.0/teams/{team-id}/channels/{channel-id}/messages. I set the method to POST and added a basic "Hello World" message. After consenting to the necessary permissions, I confirmed the message was successfully sent
g) Messaging the Bot
Finally, I sent a command to "Billy - The Birthday Bot" using the Client App ID from above and the following JSON body:
{ "body": { "contentType": "html", "content": "<div><div><at id=\"0\">Billy - The Birthday Bot</at> help</div></div>" }, "mentions": [ { "id": 0, "mentionText": "Billy - The Birthday Bot", "mentioned": { "device": null, "user": null, "conversation": null, "tag": null, "application": { "id": "INSERT THE clientAppId HERE", "displayName": "Billy - The Birthday Bot", "applicationIdentityType": "bot" } } } ] } |
In the Teams channel, I saw my post and a reply from Billy.
Step 3: Automating API Calls with Power Automate
a) Creating the Flow
I replicated the successful MS Graph API call in Power Automate. I set the URI, method (POST), and JSON body (including the bot @mention) identical to my test.

The "Send a Microsoft Graph HTTP request" Action is from the MS Teams Actions in Power Automate and should not require a Premium License (at the time of this post).
b) Testing the Flow
I sent the bot command using the Power Automate flow, and Billy promptly replied to the post in the Teams channel.
Success!
Conclusion
With MS Graph API and Power Automate, I streamlined bot interactions in Microsoft Teams. Whether you’re sending messages or automating other tasks, this approach can save time and simplify workflows. Try it out with your own Teams bot and explore the possibilities!
This community is supported by individuals freely devoting their time to provide support. They do it to let you know you are not alone. This is a community.
If someone has been able to answer your questions or solve your problem, please click Does this answer your question. This will help others who have the same question find a solution quickly via the forum search.
If someone was able to provide you with more information that moved you closer to a solution, throw them a Like. It might make their day. 😊