Microsoft Teams Webhooks
Create a Teams webhook, save it as a relay target, and test delivery.
Use this guide to send endpoint traffic to a Microsoft Teams channel.
Purpose#
Use this guide to:
- Create a Teams incoming webhook URL.
- Save Microsoft Teams as a relay target.
- Attach the target to an endpoint destination.
- Test delivery.
Before you start#
- A Microsoft Teams account with access to Workflows or Power Automate, or permission to manage a legacy channel connector.
- Access to
Relay targetsandEndpointsin PayloadRelay.
Payload format#
PayloadRelay sends a Teams delivery as a MessageCard JSON envelope. This envelope operates with a legacy Incoming Webhook connector URL and with the Teams workflow webhook trigger. For Workflows, configure the next step to post the received message or card in the Teams chat or channel.
{
"@type": "MessageCard",
"@context": "https://schema.org/extensions",
"themeColor": "0078D4",
"summary": "PayloadRelay webhook event",
"title": "PayloadRelay webhook event",
"text": "```json\n{ ...original payload... }\n```"
}Microsoft gives a Teams webhook message size limit of 28 KB. PayloadRelay examines the final JSON body before the delivery. If the Teams message is larger than the limit, PayloadRelay does not send it, and it records a failed delivery in Activity with this reason:
Microsoft Teams message exceeds the supported 28 KB limit.
Teams MessageCard text supports basic Markdown. Teams shows HTML markup as plain text. PayloadRelay does not use HTML tags for the Teams formatting.
When a message template contains the View in PayloadRelay link, PayloadRelay sends it as a MessageCard OpenUri action. A legacy Incoming Webhook connector card shows this action as a button. Teams Workflows can accept the action in the request body and ignore the button when it posts the message.
Procedure#
1. Create a webhook URL in Teams#
Option A: Workflows or Power Automate
- In Teams, select
Workflowsin the Apps section, or open Power Automate directly. - Create a new flow with the trigger
When a Teams webhook request is received. - Add a Teams action that posts the received message or card to the chat or channel.
- Copy the
HTTP POST URLfrom the trigger step.
Microsoft states that the Microsoft 365 Connectors are near to their end of life. For a new webhook integration, use Workflows.
Option B: Incoming Webhook connector (legacy)
- In the Teams channel, open the channel menu and select
Connectors. - Search for
Incoming Webhookand selectConfigure. - Give the connector a name, such as
PayloadRelay. You can also upload an icon. SelectCreate. - Copy the webhook URL (
https://<tenant>.webhook.office.com/webhookb2/...). - Select
Done.
2. Add a Microsoft Teams relay target#
- Open
Relay targetsin PayloadRelay. - Select
Add target. - Select
Microsoft Teamsas the type. - Paste the webhook URL into the
Microsoft Teams webhook URLfield.- The accepted hosts are
*.webhook.office.comand*.logic.azure.com(Power Automate).
- The accepted hosts are
- Add a name and a description. These values are optional. Then save.
The target needs no email confirmation. It is available immediately.
3. Attach the target to an endpoint#
- Open the endpoint create page or the endpoint edit page.
- In
Outputs, select the Microsoft Teams target. - Save the endpoint.
4. Test delivery#
- On the
Relay targetspage, find the Teams target and selectSend test. - PayloadRelay sends a test MessageCard to the channel.
- Make sure that the message appears in Teams.
Retry behavior#
A failed delivery uses the standard automatic retry schedule of PayloadRelay, in the limit of the plan. Microsoft Teams can rate-limit a continuous burst. Send the deliveries less frequently, or let the retries correct the temporary errors.
PayloadRelay does not retry a message that is larger than the Teams 28 KB limit, because Teams rejects the message until it is smaller. Use a shorter message template, or add routing rules or transformation rules that make the data for Teams smaller.
Troubleshooting#
| Symptom | Likely cause | Fix |
|---|---|---|
| 400 Bad Request | Malformed MessageCard JSON | Read the activity log for a size error or a formatting error. |
| The activity log says that the message is larger than 28 KB | The MessageCard is larger than the Teams limit | Make the message template shorter, or send fewer payload fields to Teams. |
| 404 Not Found | A user deleted the webhook URL in Teams | Create the connector again, and update the target URL. |
| 429 Too Many Requests | The Teams rate limit | The retries are automatic. If the problem continues, send the deliveries less frequently. |
| No message in the channel | A user removed the bot from the channel | Add the Incoming Webhook connector to the channel again. |