Send a webhook for Mattermost


I try to use Kirby’s Hooks to send a webhook to Mattermost (Slack open-spurce alternative) but I’m a bit lost.

Here’s the documentation about incomming webhooks for Mattermost but I don’t understand what I’m suppose to do with this :

Use an incoming webhook

To use the endpoint, have your application make the following request:

POST /hooks/xxx-generatedkey-xxx HTTP/1.1
Content-Type: application/json
Content-Length: 63

    "text": "Hello, this is some text\nThis is more text. 🎉"

Maybe the whole answer is obvious and written just up there, but I don’t have large skills in web dev (HTML, CSS, a bit of php) and 0 in JSON or whatever, sorry…

The goal is to send a short message like "New page created" on the hook page.create:after.

Thank you for your help !

A noob

You can use Kirby Remote class to make the request:

$result = Remote::request(
    'method'  => 'POST',
    'headers' => [
      'Content-Type' => 'application/json',
    'data'    => Data::encode(['text' => 'Hello, this is some text.'], 'json'),
1 Like

Thank you so much!!! It works perfectly!