The optional payload of the event as JSON object. Can be null in case the event doesn't contain any additional data. The structure of this payload depends on the event type and the Content-Type header.
In case the event represents a change of data in the system, usually the attributes origin and target are placed inside payload, whereas:
origin: Contains the origin value BEFORE the change happened or null, if there was no origin value.
target: Contains the final value AFTER the change happened.
Let's consider for example the event type property.moved:
origin contains here the origin property key before the move. For example: "origin": "global/app/myapp/old"
target contains here the final key, the property was moved to. For example: "target":"global/app/myapp/new".
It depends on the event type whether origin and / or target is provided inside payload and which structure they have. Consult the documentation for the certain event types to learn more about the available built-in event types.
In case a pipeline should be executed when a certain event was fired, the event.listen command should be used. When the pipeline is deployed, the event.listen registers itself as a listener to the event system. Whenever an event is fired that matches the event.listen criteria, any subsequent commands of this pipeline gets executed.
Lets assume an example: Whenever a new lead was created in Salesforce, the pipeline must send an email to the sales team:
After this pipeline was deployed to the property store, it will be executed automatically any time a new event with key webhook.salesforce.lead.created occurs. In this case, a new email will be sent to firstname.lastname@example.org.
Note: Each pipeline can define exactly one event.listen command and it must be the very first command in the pipeline.
Besides the event key, each event can also be filtered by its properties. So a pipeline gets executed only in case such a filter evaluated with true. To do so, you can use the filter parameter of the event.listen command and place a pipeline expression here. Since the event object is automatically provided in the body for you, you can access it there from inside your pipeline expression (PE). For example:
In the filter parameter you can place a pipeline expression (PE). If this expression evaluates with true, all subsequent commands after event.listen will be executed.
In this example, we assume that the event contains the Salesforce Lead object. So, we can filter for the CountryCode here. But this depends on the implementation of the webhook.
In order to send an event, you can use the event.send command. Here is an example:
Every time this pipeline gets executed, it will send a new event with key com.company.myevent. Optionally, you also set the payload of the event using its payload parameter. This can be a literal or a pipeline expression (PE) which points to an object to be attached to the payload.
Note: Whenever you send a custom event, you need to prefix it with the reversed internet address of your company. In this example it is com.company. Otherwise, it could be that your event gets dropped or causes an exception.