Simple Workflow to Replace Teams Incoming Webhooks
Replacing Teams Connectors
As you may be aware, Teams connectors have been deprecated (as discussed in Retirement of Office 365 connectors within Microsoft Teams). This means that a change to the connector URL must be made by December 31, 2024 (more information forthcoming) and that you should not create new webhooks by August 15th, 2024. After August 15th, 2024, you should be using the Power Automate Workflows app in Teams instead of webhooks.
The connectors are being retired for several reasons, including security, scalability and flexibility. These are all requests our customers have made repeatedly in the past.
Power Automate workflows are powerful 5th generation programs which use a drag-and-drop, graphical user interface (GUI) paradigm to allow powerful data transformations and selective publishing to Teams. There is a lot of information for Power Automate Workflow at Browse and add workflows in Microsoft Teams – Microsoft Support.
This article is not meant to make you an expert on Power Automate or Workflows. There are plenty of articles for you to read to become an expert. I just wanted to create an article on how you can recreate the original webhook experience. From there, you should be able to experiment with the new capabilities Workflows provide.
Replacing an Incoming Webhook
To replace the incoming connector, I’m going to start by creating a new team in my test tenant. All of this will be done using the Teams Web Client (because it’s easier for me to work with at present).
From the Teams blade, I’ll press the ‘+’ symbol and choose ‘Create team.’
I’ll name my team a really thought-provoking name like ‘Webhook-Replace’ and give it an awesome description. I’ll then click on the ‘Create’ button.
Teams will congratulate me for making such a great team with a great team name and ask me to add new members. I’ll add my System Admin account (just to make it easier for that account to delete this later) and Teams will drop me in the ‘General’ channel for this tab (all teams will have a default ‘General’ tab). Since it doesn’t matter to me where I make this webhook replacement, I’m fine with the General tab so I’ll just use it and not add another channel [Important Note: At the time I’m writing this, private channels do not work with Power Automate Workflows. My understanding is that they are working to expand Workflows to include private channels, but that work isn’t completed yet.]
Install Power Automate Workflows
Now, I need to install Power Automate Workflows into Teams. To do this, I’ll click on the ‘Apps’ button on the far-left vertical bar which will open up the apps I have available to install [Note: This list will be limited based on the App permission and App setup policies and/or App Centric Management. For App permission policies, if you don’t see Workflows in the Apps section, you need to discuss availability of this app with your Teams Administrator. Even if it appears in your apps, you may need to REQUEST the app in order to install it, depending on these policies. For App Centric Management, the App will need to be assigned to you in order to use it] In the apps application that opens up, you can type ‘Workflows’ in the ‘Search apps and more’ textbox to quickly find the app.
Click the ‘Add’ or ‘Install’ button. This will open the Workflows setup/information dialog. From here, you can do a few things. If you just click the ‘Add’ button, it will install/add the app as a ‘one-on-one chat app’. This is actually what I want, so that it allows me to determine as I design the workflow, how it acts. For a webhook replacement, this is what I recommend. You can use the down carat and choose to add to a team, chat or meeting but I will leave you to experiment with these features.
This adds the ‘Workflows’ app to the far-left application bar and opens the application.
This is the Workflows App in Teams. Personally, I don’t like using it because it will occasionally make suggestions or assumptions that go beyond what I really want to do. So, I almost always use the ‘open in browser’ option from the upper right.
This opens up the full Power Automate flow page. From the left, I’m going to choose the ‘Templates’ blade.
In the ‘Search templates’, I’ll enter ‘Teams Webhook’ and hit enter to find the webhook templates.
As you can see, you can start with a Teams template. The recommended template to begin with is ‘Post to a chat when a webhook request is received’ so that is what I will use here. We’ll change it after opening it and I’ll explain all of this in a moment.
Choosing the template opens the flow connection. The ‘This flow will connect to:’ should be pre-populated with your username and contain a green checkmark.
Click on ‘Continue’ and the flow will ask you which team and channel you wish to send to. Here, I’m going to use the dropdown to select ‘Webhook-Replace’ from my list of Teams. Then, I’ll choose the ‘General’ channel and choose to ‘Edit in advanced mode.’ You could simply choose ‘Create’ but that will automatically create the flow and we’ll need to edit it anyway.
Clicking ‘Edit in advanced mode’ will display the current flow template.
By default, this flow will take whatever is sent to the webhook and attempt to send it as an adaptive card. Generally, this won’t work. You need to do some transformation on the data, unless the application is sending an Adaptive Card – which most providers don’t do. Instead, most providers such as GitHub, send a JSON filled with data and events.
Going through how to connect GitHub is out of scope for this article, though I may follow up with a GitHub case in a new article later. Likewise, creating an adaptive card to present in the Teams channel is outside the scope of this article. I’m just going to show you a simple JSON dataset and how to send it to a channel. For this, I’m going to use a very simple CURL commandline (from Windows) with a very small, easy JSON payload.
It’s just a lame payload with text and ‘hello world’ but this is just an article to show a simple webhook replacement.
First, we need to get the URL from the ‘When a Teams webhook request is received’ step. Click on that step and it will open up the settings for the step. Copy the HTTP URL and place it in a safe place. (For me, I’ll use it in the Powershell curl.exe I have copied and pasted above).
Even though the JSON payload here is simplistic, I still need to have the flow process it. In order to do that, I’m going to need to add something to this flow. So, I’ll choose the ‘+’ button between the two existing flow steps (because I need to parse the JSON between those two steps) and choose to ‘Add an action’.
This opens the ‘Add an action’ popup on the left side. We want to process json, so I’ll enter ‘JSON’ in the search bar and look at my options. I see that ‘Data Oepration’ has a ‘Parse JSON’ option, so I’m going to choose that by clicking on it.
This adds the action between the two steps, exactly like I wanted.
This also opens the ‘Parse JSON’ settings because I still need to instruct this flow step on how to process the JSON content.
I’ll click in the ‘Content’ textbox. This will bring up the ‘actions’ choices on the right side of the textbox.
The lightning bolt means ‘Dynamic Content’. The ‘fx’ stands for formulas or expressions. I want to process Dynamic Content coming from the webhook step, so I’ll choose the lightning bolt. This brings up the potential content from the webhook step.
The ‘Attachments Adaptive Card’ will allow you to parse any Adaptive Cards coming into the webhook. ‘Attachments Item’ processes a single attachment included to the webhook package. The ‘Attachments’ collection are any multiple attachments to the package sent to the webhook. Finally, the ‘Body’ just gives you the body of the package sent to the webhook. Since I’m sending a simple JSON body, that’s what I want here.
Now, I have to supply the schema for the content I’m sending. At the very bottom of the textbox you have the option to ‘Use sample payload to generate schema.’ If you can’t write JSON Schema but you have a sample JSON payload that you’re sending, you can add it here and let the service process it. I’m going to do this, especially because this is such a simple payload.
Clicking on this opens a window where you can type or paste a sample payload. I’ll enter my simple payload here and click the ‘Done’ button at the lower right corner which will populate the schema.
You don’t need to ‘Save’ here; once entered it will remain until you change it.
As I said, creating an adaptive card is beyond the scope of this article, so I’m going to delete that. I’ll Select the ‘Send each adaptive card’ to open the ‘Settings on the left’. Next, I’ll click the three dots on the right side of that popup and choose ‘Delete.’
Now, I’ll click the ‘+’ circle under the ‘Parse JSON’ and choose ‘Add an action’ to send a message to my team’s channel.
This opens the ‘Add an action’ popup on the left. I want to add an action specific to Microsoft Teams, so I’ll select those from the available action categories.
This brings up available steps for Microsoft Teams. I’ll scroll down and find the one I’m looking for – ‘Post message in a chat or channel.’
This opens the ‘Post message in a chat or channel’ settings. From here, I’ll want to ‘Post As’ a ‘Flow bot’ (you can change this to a user but there’ll be other settings necessary; I’m happy with the ‘Flow bot’).
Next, I’ll drop down the ‘Post In’ selection box which will allow me to choose either a ‘channel’ or ‘group chat.’ Obviously, I want to post to a ‘channel’. Wait a second and this will open up further choices of which Team and channel. I’ll pick the ‘Webhook-Replace’ team and ‘General’ channel.
Finally, I’ll click in the ‘Message’ textbox. In this box, I can actually type a message to send – but I’m interested in more ‘Dynamic Content’ so I’ll choose the lightning bolt and from the ‘Parse Json’ step, choose ‘body text’ (Note: If you look back at the automatic schema generated in the ‘Parse JSON’ step, you’ll see that ‘text’ is the only ‘Propery’ in the ‘Properties’ collection so this will post the VALUE (string) from the ‘text’ property).
You might see that there are 2 ‘Advanced Parameters’ you can set. I’m not going to set them, but they will allow you to set a static or dynamic ‘Subject’ and ‘Hosted contents.’
With that, we’re done. From the bar on the upper right hand side of the screen we want to ‘Save’ the content (you can test with ‘flow checker’ if you want) and then click the ‘back’ arrow from the upper left on the same bar.
You’ll get a pop up that says ‘Your flow is ready to go’. Just click ‘Got it’. The flow will have a title the same as the template. You can click ‘Edit’ for the details action and rename it, add a description and so on. I’m not going to – it’s time to TEST!!
I click ‘enter’ on my Powershell curl.exe command and it processes!
Conclusion
As you can see, setting up a Power Automate webhook processor is not as simple as the old Teams ‘Incoming Webhook’ but it is much more scalable and flexible and, though I didn’t delve into the options here because this was a simple article to show how to replace the incoming webhook functionality, it can provide security to ensure that malicious actors can’t hijack your webhook and send data to your users.
Replacing Teams Connectors
As you may be aware, Teams connectors have been deprecated (as discussed in Retirement of Office 365 connectors within Microsoft Teams). This means that a change to the connector URL must be made by December 31, 2024 (more information forthcoming) and that you should not create new webhooks by August 15th, 2024. After August 15th, 2024, you should be using the Power Automate Workflows app in Teams instead of webhooks.
The connectors are being retired for several reasons, including security, scalability and flexibility. These are all requests our customers have made repeatedly in the past.
Power Automate workflows are powerful 5th generation programs which use a drag-and-drop, graphical user interface (GUI) paradigm to allow powerful data transformations and selective publishing to Teams. There is a lot of information for Power Automate Workflow at Browse and add workflows in Microsoft Teams – Microsoft Support.
This article is not meant to make you an expert on Power Automate or Workflows. There are plenty of articles for you to read to become an expert. I just wanted to create an article on how you can recreate the original webhook experience. From there, you should be able to experiment with the new capabilities Workflows provide.
Replacing an Incoming Webhook
To replace the incoming connector, I’m going to start by creating a new team in my test tenant. All of this will be done using the Teams Web Client (because it’s easier for me to work with at present).
From the Teams blade, I’ll press the ‘+’ symbol and choose ‘Create team.’
I’ll name my team a really thought-provoking name like ‘Webhook-Replace’ and give it an awesome description. I’ll then click on the ‘Create’ button.
Teams will congratulate me for making such a great team with a great team name and ask me to add new members. I’ll add my System Admin account (just to make it easier for that account to delete this later) and Teams will drop me in the ‘General’ channel for this tab (all teams will have a default ‘General’ tab). Since it doesn’t matter to me where I make this webhook replacement, I’m fine with the General tab so I’ll just use it and not add another channel [Important Note: At the time I’m writing this, private channels do not work with Power Automate Workflows. My understanding is that they are working to expand Workflows to include private channels, but that work isn’t completed yet.]
Install Power Automate Workflows
Now, I need to install Power Automate Workflows into Teams. To do this, I’ll click on the ‘Apps’ button on the far-left vertical bar which will open up the apps I have available to install [Note: This list will be limited based on the App permission and App setup policies and/or App Centric Management. For App permission policies, if you don’t see Workflows in the Apps section, you need to discuss availability of this app with your Teams Administrator. Even if it appears in your apps, you may need to REQUEST the app in order to install it, depending on these policies. For App Centric Management, the App will need to be assigned to you in order to use it] In the apps application that opens up, you can type ‘Workflows’ in the ‘Search apps and more’ textbox to quickly find the app.
Click the ‘Add’ or ‘Install’ button. This will open the Workflows setup/information dialog. From here, you can do a few things. If you just click the ‘Add’ button, it will install/add the app as a ‘one-on-one chat app’. This is actually what I want, so that it allows me to determine as I design the workflow, how it acts. For a webhook replacement, this is what I recommend. You can use the down carat and choose to add to a team, chat or meeting but I will leave you to experiment with these features.
This adds the ‘Workflows’ app to the far-left application bar and opens the application.
This is the Workflows App in Teams. Personally, I don’t like using it because it will occasionally make suggestions or assumptions that go beyond what I really want to do. So, I almost always use the ‘open in browser’ option from the upper right.
This opens up the full Power Automate flow page. From the left, I’m going to choose the ‘Templates’ blade.
In the ‘Search templates’, I’ll enter ‘Teams Webhook’ and hit enter to find the webhook templates.
As you can see, you can start with a Teams template. The recommended template to begin with is ‘Post to a chat when a webhook request is received’ so that is what I will use here. We’ll change it after opening it and I’ll explain all of this in a moment.
Choosing the template opens the flow connection. The ‘This flow will connect to:’ should be pre-populated with your username and contain a green checkmark.
Click on ‘Continue’ and the flow will ask you which team and channel you wish to send to. Here, I’m going to use the dropdown to select ‘Webhook-Replace’ from my list of Teams. Then, I’ll choose the ‘General’ channel and choose to ‘Edit in advanced mode.’ You could simply choose ‘Create’ but that will automatically create the flow and we’ll need to edit it anyway.
Clicking ‘Edit in advanced mode’ will display the current flow template.
By default, this flow will take whatever is sent to the webhook and attempt to send it as an adaptive card. Generally, this won’t work. You need to do some transformation on the data, unless the application is sending an Adaptive Card – which most providers don’t do. Instead, most providers such as GitHub, send a JSON filled with data and events.
Going through how to connect GitHub is out of scope for this article, though I may follow up with a GitHub case in a new article later. Likewise, creating an adaptive card to present in the Teams channel is outside the scope of this article. I’m just going to show you a simple JSON dataset and how to send it to a channel. For this, I’m going to use a very simple CURL commandline (from Windows) with a very small, easy JSON payload.
It’s just a lame payload with text and ‘hello world’ but this is just an article to show a simple webhook replacement.
First, we need to get the URL from the ‘When a Teams webhook request is received’ step. Click on that step and it will open up the settings for the step. Copy the HTTP URL and place it in a safe place. (For me, I’ll use it in the Powershell curl.exe I have copied and pasted above).
Even though the JSON payload here is simplistic, I still need to have the flow process it. In order to do that, I’m going to need to add something to this flow. So, I’ll choose the ‘+’ button between the two existing flow steps (because I need to parse the JSON between those two steps) and choose to ‘Add an action’.
This opens the ‘Add an action’ popup on the left side. We want to process json, so I’ll enter ‘JSON’ in the search bar and look at my options. I see that ‘Data Oepration’ has a ‘Parse JSON’ option, so I’m going to choose that by clicking on it.
This adds the action between the two steps, exactly like I wanted.
This also opens the ‘Parse JSON’ settings because I still need to instruct this flow step on how to process the JSON content.
I’ll click in the ‘Content’ textbox. This will bring up the ‘actions’ choices on the right side of the textbox.
The lightning bolt means ‘Dynamic Content’. The ‘fx’ stands for formulas or expressions. I want to process Dynamic Content coming from the webhook step, so I’ll choose the lightning bolt. This brings up the potential content from the webhook step.
The ‘Attachments Adaptive Card’ will allow you to parse any Adaptive Cards coming into the webhook. ‘Attachments Item’ processes a single attachment included to the webhook package. The ‘Attachments’ collection are any multiple attachments to the package sent to the webhook. Finally, the ‘Body’ just gives you the body of the package sent to the webhook. Since I’m sending a simple JSON body, that’s what I want here.
Now, I have to supply the schema for the content I’m sending. At the very bottom of the textbox you have the option to ‘Use sample payload to generate schema.’ If you can’t write JSON Schema but you have a sample JSON payload that you’re sending, you can add it here and let the service process it. I’m going to do this, especially because this is such a simple payload.
Clicking on this opens a window where you can type or paste a sample payload. I’ll enter my simple payload here and click the ‘Done’ button at the lower right corner which will populate the schema.
You don’t need to ‘Save’ here; once entered it will remain until you change it.
As I said, creating an adaptive card is beyond the scope of this article, so I’m going to delete that. I’ll Select the ‘Send each adaptive card’ to open the ‘Settings on the left’. Next, I’ll click the three dots on the right side of that popup and choose ‘Delete.’
Now, I’ll click the ‘+’ circle under the ‘Parse JSON’ and choose ‘Add an action’ to send a message to my team’s channel.
This opens the ‘Add an action’ popup on the left. I want to add an action specific to Microsoft Teams, so I’ll select those from the available action categories.
This brings up available steps for Microsoft Teams. I’ll scroll down and find the one I’m looking for – ‘Post message in a chat or channel.’
This opens the ‘Post message in a chat or channel’ settings. From here, I’ll want to ‘Post As’ a ‘Flow bot’ (you can change this to a user but there’ll be other settings necessary; I’m happy with the ‘Flow bot’).
Next, I’ll drop down the ‘Post In’ selection box which will allow me to choose either a ‘channel’ or ‘group chat.’ Obviously, I want to post to a ‘channel’. Wait a second and this will open up further choices of which Team and channel. I’ll pick the ‘Webhook-Replace’ team and ‘General’ channel.
Finally, I’ll click in the ‘Message’ textbox. In this box, I can actually type a message to send – but I’m interested in more ‘Dynamic Content’ so I’ll choose the lightning bolt and from the ‘Parse Json’ step, choose ‘body text’ (Note: If you look back at the automatic schema generated in the ‘Parse JSON’ step, you’ll see that ‘text’ is the only ‘Propery’ in the ‘Properties’ collection so this will post the VALUE (string) from the ‘text’ property).
You might see that there are 2 ‘Advanced Parameters’ you can set. I’m not going to set them, but they will allow you to set a static or dynamic ‘Subject’ and ‘Hosted contents.’
With that, we’re done. From the bar on the upper right hand side of the screen we want to ‘Save’ the content (you can test with ‘flow checker’ if you want) and then click the ‘back’ arrow from the upper left on the same bar.
You’ll get a pop up that says ‘Your flow is ready to go’. Just click ‘Got it’. The flow will have a title the same as the template. You can click ‘Edit’ for the details action and rename it, add a description and so on. I’m not going to – it’s time to TEST!!
I click ‘enter’ on my Powershell curl.exe command and it processes!
Conclusion
As you can see, setting up a Power Automate webhook processor is not as simple as the old Teams ‘Incoming Webhook’ but it is much more scalable and flexible and, though I didn’t delve into the options here because this was a simple article to show how to replace the incoming webhook functionality, it can provide security to ensure that malicious actors can’t hijack your webhook and send data to your users. Read More