Auto-tag customers with Locksmith passcodes used, with Mechanic.

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

Auto-tag customers with Locksmith passcodes used

Are you using Locksmith for access control on your online store? Use this task to tag customers with the passcode keys they've used.

Runs Occurs when Locksmith sends a session ping. Configuration includes echo all locksmith session pings.

15-day free trial – unlimited tasks

Documentation

Are you using Locksmith for access control on your online store? Use this task to tag customers with the passcode keys they've used.

Notes: After installing this task, email team@uselocksmith.com and ask to have your Locksmith webhooks sent to Mechanic.

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
locksmith/sessions/ping
Tasks use subscriptions to sign up for specific kinds of events. Learn more
Options
echo all locksmith session pings (boolean)
Code
{% if event.preview %}
  {% capture event_json %}
    {
      "preview": true,
      "data": {
        "customer": {
          "admin_graphql_api_id": "gid://shopify/Customer/1234567890"
        },
        "params": {
          "passcode": "passcode"
         }
      }
    }
  {% endcapture %}

  {% assign event = event_json | parse_json %}
{% endif %}

{% if options.echo_all_locksmith_session_pings__boolean %}
  {% action "echo", event_data: event.data %}
{% endif %}

{% assign customer_admin_graphql_api_id = event.data.customer.admin_graphql_api_id %}
{% assign passcode = event.data.params.passcode %}

{% log
  customer_admin_graphql_api_id: customer_admin_graphql_api_id,
  passcode: passcode
%}

{% if customer_admin_graphql_api_id and passcode %}
  {% action "shopify" %}
    mutation {
      tagsAdd(
        id: {{ customer_admin_graphql_api_id | json }}
        tags: {{ passcode | json }}
      ) {
        userErrors {
          field
          message
        }
      }
    }
  {% endaction %}
{% endif %}
Task code is written in Mechanic Liquid, an extension of open-source Liquid enhanced for automation. Learn more