Mechanic Get Mechanic
Task library

Auto-invite customers when tagged

This task watches for updates to customers, and sends invites for any customer who has the tag you choose, who hasn't previously been invited. If you'd like to run this task in bulk, you can find that version of the task here.

Try this task

When it runs

  • Occurs whenever a customer is created
  • Occurs whenever a customer is updated

What you choose

  • Tag to watch for
  • Ignore tag case
  • Invitation email subject
  • Invitation email body

Documentation

This task watches for updates to customers, and sends invites for any customer who has the tag you choose, who hasn't previously been invited. If you'd like to run this task in bulk, you can find that version of the task here.

This task watches for updates to customers, and sends invites for any customer who has the tag you choose, who hasn't previously been invited.

Invitation emails are sent using your store's account invite notification email template. Learn how to update this template.

Task code and subscriptions

You can edit the Liquid code after installing this task. View on GitHub or ask a question in the Mechanic Slack community.

Subscriptions

shopify/customers/create
shopify/customers/update
How task subscriptions work

Option types and flags

Task code

{% assign customers = array %}

{% if event.preview %}
  {% assign customers[0] = hash %}
  {% assign customers[0]["id"] = 1234567890 %}
{% elsif event.topic contains "shopify/customers/" %}
  {% assign customer_qualifies = true %}

  {% assign customer_tags = customer.tags | split: ", " %}
  {% assign tag = options.tag_to_watch_for__required %}

  {% if options.ignore_tag_case__boolean %}
    {% assign customer_tags = customer.tags | downcase | split: ", " %}
    {% assign tag = tag | downcase %}
    {% unless customer_tags contains tag %}
      {% assign customer_qualifies = false %}
    {% endunless %}
  {% else %}
    {% unless customer_tags contains tag %}
      {% assign customer_qualifies = false %}
    {% endunless %}
  {% endif %}

  {% if customer.state != "disabled" %}
    {% assign customer_qualifies = false %}
  {% endif %}

  {% if customer_qualifies %}
    {% assign customers[customers.size] = customer %}
  {% endif %}
{% endif %}

{% for customer in customers %}
  {% action "shopify" %}
    [
      "post",
      "/admin/customers/{{ customer.id | json }}/send_invite.json",
      {
        "customer_invite": {
          "subject": {{ options.invitation_email_subject__required | json }},
          "custom_message": {{ options.invitation_email_body__multiline_required | json }}
        }
      }
    ]
  {% endaction %}
{% endfor %}
Mechanic Liquid reference

Default option values

Tag to watch for
invite
Ignore tag case
true
Invitation email subject
Your account is ready!
Invitation email body
Your account for {{ shop.name }} has been pre-approved! Use the button below to get started.