Get email alerts for FBA failures with Mechanic.

Mechanic is the one-tool-does-it-all automation app for Shopify. :)

Get email alerts for FBA failures

by Isaac Bowen (team@usemechanic.com)

Using Fulfillment By Amazon for your business? Stay on top of your customer experience by getting notified whenever FBA is unable to fulfill your order.

Runs when a fulfillment is created and when a fulfillment is updated. Configuration includes email recipient, email subject, and email body.

15-day free trial – unlimited tasks

Developer details

Mechanic is designed to benefit everybody: merchants, customers, developers, agencies, Gurus, 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.

Events
when a fulfillment is created (shopify/fulfillments/create)
when a fulfillment is updated (shopify/fulfillments/update)
Options
email recipient (email, required), email subject (required), email body (multiline, required)
Script
{% assign cache_key = "fulfillment-failure-email-sent-" | append: fulfillment.id %}
{% assign order_qualifies = false %}

{% if fulfillment.service == "amazon_marketplace_web" and fulfillment.status == "failure" and cache[cache_key] != true %}
  {% assign order_qualifies = true %}
{% endif %}

{% if order_qualifies or event.preview %}
  {
    "action": {
      "type": "email",
      "options": {
        "to": {{ options.email_recipient__email_required | json }},
        "subject": {{ options.email_subject__required | json }},
        "body": {{ options.email_body__multiline_required | strip | newline_to_br | json }},
        "reply_to": {{ shop.customer_email | json }},
        "from_display_name": {{ shop.name | json }}
      }
    }
  }

  {
    "action": {
      "type": "cache",
      "options": {
        "set": {
          "key": {{ cache_key | json }},
          "value": true
        }
      }
    }
  }
{% endif %}
Mechanic tasks are written in Liquid, which makes them easy to write and easy to modify. Learn more about our platform.
Defaults
Email subject
FBA failure for order {{ fulfillment.order.name | default: "#12345" }}
Email body
Hello,

Amazon has reported a fulfillment failure for order {{ fulfillment.order.name | default: "#12345" }}. Here's the message they included:

> {{ fulfillment.receipt.response_message | default: "(no message given)" }}

View this order's details in Shopify:

https://{{ shop.myshopify_domain }}/admin/orders/{{ fulfillment.order.id | default: 12345 }}

Thanks,

- Mechanic, for {{ shop.name }}