Event actions are powerful. They allow you to invoke other tasks as a response to an incoming event. And, because a single task can subscribe to multiple event topics, it means you can create multi-phase tasks that are executed over time.

For developers

Options

  • "topic" – required, must start with user/ and look like user/foo/bar 
  • "data" – required, can be any JSON value

Example

This task emails a customer daily until their order is paid.

Subscriptions:

shopify/orders/create
user/orders/unpaid_reminder+1.day

Script:

{% if event.topic == "user/orders/unpaid_reminder" %}
  {% assign order = shop.orders[event.data.order_id] %}
{% endif %}

{% unless order.financial_status == "paid" %}
  {
    "action": {
      "type": "email",
      "options": {
        "to": {{ order.email | json }},
        "reply_to": {{ shop.customer_email | json }},
        "subject": "Order #{{ order.order_number }} still needs to be paid",
        "body": "Please get in touch, stat!",
        "from_display_name": {{ shop.name | json }}
      }
    }
  }

  {
    "action": {
      "type": "event",
      "options": {
        "topic": "user/orders/unpaid_reminder",
        "data": {
          "order_id": {{ order.id | json }}
        }
      }
    }
  }
{% endunless %}
Did this answer your question?