Power Automate: How to Generate a Scheduled Message into a Teams Chat (Not Channel!)

Your NOC team always forgets to fill in the shift report (I love you guys really) so you really just want to give them a nudge in your Microsoft Teams group chat (or ‘conversation’) to send that decrepit report on time for the next shift.

Power Automate is your hero. N.B. this could probably be replicated with Azure Logic Apps, though I am yet to try. Let me know in the comments if you’ve done it!

Our aim: Schedule an automated message to be sent into a teams conversation.

Table of Contents

Getting Started

Flow Summary

Step 1: Setting the Recurrence

Step 2: Generating the Skype Token

Step 3: Parsing the Authenticated Info

Step 4: Posting the Message into Teams Chat

Output and Troubleshooting

Getting Started

Pre-requisites (please read carefully):
1. Power Automate Community Licence (Wait don’t fret! This is a workaround that I definitely do not recommend nor am I advocating, but definitely does work) – we will be using Premium connectors here to be able to leverage Azure AD!
2. An Azure AD Connected Account (To create a connection for our AAD calls)

About the Power Automate Community Licence:
So as I mentioned, it does work. It’s a free environment for individual use. However, as Microsoft mention: “The Power Apps Community Plan gives you a free development environment for individual use” and also that “There is a limited capacity provided because this environment is meant for individual use, not for a team or production use.”. So I’m definitely not advocating it, but use at your own risk if deployed to production environments.

To sign-up with your work or school account:
Power Apps Community Plan | Microsoft Power Apps

Once you’re done, it’ll appear like this at the top of your power automate screen:(make.powerapps.com)

If you don’t have ‘Power Apps for Office 365’ showing, I don’t think this is an issue. We just happen to be using Office 365 here and that comes with it. We really just care about the Power Apps Community Plan.

Flow Summary

The Flow can be broken down into 4 steps as we can see in the flow diagram below:

Flow Summary:
1. Initiate the recurrence, according to a set time
2. Generate a Skype Token which will Authenticate your account against Azure AD (to be able to send the message into the teams chat in your work/school environment)
3. Parse the information you got in Step 2 (break down the information in Step 2 into nice chunks to be able to pull out the Skype Token)
4. Post the message into the teams chat, authenticating yourself with the skype token from the previous step

Simple right?

Step 1: Setting the Recurrence

From your flows blade in the Power Automate centre, click the ‘New’ drop-down menu and select the ‘Scheduled–from blank’ flow.

Choose a name for your flow, when you want the flow to start and how often you want it to repeat. The helper at the bottom tells you how often it will run. If you want it to run multiple times a day, then choose to repeat every few hours. Once done, hit Create.

If you want even finer control, such as specific hours of the day you want the flow to run (i.e. different gaps between each run), then within this flow step you can change the frequency to ‘Day’ and adjust the specific hours you want it to run.

Step 2: Generating the Skype Token (for Authentication)

We now want to add another step. Underneath the recurrence, click ‘+’. Search for the ‘Invoke an HTTP request’ under the HTTP with Azure AD action. This action will need to be initiated with an Azure AD connection and we will create this in the next step.

Once found, click the 3 dots on the top right of the flow step and add a new connection, found at the bottom of the sub-menu under ‘My Connections’. We should take this time to rename this flow step so we know what’s going on.

Step 2’s connection we’ll call Connection 1 – this will link us with Teams. The Base Resource URL and the Azure AD Resource URI should be the same: https://teams.microsoft.com/
Then sign in with your work/school AAD account.

Choose the ‘POST’ Method within the step and the Request URI: https://teams.microsoft.com/api/authsvc/v1.0/authz

This will generate the Skype Token for authentication.

Whilst we’re here, we need to generate a JSON Schema in our next step. So we need a sample from which to create the schema. To do this, test your flow by clicking ‘Test’ on the top right of your page.

Click on the flow runs page to see the output and click on the 2nd Step of the flow to see its output (below).

The information here is very important. Copy the information from the Body box and keep this to hand – we’ll be using this to generate our schema (this is our ‘sample’). Note also the region in the same box. Mine is Amer, which represents North, Central and South America – we’ll go into more detail on how we will use this information in the next step.

Step 3: Parsing the Authenticated Information to Retrieve the Skype Token

Now, create another step (Step 3) below the HTTP request (which was Step 2). Search for the ‘Parse JSON’ Data Operation action. This step will help us section out all the parts of the information from Step 2 and help us isolate the skype token which we’ll need for Step 4.

The content we’ll be parsing will be the ‘Body’ of the information from Step 2, nicely laid out for us under the Dynamic Content pop-up window. Click ‘Body’.

We’ll now need to generate a schema – but before we do this, we need a sample which as I mentioned was the ‘Body’ of information you copied from the previous step. Click ‘Generate from Sample’.

Paste in the copied body text from Step 2 and click done. It will look like this:

Step 4: Posting the Message into the Teams Chat

This is the last step to add to our flow. Create another Invoke An HTTP Request from a new Azure AD Action. Rename this stating you’re using a New Connection.

It is imperative that you create a new connection for this step as it will use a different URI. Firstly, we’ll need to find the new Base Resource URL as this will differ based on your region. If you remember previously, the Body of the output on Step 2 told us our region. So using this, your Base Resource URL will be one of the following:

For me, it’s ‘AMER’ so my Base Resource URL is https://amer.ng.msg.teams.microsoft.com

Also, the Azure AD Resource URI is https://teams.microsoft.com/

Next we need the Conversations ID which we can find from the web version of teams, in the URL. This will form part of the Request URL. Simply click on the chat in question in the web version of teams (go to teams.microsoft.com and click on the conversation of choice) and copy the URL at the top of the browser. This will be of the form:

Then grab the bit after ‘Conversations’ up until ‘thread.v2’. This is our Conversation ID.


We also need to change the symbols into its Ascii conversion (Hex) so it works in our flow. Here, this means we need to change : and @ to %3A and %40 respectively which gives us:


Then we need to put it into the following form with its conversions, noting our region at the beginning (this will form our Request URL for the step):


As such:


This final code above is your Request URL. Ensure the Method is POST. Set the Header as Authentication with the parsed SkypeToken from Step 3 as its value. Finally the content can be written in Markdown as you see on the left!

Output and Troubleshooting

Here is the final output within teams:

Just as aggressive as I wanted it to be. I have seen some issues so I’ve noted common errors and troubleshooting steps below for you to keep an eye out for:

  • ‘BaseResourceUri ‘x’ must be a base of the full url ‘y’:

    Make sure the BaseResourceUri (https://teams.microsoft.com) is a base of the full url for example: (https://amer.ng.msg.teams.microsoft.com/v1/users/ME/conversations/19:xxxxxxxxxxxx92… etc.

    As mentioned in Step 4, we need to use a second connection for this step. This error above effectively means we’ve used the wrong connection for the wrong step. In essence, ensure Step 1 uses Connection 1 and Step 4 uses Connection 2.

    So this error effectively means the connection used in the second ‘Invoke an HTTP Request’ action is still using the connection for first ‘Invoke an HTTP Request’.

Published by Adil

Editor-in-chief or whatever it's called. I like Cloud. I also like Earth.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: