GUITACA BLOGS
Blogs from our authors

Office 365: The best recipes for developers
Gustavo Velez
Learn more and buy
Return to Blogs
Incoming Webhooks in Teams ChannelsGustavo Velez
Messages can be sent to a Teams Channel using Webhooks03-01-2021
Teams

Any Channel in a Team can expose an HTTPS endpoint that accepts JSON messages and inserts messages into that Channel. The possibility to use Incoming Webhooks must be enabled for the Team in its general configuration (in the Member permissions section, Allow members to create, update, and remove connectors). Incoming Webhooks are configured as Connectors at the Channel level.

Teams Connectors are the same as O365 Connectors, and, technically, they are Incoming Webhook in Teams. The Connectors model used within Teams is the same one used by Exchange (and Outlook), and one Connector can be installed and used in both services.

To add an Incoming Webhook to a Channel:

- From the Channel where the Webhook will be added, use the ellipse (...) More Options button and choose Connectors.

- From the menu, search for Incoming Webhook and click on the Add button (two times).

- In the popup window, define a name for the Webhook, and use the Create button.

- The wizard generates a unique URL that will map to the Channel. Copy and save the URL because it will be used later. It will be in the form:

https://outlook.office.com/webhook/6f45c2f8-9b25-47a6-a2d4-9323cbb094d7@9e5f418c-8a47-4228-aa48-17d7555e2400/IncomingWebhook/07c435ceb88d4b6ebaec175519f85600/c5f65d8e-8892-470f-9ed2-0a2d4b1a7606

- After clicking on the Done button, the Webhook is available on the Channel.

A simple way to test a configured Incoming Webhook is using PowerShell to send a POST request to the hook:

Invoke-RestMethod -Method post -ContentType 'Application/Json' -Body '{"text":"Sent by a Webhook"}' -Uri [Webhook URL]

If everything is correctly configured, the cmdlet will get a 1 as the response.

Open the Posts tab of the Teams channel to review the messages received through the Webhook.

Return to Blogs