A small and simple proxy for webhooks. You can use it to centralize the logic of sending message for your rooms on Google Chat using their webhooks.
The initial idea was to send Zabbix's alerts to all the interested people in their rooms.
You can use it for any purpose!
git clone https://github.com/thiagosanches/webhook-proxy.git
- Create a spreadsheet in your Google Drive with the following columns. On the example below, every message that was sent to devops team it will also send to Telegram as well.
teamName | webhookUrl | webhookFallbackUrl |
---|---|---|
devops | https://chat.googleapis.com/v1/spaces/... |
https://api.telegram.org/bot... |
team1 | https://chat.googleapis.com/v1/spaces/... |
https://api.telegram.org/bot... |
team2 | https://chat.googleapis.com/v1/spaces/... |
https://api.telegram.org/bot... |
- The webhookFallbackUrl is optional.
- Create a service account on Google Cloud and download the key json file.
- Grant permission to the service-account email ([email protected]) to access your Google Spreadsheet.
- Edit your key json file and add the spread sheet id and place it on besides
read-google-spreadsheet.js
file with the namekey.json
for example:
{
"type": "service_account",
"project_id": "your-google-project",
"private_key_id": "",
"private_key": "-----BEGIN PRIVATE KEY-----",
"client_email": "[email protected]",
"client_id": "",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/...",
"spread_sheet_id": "<YOUR SPREAD SHEET ID>"
}
cd webhook-proxy
npm install
node main.js
docker-compose up -d
curl http://localhost:3000 -X POST \
--data '{"team":"team1", "message":"Hello!!!"}' -H "Content-Type: application/json"