Mechanic Get Mechanic
Task library

Email POS form answers after a paid sale

Email saved Mechanic POS form answers to your workshop or team after a paid POS sale. Use it with the short Add engraving or Add a gift note starter, or your own POS form.

Try this task

When it runs

Occurs whenever an order is paid

What you choose

  • POS form ID
  • Email recipients

Documentation

Email saved Mechanic POS form answers to your workshop or team after a paid POS sale. Use it with the short Add engraving or Add a gift note starter, or your own POS form.

Set up the workflow

  1. In Mechanic Forms → Create form → Point of sale, choose Add engraving (item and engraving text) or Add a gift note (one message). Keep it short for staff at the counter. You can customize the fields; this task includes every nonempty saved answer.
  2. Publish the form and add the Mechanic Forms tile from the same Mechanic app in Shopify POS. If you have production, staging, or development apps installed together, check which app the tile belongs to. An active cart with an item is required. This is a save-with-sale workflow, not standalone registration.
  3. Open the form's Submission settings, copy its Form ID, and paste it into this task's POS form ID option. Choose the recipient inboxes in Email recipients. No webhook or shared secret is needed. Install a separate copy of the task for each form you want to email; each copy can have its own recipients.
  4. Save and enable this task. Make sure the shop is approved to send email.
  5. In POS, add a product, open the form, enter the answers, and choose Save to cart. Complete a paid test sale. Check the saved order details, the Mechanic email action, and an inbox you control. Form preview and Save to cart do not send this email. Task preview uses sample engraving answers to show the email without sending it.

What the task does

The task runs on shopify/orders/paid, checks that the webhook describes an uncancelled POS order with paid status, and reads only _mechanic_pos_<your form ID> from the order's additional details. Orders without this form are skipped. It does not read or change the customer profile, change fulfillment, or send an invoice. A deposit or partially paid order will not trigger an email until the order becomes fully paid.

Saved answers belong to the sale, not an individual line item. For engraving, staff must identify the item and quantity in the form. This is one set of instructions per form per sale; it is not a separate engraving entry for every cart item. The gift note starter sends the note to your team, not to the gift recipient.

Email headings come from the fields' data keys with underscores changed to spaces. Labels can be edited freely, but use readable data keys. Text is escaped for email; checkbox answers become Yes or No. Invalid JSON, unsupported versions, duplicate form properties, and unsupported answer values produce an error without emailing partial instructions. Blank answers are omitted, while unchecked checkboxes remain No.

Email runs asynchronously after payment. Save confirms storage, not email delivery. Inspect failed email actions before retrying. Re-running the event, enabling duplicate task copies, or receiving duplicate paid events can send another email; this task does not guarantee exactly-once delivery. It does not watch for later edits to order details or recall an email if the order is later cancelled.

Availability

POS Forms must be enabled for the shop, and the POS extension must be installed. Installing this task does not enable POS Forms or create a form. Existing forms continue to work; the task supports the current version 1 POS saved-answer format.

See the POS Forms guide for placement, prefill, and troubleshooting.

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/orders/paid
How task subscriptions work

Option types and flags

Task code

{% comment %}
  {{ options.pos_form_id__required }}
  {{ options.email_recipients__email_array_required }}
{% endcomment %}

{% assign form_id = options.pos_form_id__required | strip | downcase %}
{% assign recipients = options.email_recipients__email_array_required %}
{% if event.preview %}
  {% assign form_id = form_id | default: "11111111-1111-4111-8111-111111111111" %}
  {% if recipients == blank %}{% assign recipients = "workshop@example.com" | split: "," %}{% endif %}
  {% capture sample_answers %}{"version":1,"formRevision":1,"savedWithCustomerId":null,"answers":{"item":"Silver bracelet, one","engraving_text":"Love, Alex"}}{% endcapture %}
  {% capture sample %}
    {"id":1234567890,"name":"#1001","source_name":"pos","financial_status":"paid","cancelled_at":null,"note_attributes":[{"name":{{ form_id | prepend: "_mechanic_pos_" | json }},"value":{{ sample_answers | json }}}]}
  {% endcapture %}
  {% assign order = sample | parse_json %}
{% endif %}
{% assign valid_form_id = form_id | match: '\A[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\z' %}
{% unless valid_form_id %}
  {% error "Copy the POS form ID from Forms > Submission settings into the POS form ID option." %}{% break %}
{% endunless %}
{% unless event.topic == "shopify/orders/paid" and order.source_name == "pos" and order.financial_status == "paid" and order.cancelled_at == nil %}
  {% log "This is not a paid, uncancelled POS sale. No email was queued." %}{% break %}
{% endunless %}
{% assign property_name = form_id | prepend: "_mechanic_pos_" %}
{% assign matches = order.note_attributes | where: "name", property_name %}
{% if matches.size == 0 %}
  {% log "This sale has no saved answers for the selected POS form. No email was queued." %}{% break %}
{% endif %}
{% if matches.size != 1 %}
  {% error "More than one saved property matches this POS form. Review the order's additional details. No email was queued." %}{% break %}
{% endif %}
{% assign raw = matches.first.value %}
{% assign raw_type = raw | json | slice: 0, 1 %}
{% unless raw_type == '"' and raw.size <= 4096 %}
  {% error "The saved POS form data is invalid or too long. No email was queued." %}{% break %}
{% endunless %}
{% assign saved = raw | parse_json: silent: true %}
{% assign saved_type = saved | json | slice: 0, 1 %}
{% unless saved_type == '{' %}
  {% error "The saved POS form data is not a JSON object. No email was queued." %}{% break %}
{% endunless %}
{% assign answers_type = saved.answers | json | slice: 0, 1 %}
{% assign answers_size = saved.answers | size %}
{% unless saved.version == 1 and answers_type == '{' and answers_size <= 50 %}
  {% error "The saved POS form format is unsupported. No email was queued." %}{% break %}
{% endunless %}
{% assign answer_count = 0 %}
{% assign invalid_answers = false %}
{% capture details %}
  {% for pair in saved.answers %}
    {% assign key = pair.first %}
    {% assign value = pair.last %}
    {% assign valid_key = key | match: '\A[a-z][a-z0-9_]{0,63}\z' %}
    {% assign serialized = value | json %}
    {% assign value_type = serialized | slice: 0, 1 %}
    {% unless valid_key %}{% assign invalid_answers = true %}{% break %}{% endunless %}
    {% unless value_type == '"' or serialized == 'true' or serialized == 'false' %}
      {% assign invalid_answers = true %}{% break %}
    {% endunless %}
    {% if value_type == '"' and value == blank %}{% continue %}{% endif %}
    {% assign answer_count = answer_count | plus: 1 %}
    <p><strong>{{ key | replace: "_", " " | capitalize | escape }}</strong><br>
    {% if serialized == 'true' %}Yes{% elsif serialized == 'false' %}No{% else %}{{ value | escape | newline_to_br }}{% endif %}</p>
  {% endfor %}
{% endcapture %}
{% if invalid_answers %}
  {% error "The saved POS form contains unsupported answer values. No email was queued." %}{% break %}
{% endif %}
{% if answer_count == 0 %}
  {% log "The selected POS form has no completed answers. No email was queued." %}{% break %}
{% endif %}
{% if recipients == blank %}
  {% error "Enter the email recipients for these POS instructions. No email was queued." %}{% break %}
{% endif %}
{% capture subject %}POS instructions for {{ order.name | strip_newlines }}{% endcapture %}
{% capture body %}
  <p>A paid POS sale has instructions for your team.</p>
  <p><strong>Order {{ order.name | escape }}</strong></p>
  {{ details }}
  <p>These answers describe the sale. Item descriptions are entered by staff, not automatically linked to an order line.</p>
  <p><a href="https://{{ shop.myshopify_domain | escape }}/admin/orders/{{ order.id | escape }}">View order in Shopify</a></p>
{% endcapture %}
{% action "email" %}
  {
    "to": {{ recipients | json }},
    "subject": {{ subject | strip | truncate: 200, "" | json }},
    "body": {{ body | strip | json }},
    "from_display_name": {{ shop.name | json }},
    "reply_to": {{ shop.customer_email | json }}
  }
{% endaction %}
Mechanic Liquid reference

Default option values

Email recipients
[]