Send account invites to all customers in bulk, with Mechanic.

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

Send account invites to all customers in bulk

Use this task to send out account invitations to all the customers you already have on file, with the push of a button. Optionally, filter by customer tag.

Runs Occurs when a user manually triggers the task and Occurs when a bulk operation is completed. Configuration includes only invite customers with this tag, custom subject, and custom message.

15-day free trial – unlimited tasks

Documentation

Use this task to send out account invitations to all the customers you already have on file, with the push of a button. Optionally, filter by customer tag.

This task sends the same Shopify-powered emails that are used when sending individual customer invitations (see Shopify's documentation), and uses the same Shopify email template. A custom subject and message are not required, but will be included when specified.

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
mechanic/user/trigger
mechanic/shopify/bulk_operation
Tasks use subscriptions to sign up for specific kinds of events. Learn more
Options
only invite customers with this tag, custom subject, custom message (multiline)
Code
{% if event.topic == "mechanic/user/trigger" %}
  {% assign query = "state:DISABLED" %}
  {% if options.only_invite_customers_with_this_tag %}
    {% assign query = query | append: " AND " | append: "tag:" | append: options.only_invite_customers_with_this_tag %}
  {% endif %}

  {% capture bulk_operation_query %}
    query {
      customers (query: {{ query | json }} ) {
        edges {
          node {
            __typename
            legacyResourceId
          }
        }
      }
    }
  {% endcapture %}

  {% action "shopify" %}
    mutation {
      bulkOperationRunQuery(
        query: {{ bulk_operation_query | json }}
      )	{
        bulkOperation {
          id
          status
        }
        userErrors {
          field
          message
        }
      }
    }
  {% endaction %}

{% elsif event.topic == "mechanic/shopify/bulk_operation" %}
  {% assign customers = bulkOperation.objects | where: "__typename", "Customer" %}
  {% if event.preview %}
    {% assign customers = array %}
    {% assign customers[0] = hash %}
    {% assign customers[0]["legacyResourceId"] = 12345 %}
  {% endif %}  
  {% for customer in customers %}

    {% action "shopify" %}
      [
        "post",
        "/admin/customers/{{ customer.legacyResourceId }}/send_invite.json",
        {
          "customer_invite": {
            "subject": {{ options.custom_subject | json }},
            "custom_message": {{ options.custom_message__multiline | json }}
          }
        }
      ]
    {% endaction %}
  {% endfor %}
{% endif %}


Task code is written in Mechanic Liquid, an extension of open-source Liquid enhanced for automation. Learn more