Filter and modify webhooks and other processes
In general, there are two types of pre-processing functions:
The output from this function determines if the event is processed or discarded. For the filter function to pass, it must return the boolean
true value. Any other value or exception will discard the event. For webhooks, the failing filter means that the webhook is not posted, and for Document Store events, it means that the email is not stored in the Document Store.
This function allows to modify the structure of the processed data. You can add or remove properties or completely replace the value.
Here's how the Document Store pre-processing function configuration page looks like:
dataproperty. For Document Store events, it is the email object itself.
logger.error(...)etc. The log entries are logged to EmailEngine's output log.
Pre-processing functions support top-level
await..asyncsyntax. This is mostly needed for the Fetch calls.
EmailEngine allows defining of an environment for the pre-processing scripts. This is a JSON object string you can set either from the Service settings page or via Settings API using the
Once the environment object value is set, it becomes available for all pre-processing scripts as the
env object variable.
Defining the environment from the admin page:
Defining the same environment using an Settings API call:
Once you have the environment object set up, you can use it in the filter and map functions as the
The following filter function only passes if the account id of the email is listed in the provided array.
This mapping function sets a property to the email from the environment object.