Reusing event context from preceding nodes

While defining the settings of a node, you can use data (event parameters) received in the preceding node in a diagram. This enables inserting dynamic values (for example, a customer’s name or ID) in the input of the following nodes in a workflow or a request in a webhook. Such reuse in automations is called the event context.

Tip: If you’re not familiar with the Automation-related terms, check them in the dictionary.

Formula


The context of an event is kept in the {{ event.params }} Jinjava variable. This variable contains all parameters of the event from the preceding node (it can be either Client Event (a trigger) and/or Client Event Filter (a condition)).

For example, if your workflow is triggered by a visit to a website (the page.visit event), in the following nodes you can refer to the parameters of this event, for example {{ event.params.uri }}, {{ event.params.browser }}.

How it works


As the context of {{ event.params }} changes, {{ event.params }} takes over the event context of the previous node in a workflow. At the beginning of the workflow, {{ event.params }} holds the context of an event from the trigger, it can be kept throughout the whole workflow and can be referred to at any moment unless the workflow contains a Client Event Filter (which is the only node that changes the context). In such case, {{ event.params }} takes over the event context from the Client Event Filter node.

Context switch in a workflow
Context switch in a workflow
Important: The context does not change with the Action nodes (Outgoing Webhook, Send Event, Send Email, and so on).

When to use it


When a workflow contains nodes (building elements) that are based on events: Client Event and Client Event Filter.

Tips and tricks


  • You can put a parameter name in square brackets: {{ event.params['example'] }}. It is helpful when a parameter name contains special characters, like in og:url or $orderStatus, the jinjava formula for these parameters is as follows: {{ event.params['og:url'] }} and {{ event.params['$orderStatus'] }}.
  • You can use {{ event.params }} in Schema builder and in the message templates sent from the Automation module as well.
  • It is a good practice to use {{ event.params }} wherever you can instead of using aggregates, filters, and any other elements that require a call to the database.
  • If you want to set {{ event.params }} as a variable in your Jinjava code, you must omit the brackets: {{ }}.
    Example:
{% set foo = event.params.example %}

Example of use


Exemplary workflow that uses the event context
Exemplary workflow that uses the event context

The example presents a workflow that is triggered by a particular customer activity (event), as a result a webhook is sent to the external tool, the Synerise system waits until it gets the response from the tool. If so, the customer data is updated with information received through the webhook response.

Select a trigger


  1. Add the Client Event node.
  2. Click the node twice and select the event.
  3. Confirm by clicking Apply.
    Result: The selected event launches a workflow.
  4. Click the plus icon on the node.

Send a webhook to an external tool


  1. From the dropdown list, select Outgoing Webhook.
  2. Click the node twice and define the settings of the node.
    Tip: Read more about Outgoing Webhook.
  3. Select the Custom webhook tab.
  4. Prepare the body of the webhook request.
  5. Confirm by clicking Apply.
    Result: Right after the event occurrence (defined in the Client Event node), a webhook is sent to the external tool.

Check if the response is received


  1. On the Outgoing Webhook node, click the plus icon.
  2. From the dropdown list, select Client Event Filter.
  3. Click the Client Event Filter node twice.
  4. From the All events dropdown list, select webhook.response.
    Webhook response selected
    Webhook response selected
  5. Confirm by clicking Apply.
    Result: When the workflow launches and the webhook is sent, the system checks if a webhook response is received (the webhook.response event is visible on the customer’s profile in CRM). If so, the customer continues the workflow.

Modify customer data with info received from response


  1. Click the plus icon on the Client Event Filter node.
  2. From the dropdown list, select the Update Client node.
  3. Click the node twice.
  4. Select the customer attribute to be modified.
  5. Select the Change option.
    Result: A field appears.
  6. In the field, enter: {{event.params['response_parameter_name']}} (replace parameter_name with the actual name of the parameter).
    Event context used in Update Client
    Event context used in Update Client
  7. Confirm by clicking Apply.
  8. Click the plus button on the Update Client node.
  9. Select End.
😕

We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

😉

Awesome!

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.