This repository acts as a webhook service that listens for Grafana alerts and forwards them to a specified WhatsApp number or group. It enables seamless integration of Grafana alerts with WhatsApp for real-time notifications.
Before using this service, generate a secret token. This is a user-defined value used to authenticate incoming webhook requests — it is not a Meta or WhatsApp API token.
Copy .env.example to .env and fill in your values:
WEBHOOK_SECRET=your_generated_secret
WHATSAPP_USER_ID=your_phone_number_without_plus
WHATSAPP_GROUP_ID=your_group_jid
Note: The phone number must be entered without the
+sign.
docker run -p 8080:8080 \
--env-file .env \
--name grafana-whatsapp-webhook \
--rm \
-v ./data:/app/data \
-v ./out:/app/out \
-d ghcr.io/optiop/grafana-whatsapp-webhook:latestThe
-v ./data:/app/datamount persists your WhatsApp session so you don't need to re-authenticate after a restart.
-
QR Code Generation:
- A QR code will be generated and saved to
./out/qr.png. - Alternatively, retrieve it from the container logs:
docker logs grafana-whatsapp-webhook
- A QR code will be generated and saved to
-
Link Device:
- Open WhatsApp, go to Linked Devices, and select Link a Device.
- Scan the QR code from
./out/qr.pngor from the logs.
Once authentication is complete, stream logs to retrieve the WhatsApp Group JID:
docker logs -f grafana-whatsapp-webhookCopy the JID of the group where you want to send alerts —
use only the number, not the @g.us suffix.
In this example
120363400930729957 is the group ID.
Set up a contact point in Grafana with the following settings:
-
For a user:
- URL:
http://<your_ip>:8080/whatsapp/send/grafana-alert/user/<phone_number> - HTTP Method: POST
- Authorization Header - Scheme:
Bearer - Authorization Header - Credentials:
<WEBHOOK_SECRET>
- URL:
-
For a group:
- URL:
http://<your_ip>:8080/whatsapp/send/grafana-alert/group/<group_id> - HTTP Method: POST
- Authorization Header - Scheme:
Bearer - Authorization Header - Credentials:
<WEBHOOK_SECRET>
- URL:
Replace <your_ip>, <phone_number>, <group_id>, and <WEBHOOK_SECRET> with your actual values.
Note: Do not use
localhostor127.0.0.1— use the actual IP address of your machine.
⚠️ WARNING: If you stop using this service, unlink the device from WhatsApp to maintain your account's security.