- Use Case
- Log in →
- Server Sent Events (SSE) - WS alternative, Go and Vue.js example
- Rewrite webhook body
- Docker Compose update on Github webhook
- Using Google Firestore for a Golang backend application
- Automated Jenkins builds on GitHub pull request
- Rules-based webhook filtering & routing
- Introducing Cloudflare support for Home Assistant remote access
- Setting up simple, self-hosted & fast CI/CD solution with Drone.io
- Controlling TV with Google Home, IFTTT and Node-RED
- Node-RED OwnTracks location tracking without public IP/MQTT
Rewrite webhook body
Oct 8, 2019, by Karolis Rusenas
In this short guide we will create a Python script that reads webhook body, extracts some data and sends a new webhook request to the configured destination.
Buckets group webhook input endpoints and output destinations. Go to buckets page and create one:
As a destination you can use Webhook Bin service which can provide a free an easy to use webhook testing ground.
For the sake of this example, our input JSON payload will be:
Our desired output JSON will be:
As you can see, to achieve this we will need to create a new JSON structure based on existing fields.
Relay CLI injects payload via STDIN with some optional data like destination, bucket name and so on. For this use case we will need that additional data.
First things first, let’s craft our testing payload. I used this tool https://tools.knowledgewalls.com/jsontostring to convert my input JSON into a string:
Now, input JSON (that we care about) will look like:
Let’s write a simple Python app that just prints the payload back to us:
Now, to run it:
We can see the print file
Now, to start relay agent in exec mode we will have to supply several options: