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.
Try this taskWhen it runs
Occurs when Locksmith sends a session ping
What you choose
Echo all locksmith session pings
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.
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
locksmith/sessions/ping
How task subscriptions work
Option types and flags
- Echo all locksmith session pings (boolean)
Task 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 %}
Mechanic Liquid reference
Default option values
- Echo all locksmith session pings
false