2020-01-10 21:53:33 +08:00
# Setting up Appservice Webhooks (optional)
The playbook can install and configure [matrix-appservice-webhooks ](https://github.com/turt2live/matrix-appservice-webhooks ) for you.
2020-01-14 22:02:37 +08:00
This bridge provides support for Slack-compatible webhooks.
2020-01-10 21:53:33 +08:00
Setup Instructions:
loosely based on [this ](https://github.com/turt2live/matrix-appservice-webhooks/blob/master/README.md )
2020-01-14 00:28:54 +08:00
1. All you basically need is to adjust your `inventory/host_vars/matrix.<domain-name>/vars.yml` :
2020-01-14 21:55:56 +08:00
```yaml
matrix_appservice_webhooks_enabled: true
matrix_appservice_webhooks_api_secret: '< your_secret > '
```
2020-01-10 21:53:33 +08:00
2. In case you want to change the verbosity of logging via `journalctl -fu matrix-appservice-webhooks.service`
2020-01-14 00:28:54 +08:00
you can adjust this in `inventory/host_vars/matrix.<domain-name>/vars.yml` as well.
2020-01-10 21:53:33 +08:00
2020-01-14 21:55:56 +08:00
*Note*: default value is: `info` and availabe log levels are : `info` , `verbose`
```yaml
matrix_appservice_webhooks_log_level: '< log_level > '
```
2020-01-10 21:53:33 +08:00
3. If you've already installed Matrix services using the playbook before, you'll need to re-run it (`--tags=setup-all,start`). If not, proceed with [configuring other playbook services ](configuring-playbook.md ) and then with [Installing ](installing.md ). Get back to this guide once ready.
2020-02-20 15:39:27 +08:00
4. If you're using the [Dimension Integration Manager ](configuring-playbook-dimension.md ), you can configure the Webhooks bridge by opening the Dimension integration manager -> Settings -> Bridges and selecting edit action for "Webhook Bridge". Press "Add self-hosted Bridge" button and populate "Provisioning URL" & "Shared Secret" values from `/matrix/appservice-webhooks/config/config.yaml` file's homeserver URL value and provisioning secret value, respectively.
2020-02-20 13:11:19 +08:00
2020-02-26 08:01:32 +08:00
5. Invite the bridge bot user to your room:
2020-01-14 21:55:56 +08:00
- either with `/invite @_webhook:<domain.name>` (*Note*: Make sure you have administration permissions in your room)
2020-01-10 21:53:33 +08:00
- or simply add the bridge bot to a private channel (personal channels imply you being an administrator)
2020-02-26 08:01:32 +08:00
6. Send a message to the bridge bot in order to receive a private message including the webhook link.
2020-01-14 21:55:56 +08:00
```
!webhook
```
2020-01-10 21:53:33 +08:00
2020-02-26 08:01:32 +08:00
7. The JSON body for posting messages will have to look like this:
2020-01-14 21:55:56 +08:00
```json
{
"text": "Hello world!",
"format": "plain",
"displayName": "My Cool Webhook",
2021-02-19 03:48:56 +08:00
"avatar_url": "http://i.imgur.com/IDOBtEJ.png"
2020-01-14 21:55:56 +08:00
}
```
You can test this via curl like so:
```
curl --header "Content-Type: application/json" \
--data '{
"text": "Hello world!",
"format": "plain",
"displayName": "My Cool Webhook",
2021-02-19 03:48:56 +08:00
"avatar_url": "http://i.imgur.com/IDOBtEJ.png"
2020-01-14 21:55:56 +08:00
}' \
< the link you ' ve gotten in 5 . >
```