Functions are used to mutate webhook payloads (event data) before they are dispatched based on a passed user-defined Javascript function. Convoy uses goja to provide a JavaScript runtime environment in Go, providing full ECMAScript 5.1 support (including regex and strict mode). Most of the ECMAScript 6 spec is implemented, but this is a work in progress. To enhance the runtime, console support from goja_nodejs was also added.Documentation Index
Fetch the complete documentation index at: https://getconvoy.io/docs/llms.txt
Use this file to discover all available pages before exploring further.
Importing Modules
require support also exists but is currently disabled.
Caveats
Certain constraints exist while using functions:- Multiple functions can be written in the file, but only the
transformfunction is invoked. - Only the first argument is used in the
transformfunction and that is the payload data. - The
transformfunction must return a value.
Use cases
Subscriptions
Functions can be configured when creating or updating a subscription. This is currently only possible in incoming projects. The function is used to mutate ingested event payloads from webhook providers before sending them to the destination endpoints.Sources
Functions can be configured when creating a message broker source in an outgoing project. The function is used to mutate ingested event payloads from the message broker before sending them to the destination endpoints.
Example
sample payload
sample function
sample output