Email someone specific based on a new order's customer tags with Mechanic.

Mechanic is an automation and development platform for Shopify. :)

Email someone specific based on a new order's customer tags

by Isaac Bowen (team@usemechanic.com)

Use customer tags to assign staff email addresses to specific customers. When a new order arrives from a customer who has an assignment tag, this task will email the related staff member.

Runs when an order is created. Configuration includes customer tags and assigned email recipients, email subject, and email body.

15-day free trial – unlimited tasks

Documentation

Fill in the "Customer tags and assigned email recipients" option with customer tags on the left (case-insensitive), and staff email addresses on the right. When this task registers a newly-created order with a customer tag that's found in the list, it will send an email to the appropriate email address. If multiple assignment tags are found for the customer, the email will be sent to all related staff members.

Developer details

Mechanic is designed to benefit everybody: merchants, customers, developers, agencies, Gurus, 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.

Events
when an order is created (shopify/orders/create)
Options
customer tags and assigned email recipients (keyval, required), email subject (required), email body (required, multiline)
Script
{% assign customer_tags = order.customer.tags | downcase | split: ", " %}

{% assign email_recipients = array %}

{% for keyval in options.customer_tags_and_assigned_email_recipients__keyval_required %}
  {% assign assigned_tag = keyval[0] | downcase %}
  {% assign assigned_email = keyval[1] %}

  {% if customer_tags contains assigned_tag %}
    {% assign email_recipients[email_recipients.size] = assigned_email %}
  {% endif %}
{% endfor %}

{% if event.preview or email_recipients != empty %}
  {% action "email" %}
    {
      "to": {{ email_recipients | join: ", " | json }},
      "subject": {{ options.email_subject__required | json }},
      "body": {{ options.email_body__required_multiline | newline_to_br | json }},
      "reply_to": {{ shop.customer_email | json }},
      "from_display_name": {{ shop.name | json }}
    }
  {% endaction %}
{% endif %}
Mechanic tasks are written in Liquid, which makes them easy to write and easy to modify. Learn more about our platform.
Defaults
Email subject
Order {{ order.name }} from your customer, {{ order.email }}
Email body
Hello,

Order {{ order.name }} has arrived from {{ order.customer.first_name | default: "(first name)" }} {{ order.customer.last_name | default: "(last name)" }} ({{ order.email }}).

<a href="https://{{ shop.domain }}/admin/orders/{{ order.id }}">View this order in Shopify</a>

Thanks,
Mechanic, for {{ shop.name }}