【Mattermost】webhook

Posted by 西维蜀黍 on 2020-07-09, Last Modified on 2021-09-21

Incoming Webhooks

Mattermost supports webhooks to easily integrate external applications into the server.

Use incoming webhooks to post messages to Mattermost public channels, private channels and direct messages. Messages are sent via an HTTP POST request to a Mattermost URL generated for each application and contain a specifically formatted JSON payload in the request body.

Simple Incoming Webhook

Let’s learn how to create a simple incoming webhook that posts the following message to Mattermost.

  1. First, go to Main Menu > Integrations > Incoming Webhook. If you don’t have the Integrations option in your Main Menu, incoming webhooks may not be enabled on your Mattermost server or may be disabled for non-admins. Enable them from System Console > Integrations > Custom Integrations in prior versions or System Console > Integrations > Integration Management in versions after 5.12 or ask your System Administrator to do so.
  2. Click Add Incoming Webhook and add name and description for the webhook. The description can be up to 500 characters.
  3. Select the channel to receive webhook payloads, then click Add to create the webhook.
  4. Use a curl command from your terminal or commandline to send the following JSON payload in a HTTP POST request:
curl -i -X POST -H 'Content-Type: application/json' -d '{"text": "Hello, this is some text\nThis is more text. :tada:"}' http://{your-mattermost-site}/hooks/xxx-generatedkey-xxx
# or
curl -i -X POST --data-urlencode 'payload={"text": "Hello, this is some text\nThis is more text. :tada:"}' http://{your-mattermost-site}/hooks/xxx-generatedkey-xxx

Outcoming Webhooks

//TODO

Reference