Manipulate webhook request body
Learn how to perform basic request body modifications on webhooks using Functions.
Last updated
Was this helpful?
Learn how to perform basic request body modifications on webhooks using Functions.
Last updated
Was this helpful?
This example will demonstrate how to modify webhook requests on the fly using Webhook Relay Functions that provide (Function as a Service) functionality. We will create a function, configure routing and then send a test payload.
This function will parse JSON payload and then will construct a new JSON payload. It will also change HTTP method (to PUT) and set a content type header. Save this function to file my_function.lua:
Now, add this function to your account:
To view your functions:
Now, we will need some target where to send webhooks. Normally it would be just your system that is supposed to receive them (your backend application, Zapier, Slack, etc..)
Here:
–bucket option with ‘modify-req-with-func’ instructs to create a new bucket or reuse existing one. They are used to group inputs and outputs.
–function option specifies to use our newly created function.
-type specifies to treat the destination as public one so user doesn’t need to start the relay agent on any computer or server.
Once the command is executed, you should display
Let’s send a test payload:
You can view modified requests in Webhook Relay dashboard and in the Webhook Bin Service:
Where body is now:
and HTTP request method is PUT.
For the sake of this example we will use service. Once you enter the site you should be able to see a generated webhook inbox, copy your endpoint (https://bin.webhookrelay.com/v1/webhooks/xxxx
) and use relay forward
command:
is our webhook destination.