Estimated effort
Task | Average effort | Technical skills required |
5 min | No | |
5-10 min | No | |
5-10 min | No | |
5 min | No | |
Total time to bring the use case live | 20-30min |
|
Set up
Components
To implement the use case, you need to consider 2 components:
The Emarsys automation that is triggered when the product-based event (e.g. Back-in-stock) occurs and that triggers the charles flow via the webhook node (Emarsys webhook)
The charles flow that the Emarsys webhook triggers is responsible for sending the WhatsApp message
Before you begin
Make sure the charles x Emarsys integration is installed, see Configure the Emarsys App
Make sure that the event you want to use to trigger the automation is tracked in Emarsys, e.g. "Low in stock"
Set up the charles flow
Create a new flow in Journeys
Add the "Emarsys trigger"
Configure the "Emarsys trigger"
Select "Custom Event"
Enter an event name that matches the use case. For example, "back_in_stock" for a back-in-stock flow
Enter the
payload
:Copy the payload of an example event from Emarsys and paste it into the field
(Optional) Use the Define Variable Node if you need to wrangle with the event data before using it for conditions or personalization of messages. For details, see Useful templating language snippets
Currently, Event Names with whitespaces are not supported.
This is the minimum setup. Depending on the use case, you want to add condition node, waiting nodes, multiple templates, etc.
Set up the Emarsys automation program
Create a new automation or select an existing one
As trigger, select the use-case specific event, or example "Price Drop"
Add use-case specific logic, e.g. condition checks
Add the webhook node as described in Set up Emarsys automation
As
event_name
choose the same event name as you used in charles, see here
Testing the setup
See the separate product guide on testing Emarsys automations
Useful templating language snippets
You can use these snippets wrangle with the event data, using the "Define variable node"
Get data from a list of products
This snippet grabs the products list and accesses the first product's title.
{% EMARSYS_TRIGGER.event_data.products[0].title %}
Determine which product dropped in price
This snippet iterates through list of products and returns the title
property of the first product that dropped in price.
{% assign discounted_product = "" %}
{% for product in EMARSYS_TRIGGER.event_data.products %}
{% if product.new_price < product.old_price %}
{% assign discounted_product = product %}
{% endif %}
{% endfor %}
{{discounted_product.link}}
Look up product details (image, link, title, etc.) based on ID
In some cases, events only contain the product ID and lack more meta data, such as the product URL, the image, or the name. The Define Variable node provides the handy function to pull this meta data by ID for these cases.
See the following two examples of how you can list the products with name and price or how you can fetch the image URL.
To get a product item by its SKU, you can use a Liquid function:
{{ '123233' | get_product: 'id' }}
where '123233
' would be the product's SKU
You can also use this function when iterating over a list of products that you might receive, for instance in an Abandoned Cart or Price Drop event:
{%- for id in REST_TRIGGER.emarsys_product_id -%}
{% assign product = id | get_product: 'id' %}
- {{ product.name }}: {{ product.price }}{{ product.currency }}
{%- endfor -%}
Based on the structure of your Emarsys event, you might need to make modifications. Reach out to charles customer support if you have questions.