Mechanic is a development and ecommerce automation platform for Shopify. :)
This task allows you to receive an email alert for any event topic supported by Mechanic. Configure the task with a list of email addresses to notify, an email subject, and one or more event topics, each paired with an email body that supports liquid output tags for the main object of each event (e.g. shopify/products/create can use attributes like {{ product.id }} or {{ product.title }})
Runs Occurs whenever a product is created and Occurs whenever a customer is created. Configuration includes emails to notify, general email subject, append event topic to email subject, and event topics and email bodies.
This task allows you to receive an email alert for any event topic supported by Mechanic. Configure the task with a list of email addresses to notify, an email subject, and one or more event topics, each paired with an email body that supports liquid output tags for the main object of each event (e.g. shopify/products/create can use attributes like {{ product.id }}
or {{ product.title }}
)
The task comes preloaded with the customers and products create event topics, along with sample email bodies. Configure to taste :) The full list of supported event topics can be found here.
Note:
- The task will replace the OBJECT_LINK string within the email body if present (and where it makes sense to do so) with an admin link to the Shopify object related to the event topic.
- Some event topics, like shopify/products/update and shopify/inventory_levels/update, can generate a lot of emails, so they should be used with caution.
- When using the shopify/orders/edited event topic, the original order can be referenced using {{ order_edit.order }}
.
Mechanic is designed to benefit everybody: merchants, customers, developers, agencies, Shopifolks, everybody.
That’s why we make it easy to configure automation without code, why we make it easy to tweak the underlying code once tasks are installed, and why we publish it all here for everyone to learn from.
(By the way, have you seen our documentation? Have you joined the Slack community?)
{{ options.event_topics_and_email_bodies__keyval_multiline_required | keys | join: newline }}
{% comment %} Preferred option order: {{ options.emails_to_notify__array_required }} {{ options.general_email_subject__required }} {{ options.append_event_topic_to_email_subject__boolean }} {{ options.event_topics_and_email_bodies__keyval_multiline_required }} {% endcomment %} {% assign email_recipients = options.emails_to_notify__array_required %} {% for keyval in options.event_topics_and_email_bodies__keyval_multiline_required %} {% assign configured_event_topic = keyval.first %} {% if event.topic == configured_event_topic %} {% assign email_subject = options.general_email_subject__required %} {% assign email_body = keyval.last %} {% if options.append_event_topic_to_email_subject__boolean %} {% assign email_subject = email_subject | append: " [" | append: configured_event_topic | append: "]" %} {% endif %} {% capture admin_link %}https://{{ shop.myshopify_domain }}/admin/{% endcapture %} {% assign object_link = nil %} {% if event.topic contains "shopify/collections/" %} {% capture object_link %}collections/{{ collection.id | default: 1234567890 }}{% endcapture %} {% elsif event.topic contains "shopify/customers/" %} {% capture object_link %}customers/{{ customer.id | default: 1234567890 }}{% endcapture %} {% elsif event.topic contains "shopify/draft_orders/" %} {% capture object_link %}draft_orders/{{ draft_order.id | default: 1234567890 }}{% endcapture %} {% elsif event.topic contains "shopify/fulfillment_events/" %} {% capture object_link %}orders/{{ fulfillment_event.order.id | default: 1234567890 }}{% endcapture %} {% elsif event.topic contains "shopify/fulfillments/" %} {% capture object_link %}orders/{{ fulfillment.order.id | default: 1234567890 }}{% endcapture %} {% elsif event.topic contains "shopify/orders/" %} {% capture object_link %}orders/{{ order.id | default: order_edit.order.id | default: 1234567890 }}{% endcapture %} {% elsif event.topic contains "shopify/products/" %} {% capture object_link %}products/{{ product.id | default: 1234567890 }}{% endcapture %} {% elsif event.topic contains "shopify/refunds/" %} {% capture object_link %}orders/{{ refund.order.id | default: 1234567890 }}{% endcapture %} {% elsif event.topic contains "shopify/themes/" %} {% capture object_link %}themes/{{ theme.id | default: 1234567890 }}{% endcapture %} {% endif%} {% if object_link != blank %} {% assign object_link = admin_link | append: object_link %} {% else %} {% assign object_link = "[<small>Object link could not be generated</small>]" %} {% endif %} {% assign email_body = email_body | replace: "OBJECT_LINK", object_link %} {% action "email" %} { "to": {{ email_recipients | join: ", " | json }}, "subject": {{ email_subject | json }}, "body": {{ email_body | unindent | newline_to_br | json }}, "from_display_name": {{ shop.name | json }} } {% endaction %} {% endif %} {% endfor %}
ALERT
true
{"shopify/products/create" => "Hi,\n\nProduct {{ product.id }} was created\n\nView the details in Shopify:\nOBJECT_LINK", "shopify/customers/create" => "Hi\n\nCustomer {{ customer.id }} was created\n\nView the details in Shopify:\nOBJECT_LINK"}