https://github.com/mazzz1y/go-matrix-webhook
Send matrix messages via webhook
https://github.com/mazzz1y/go-matrix-webhook
element im matrix synapse webhook
Last synced: 25 days ago
JSON representation
Send matrix messages via webhook
- Host: GitHub
- URL: https://github.com/mazzz1y/go-matrix-webhook
- Owner: mazzz1y
- Created: 2023-09-14T10:01:35.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2023-09-14T10:18:03.000Z (about 2 years ago)
- Last Synced: 2025-03-30T02:51:05.953Z (6 months ago)
- Topics: element, im, matrix, synapse, webhook
- Language: Go
- Homepage:
- Size: 12.7 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Go-Matrix-Webhook
Go-Matrix-Webhook is a lightweight and easy-to-use Matrix bot that allows you to send messages to a Matrix room using a simple POST request. It's perfect for integrating with other services, automating notifications, or even building your own custom applications.
## Installation
### Docker
Run the Docker container:
```bash
docker run -d --name go-matrix-webhook \
-p 8080:8080 \
-e LISTEN_ADDR="0.0.0.0" \
-e LISTEN_PORT="8080" \
-e LISTEN_PATH="/" \
-e SECRET_HEADER="your_secret_header" \
-e MATRIX_ACCESS_TOKEN="your_matrix_access_token" \
-e MATRIX_ID="your_matrix_id" \
-e MATRIX_URL="your_matrix_url" \
ghcr.io/mazzz1y/go-matrix-webhook:latest
```Replace `your_secret_header`, `your_matrix_access_token`, `your_matrix_id`, and `your_matrix_url` with the appropriate values.
### Download from GitHub Releases
1. Download and extract the latest release binary for your platform from the [GitHub Releases](https://github.com/mazzz1y/go-matrix-webhook/releases) page.
2. Run the binary:
```bash
./go-matrix-webhook
```## Configuration
You can configure Go-Matrix-Webhook using the following environment variables:
- `LISTEN_ADDR`: The address on which the webhook server listens (default: "0.0.0.0").
- `LISTEN_PORT`: The port on which the webhook server listens (default: 8080).
- `LISTEN_PATH`: The path on which the webhook server listens (default: "/").
- `SECRET_HEADER`: Pre-shared `X-Secret` security header.
- `MATRIX_ACCESS_TOKEN`: The access token for your Matrix account.
- `MATRIX_ID`: Your Matrix user ID.
- `MATRIX_URL`: The URL of the Matrix homeserver.Alternatively, you can set these options using command-line flags. Run `./go-matrix-webhook --help` for more information.
## Usage
### Create access token
```bash
curl -X POST -H "Content-Type: application/json" -d '{"type": "m.login.password", "identifier": {"type": "m.id.user", "user": ""}, "password": "", "initial_device_display_name": "Webhook Client"}' "https:///_matrix/client/r0/login"
```
Get the `access_token` from the curl output and pass it into this application along with other required variables. Don't forget to add the bot to your room!
### Send MessagesTo send a message, simply make a POST request with the following structure:
```bash
curl -X POST -H 'X-Secret: ' -H "Content-Type: application/json" -d '{"message": "", "room_id": ""}' "http://:"
```Replace ``, ``, ``, ``, and `` with the appropriate values.