Follow the next steps to update O365 teams webhook connector to user workflows (power automate - flows).
This flow in power automate is going to be triggered by the webhook and post the message in the channel. The "attachments" field in the webhook is an array, so we need to parse the JSON data to get the content of the message. This will get the first attachment content.
-
Create
instant cloud flow
-
Provide a name
-
Select trigger: When a
Teams webhook request is received
and presscreate
. -
Press the
+ New step
button and selectAdd an action
. -
Search for
Post card in a chat or channel
action. -
Fill in the required fields:
- Team: Select the team where the webhook is connected.
- Channel: Select the channel where the webhook is connected.
- Message: Here is the important part. You must add a function to parse the JSON data from the webhook. To do this, click on the
Message
field and selectExpression
.
-
In the expression editor, add the following expression:
triggerOutputs()?['body']?['attachments']?[0]?['content']
Follow the image below to see how the flow should look like.
To test the flow, you can use the Postman
tool to send a POST request to the webhook URL genereated in the When a Teams webhook request is received block (click on the block to see the URL). The body of the request should be a JSON object with the following structure:
{
"type": "message",
"attachments": [
{
"contentType": "application/vnd.microsoft.card.adaptive",
"contentUrl": null,
"content": {
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.2",
"body": [
{
"type": "TextBlock",
"text": "Hello World message from Teams flow 🚨",
"weight": "Bolder",
"size": "Medium"
},
]
}
}
]
}