Originally published at rharshad.com
Incoming webhook connector allows you to publish messages to teams channel.
You can even add actions to the content so that users can complete tasks within the channel.
In Microsoft Teams, choose the
More options (⋯) button next to the channel name in the list of channels and then choose Connectors.
Incoming webhook connector to the channel.
configure button next to the
Incoming Webhook connector.
Provide a name and upload an image for the connector. Now select
Copy the webhook URL for later reference.
We have now set up the webhook for the channel.
To send a message to the webhook connector we have to send it as a JSON payload. Refer message card template on how the payload needs to be structured.
Note: Adaptive cards are the recommended card type for new Teams development. They are the new cross product specification for cards in Microsoft products including Bots, Cortana, Outlook, and Windows. However, they are not supported yet in teams connectors.
You can experiment your card design at Card Playground.
We will send below sample payload to the connector and check if it works.
Send this JSON payload as a POST request to the Webhook URL.
There is a python library which you can make use of for building the messages dynamically.
You can make use of the office 365 connector plugin to send build messages to the webhook.
However, if you want to send a custom message as part of your jenkins job then we can't make use of this plugin.
Below is a sample which sends a custom card message to the webhook using
httpRequest step in jenkins pipeline code.
This card shows the build parameter values with an action button to view the build job.