Skip to content
Snippets Groups Projects
README.md 1.27 KiB
Newer Older
# Matrix Webhook
Robert Test's avatar
Robert Test committed

Post a message to a matrix room with a simple HTTP POST
Guilhem Saurel's avatar
Guilhem Saurel committed

## Configuration

Guilhem Saurel's avatar
Guilhem Saurel committed
Create a matrix user for the bot, make it join the rooms you want it to talk into, and then set the following
environment variables:
Guilhem Saurel's avatar
Guilhem Saurel committed

Guilhem Saurel's avatar
Guilhem Saurel committed
- `MATRIX_URL`: the url of the matrix homeserver
- `MATRIX_ID`: the user id of the bot on this server
- `MATRIX_PW`: the password for this user
- `API_KEY`: a secret to share with the users of the service
- `HOST`: HOST to listen on, all interfaces if `''` (default).
- `PORT`: PORT to listed on, default to 4785.
Guilhem Saurel's avatar
Guilhem Saurel committed

## Dev

```
Guilhem Saurel's avatar
Guilhem Saurel committed
pip3 install --user markdown matrix-nio
./matrix_webhook.py
Guilhem Saurel's avatar
Guilhem Saurel committed
```

## Prod

Guilhem Saurel's avatar
Guilhem Saurel committed
- Use [Traefik](https://traefik.io/) on the `web` docker network, eg. with
  [proxyta.net](https://framagit.org/oxyta.net/proxyta.net)
Guilhem Saurel's avatar
Guilhem Saurel committed
- Put the configuration into a `.env` file
Guilhem Saurel's avatar
Guilhem Saurel committed
- Configure your DNS for `${CHATONS_SERVICE:-matrixwebhook}.${CHATONS_DOMAIN:-localhost}`
Guilhem Saurel's avatar
Guilhem Saurel committed

```
docker-compose up -d
```

Guilhem Saurel's avatar
Guilhem Saurel committed
## Test / Usage
Guilhem Saurel's avatar
Guilhem Saurel committed

```
Guilhem Saurel's avatar
Guilhem Saurel committed
curl -d '{"text":"new contrib from toto: [44](http://radio.localhost/map/#44)", "key": "secret"}' \
  'http://matrixwebhook.localhost/!DPrUlnwOhBEfYwsDLh:matrix.org'
Guilhem Saurel's avatar
Guilhem Saurel committed
```
(or localhost:4785 without docker)
Guilhem Saurel's avatar
Guilhem Saurel committed

## Test room

[#matrix-webhook:tetaneutral.net](https://matrix.to/#/!DPrUlnwOhBEfYwsDLh:matrix.org?via=laas.fr&via=tetaneutral.net&via=aen.im)