Automatically send account invite to new customers, with Mechanic.

Mechanic is a development and ecommerce automation platform for Shopify. :)

Automatically send account invite to new customers

This task sends account invitations to newly-created customers, whether created/imported through the Shopify admin or through another app. It does not send invitation emails for customers without an email address, or to customers who've signed up via your online store.

Runs Occurs whenever a customer is created, with a 1 minute delay. Configuration includes invitation email subject and invitation email body.

15-day free trial – unlimited tasks

Documentation

This task sends account invitations to newly-created customers, whether created/imported through the Shopify admin or through another app. It does not send invitation emails for customers without an email address, or to customers who've signed up via your online store.

(Wondering about the 1-minute delay? It's because customers who sign themselves up aren't marked as such until a few seconds after their account is created. So, Mechanic waits a minute, just to be sure.)

Developer details

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?)

Open source
View on GitHub to contribute to this task
Subscriptions
shopify/customers/create+1.minute
Tasks use subscriptions to sign up for specific kinds of events. Learn more
Options
invitation email subject (required) , invitation email body (multiline, required)
Code
{% assign invitation_email_subject = options.invitation_email_subject__required %}
{% assign invitation_email_body = options.invitation_email_body__multiline_required %}

{% if event.topic == "shopify/customers/create" %}
  {% comment %}
    -- get customer data
  {% endcomment %}

  {% capture query %}
    query {
      customer(id: {{ customer.admin_graphql_api_id | json }}) {
        id
        displayName
        defaultEmailAddress {
          emailAddress
        }
        state
        tags
      }
    }
  {% endcapture %}

  {% assign result = query | shopify %}

  {% if event.preview %}
    {% capture result_json %}
      {
        "data": {
          "customer": {
            "id": "gid://shopify/Customer/1234567890",
            "state": "DISABLED"
          }
        }
      }
    {% endcapture %}

    {% assign result = result_json | parse_json %}
  {% endif %}

  {% assign customer = result.data.customer %}

  {% unless event.preview %}
    {% log customer: customer %}
  {% endunless %}

  {% unless customer.state == "DISABLED" %}
    {% log "Customer state is not 'DISABLED', so an account invite will not be sent." %}
    {% break %}
  {% endunless %}

  {% action "shopify" %}
    mutation {
      customerSendAccountInviteEmail(
        customerId: {{ customer.id | json }}
        email: {
          subject: {{ invitation_email_subject | json }}
          customMessage: {{ invitation_email_body | json }}
        }
      ) {
        customer {
          id
          displayName
          defaultEmailAddress {
            emailAddress
          }
          state
        }
      }
    }
  {% endaction %}
{% endif %}
Task code is written in Mechanic Liquid, an extension of open-source Liquid enhanced for automation. Learn more