Skip to main content

Migrate MS Teams webhooks to Power Automate

· 2 min read
Stephan Hochdörfer
Head of IT Business Operations

Microsoft recently announced to retire the Office connectors in Microsoft Teams to deliver content from third-party services into a Teams channel.

That means if you rely on Office connectors webhooks in Teams, you need to migrate to Microsoft's Power Platform and create a flow triggered by a webhook. If you are new to the Power Platform, search for "webhook" in the template library, and you'll find some examples provided by Microsoft.

But that's not all that will change. If you want to post a message to a Teams channel or chat, your data needs to comply with the Adaptive Cards structure. Adaptive Cards are platform-agnostic snippets of UI authored in JSON format. Microsoft uses them to standardize how messages are rendered on different devices and/or apps.

But what does that mean?

For the "old" Office connectors webhooks in Teams, the JSON request looks like this:

$webhookUrl = '';
$content = 'Lorem ipsum...';

$client = new \GuzzleHttp\Client();
$response = $client->post($webhookUrl, [
'json' => [
'themeColor' => '#ff0909',
'text' => $content,
]
]);

Post a themeColor and text element that is all it needs.

Thanks to the Adaptive Cards structure, the similar request looks now like this:

$webhookUrl = '';
$content = 'Lorem ipsum...';

$client = new \GuzzleHttp\Client();
$response = $client->post($webhookUrl, [
'json' => [
'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' => $content,
]
]
]
]
]
]
]);

That's a lot more complex for achieving the same result. It means that if you are using third-party tools that support the "old" Office connectors webhooks way of doing things, you need to check for alternatives if the vendor of your tool does not provide an update.

On the positive side, you can do a lot more with Adaptive Cards than with the "old" Office connectors webhook. You can find a lot of examples in the official schema explorer: https://adaptivecards.io/explorer/