Notification templates

Events are sent to Koraki from various integration sources. Each source may contain different data schemas and we came up with templating for these event sources to provide wide range of customization to notifications generated. Assume you would like a notification when there's an order placed. The default body of the notification may look like "Adam from New York, USA bought a a Ladies Black Top". But you can customize the notification to be something like "Adam from New York just ordered a Ladies Black Top" or even "Adam d'New York vient de commander un Ladies Black Top" with templating.

Koraki uses liquid syntax for notification templating. Liquid is an open-source template language created by Shopify. Koraki template engine supports all operations allowed in Liquid.

Let's check how we can achieve two scenarios mentioned above

Any customizable Koraki integration comes with an Events tab. You can enter any valid liquid syntax in the template and see a sample output realtime.

How to setup a template to get "Adam from New York just ordered a Ladies Black Top"

First we need to understand the variables provided with this particular event. You can see all the available variables just under the template text box. Out of all the available variables, we will need to use {{first_name}} , {{city}}and {{first_product_name}} variables. Koraki will replace these variables with correct values when the notification is generated.

{{first_name}} from {{city}} just ordered a {{first_product_name}}

This will generate a plain notification body with the output we wanted. If you need to add a link to the product, you can do it with html anchor tag. Koraki notification templates allow using any safe html tag except for scripts and iframe.

{{first_name}} from {{city}} just ordered a <a href="{{first_product_url}}">{{first_product_name}}</a>

Or more complex template to show some additional information

{{first_name}} from {{city}} just ordered a <a href="{{first_product_url}}">{{first_product_name}}</a>{% if product_count > 1 %} and {{ product_count | abs | minus:1 }} other item{% if product_count > 2 %}s{% endif %}{% endif %}

This has a condition to check if product count is greater than 1 and show additional text indicating how many other items were bought together. Output of the above template will look like this.

Final output of above template

A much more complex example and it's output is as follows

<span style="color:#d80046;font-weight:bold">{{first_name}}</span> from <span style="background-color:#eee;padding:1px;border-radius:3px;">{{city}}</span> just ordered a <a href="{{first_product_url}}">{{first_product_name}}</a>{% if product_count > 1 %} and <b>{{ product_count | abs | minus:1 }} other item{% if product_count > 2 %}s{% endif %}</b>{% endif %}

Complex template with html style tags

Please visit liquid documentation page to learn more about syntax and operations https://shopify.github.io/liquid/‚Äč