Mechanic
đŸ“Ŗ Shopify REST Deprecation
  • â›Šī¸Introduction
  • 🤓Hire a Mechanic developer
  • đŸ’¯status.mechanic.dev
  • đŸ“ŖShopify is deprecating the REST API
  • 🙋"I need something custom!"
  • 🧑‍đŸ’ģ"I need help with my custom task!"
  • 🤖"I need help with my AI-written task!"
  • Resources
    • âŦ‡ī¸Install Mechanic
    • 🧑‍đŸ’ģTask library
      • Contributing
      • Requesting
    • 🚀Slack community
    • 🤝Partner directory
    • 🧠Tutorials
      • Video walkthroughs
        • Auto-tag orders by originating staff member
        • Maintain a tag for orders processed today
        • Auto-tag orders with their tracking numbers
        • Sync inventory for shared SKUs
        • Auto-tag products when their SKU(s) change
        • Auto-publish new products
        • Email a report of customers who haven't ordered in X days
        • Upgrading a Mechanic task: Adding a time delay
        • Email the customer when tracking numbers are added to their order
        • Adding an optional time delay to your Mechanic task
        • Delete all orders
        • Send an email when a specific product is shipped
        • Send recurring reminders about unpaid orders
        • Send an email when a product's price goes below its cost
        • Auto-tag customers by sales channel
        • Creating products in bulk
      • Creating a Mechanic webhook
      • Practicing writing tasks
      • Triggering tasks from a contact form
      • Creating scheduled CSV feeds
      • Fetching data from a shared Google sheet
    • 🏆Converting tasks from Shopify REST to GraphQL
      • Conversion: Single resource lookups
      • Conversion: Resource loops to paginated queries
      • Conversion: Connections from a resource
      • Conversion: Metafield lookups from a resource
      • Conversion: Resource lookups in task option fields
  • Core Concepts
    • Events
      • Topics
      • Parent and child events
    • Tasks
      • Subscriptions
      • Code
        • Environment variables
        • Action objects
        • Error objects
        • Log objects
      • Options
        • Custom validation
      • Previews
        • Defining preview events
        • Stub data
      • Shopify API version
      • Advanced settings
        • Documentation
        • JavaScript
        • Perform action runs in sequence
      • Import and export
      • User Form
    • Actions
      • Cache
      • Echo
      • Email
      • Event
      • Files
      • Flow
      • FTP
      • Google Drive
      • Google Sheets
      • HTTP
      • Integrations
        • Report Toaster
      • Shopify
      • File generators
        • Base64
        • PDF
        • Plaintext
        • URL
        • ZIP
    • Runs
      • Scheduling
      • Concurrency
      • Ordering
      • Retries
    • Interacting with Shopify
      • Responding to events
        • Reconciling missing events
      • Reading data
        • âš ī¸Liquid objects
        • 🏆GraphQL in Liquid
        • Bulk operations
        • The Shopify action
      • Writing data
      • Shopify admin action links
      • API rate limit
      • API versions
  • Platform
    • 🔆Policies
      • Data
      • Plans
      • Pricing
      • Privacy
    • Cache
      • Cache endpoints
    • Email
      • Receiving email
      • Custom email addresses
      • DMARC
      • Email templates
    • Error handling
    • Events
      • Event topics
      • Event filters
    • GraphQL
      • Basics
        • Shopify Admin API GraphiQL explorer
        • Queries
        • Mutations
        • Pagination
      • Bulk operations
    • Integrations
      • Appstle Subscriptions
      • Google Drive and Google Sheets
      • Judge.me
      • Locksmith
      • Report Toaster
      • Shopify Flow
      • Run links
    • Liquid
      • Basics
        • Syntax
        • Data types
        • Variables
        • Comments
        • Filters
        • Operators
        • Control flow
          • Condition
          • Iteration
        • Whitespace
      • Liquid console
      • Mechanic filters
        • Deprecated filters
      • Mechanic keyword literals
        • array
        • hash
        • newline
      • Mechanic objects
        • Action object
        • Cache object
        • Event object
        • Options object
        • Task object
        • âš ī¸Shopify REST Admin API
          • đŸšĢArticle object
          • đŸšĢBlog object
          • đŸšĢCollection object
          • đŸšĢCustomer object
          • đŸšĢDiscount code object
          • đŸšĢDispute object
          • đŸšĢDraft order object
          • đŸšĢFulfillment object
          • đŸšĢFulfillment order object
          • đŸšĢFulfillment event object
          • đŸšĢGift card object
          • đŸšĢInventory item object
          • đŸšĢInventory level object
          • đŸšĢLine item object
          • đŸšĢLocation object
          • đŸšĢMetafields
            • Metafield object
            • Metafield representation object
            • Metafield collection object
          • đŸšĢOrder object
          • đŸšĢOrder risk object
          • đŸšĢPrice rule object
          • đŸšĢProduct object
          • đŸšĢProduct image object
          • đŸšĢRefund object
          • đŸšĢShipping zone object
          • đŸšĢShop object
          • đŸšĢTheme object
          • đŸšĢTheme asset object
          • đŸšĢTransaction object
          • đŸšĢVariant object
      • Mechanic tags
        • liquid
        • action
        • assign
        • error
        • log
      • Mechanic code snippets
    • Shopify
      • Custom authentication
      • "Read all orders"
    • Webhooks
  • Techniques
    • Preventing action loops
    • Writing a high-quality task
    • Tagging Shopify resources
    • Debouncing events
    • Responding to action results
    • Working with external APIs
      • JSON Web Signatures
      • AWS request signatures
    • Finding a resource ID
    • Migrating templates from Shopify to Mechanic
    • Securing Mechanic webhooks
    • Monitoring Mechanic
  • FAQ
    • The app isn't loading. What do I do?
    • How do I stop a large batch of runs?
    • A Shopify event is missing. Where is it?
    • Does Mechanic have an affiliate program?
    • Can non-owners install Mechanic?
    • Can I replace Shopify's order emails with Mechanic?
    • Can I manually set Shopify permissions for Mechanic?
    • Does my theme need to be updated for Mechanic?
    • Do you have a plan for development stores?
    • Why don't I see any events in my task's activity?
    • Can I read data back from my webhook submission?
    • My task added a tag, but now the tag is missing – why?
    • How do I add an unsubscribe link to my emails?
    • How do I send images with my emails?
    • Can I re-send order confirmation emails with Mechanic?
    • Why am I seeing a different price than on the app store?
    • Do you have a Partner-friendly plan?
    • Why are my tasks delayed or not running?
    • My task is failing because of a permissions problem. Why?
    • How do I preview email attachments?
    • Can I query external APIs?
    • Why can't I access the Shopify API during preview mode?
    • How do marketing preferences work with Mechanic?
    • Can I send data to Google Sheets?
    • What's possible with timeline comments?
    • I'm getting a "query param length is too long" error when using GraphQL.
    • Can my Mechanic concurrency limit be raised?
    • What IP address does Mechanic use?
    • Can Mechanic read or manage customer subscriptions?
    • Why is everything harder now?
    • Can task content be translated into multiple languages?
    • Can I add a time delay to my task?
    • Can I add another store to my existing Mechanic subscription?
    • How can I reduce memory usage of my task?
    • How do I connect PayPal to Shopify with Mechanic?
    • How do I add a Shopify access scope to my task?
    • Can I have my Mechanic data retained for more (or less) than 15 days?
Powered by GitBook

Important Updates

  • đŸ“Ŗ Shopify REST Deprecation
On this page
  • What is Flow?
  • Flow terminology
  • Connecting Mechanic
  • Mechanic → Flow
  • Flow → Mechanic

Was this helpful?

Edit on GitHub
Export as PDF
  1. Platform
  2. Integrations

Shopify Flow

PreviousReport ToasterNextRun links

Last updated 1 year ago

Was this helpful?

Mechanic allows developers to integrate their work with via an official Flow connector, sending triggers to Shopify using Mechanic's , and receiving events from Shopify using custom event topics in .

What is Flow?

Flow is Shopify's answer to automation for Plus merchants: a graphical tool that allows for defining automation using flowchart-like structures.

From :

Shopify Flow is an ecommerce automation solution that was purpose-built to help solve the unique challenges that Shopify merchants face. With Flow, you can build workflows to automate tasks, campaigns, and processes within your store and across your apps.

Flow terminology

As an automation tool itself, Flow has its own terms for the components of automation.

Workflow

A package of configuration, containing a trigger, zero or more conditions, and one or more actions. Analogous to a Mechanic task.

Trigger

An event from Shopify or another connector (like Mechanic), which can be used to set workflows. Analogous to a Mechanic event.

Condition

A logical check which evaluates some data (possibly provided by the trigger), and steers the workflow towards specific actions. Loosely analogous to the code in a Mechanic task.

Action

Work to be performed, at the conclusion of a workflow's run. Directly analogous to a Mechanic action.

Both Mechanic and Flow use the term "action"! When working on both of these platforms together, keep an eye out for this term, and make sure you understand which platform's definition is relevant.

Connecting Mechanic

Mechanic's Flow connector works in both directions: Mechanic → Flow, and Flow → Mechanic.

  • Beginning on the Mechanic side, the Flow action sends data to Flow, arriving in the form of a trigger, and setting off the Flow workflows configured there.

  • Beginning on the Flow side, the Mechanic action sends data to Mechanic, arriving in the form of a new event, setting off the Mechanic tasks configured there.

Mechanic → Flow

On the Flow side, workflows may be configured to listen for any of these four Mechanic triggers.

Triggers

  • General

    • Send user-defined data to a Shopify Flow workflow.

  • Customer

    • Send a customer ID to be pulled up in context in Shopify Flow.

    • Send user-defined data to a Shopify Flow workflow.

  • Order

    • Send a order ID to be pulled up in context in Shopify Flow.

    • Send user-defined data to a Shopify Flow workflow

  • Product

    • Send a product ID to be pulled up in context in Shopify Flow.

    • Send user-defined data to a Shopify Flow workflow

User-defined data

All four triggers include the following user-defined data variables, given as options to the Flow action. If a variable is omitted from the action's options, Mechanic will still send it to Flow, using a default value.

Usage

To choose between trigger types, choose between defining exactly one specific Shopify resource ID (i.e. for a customer, order, or product, resulting in the appropriate resource trigger), or omitting a resource ID entirely (resulting in the General trigger).

{% action "flow" %}
  {
    {% comment %}
      If you want your Mechanic Flow trigger to be associated
      with a Shopify resource, you may include its numeric ID
      below. Only one resource at a time is supported. Leave
      this out entirely to use the General Mechanic Flow trigger.
    {% endcomment %}
    "customer_id": 1234567890,
    "order_id":    1234567890,
    "product_id":  1234567890,

    {% comment %}
      Keep as many of the following as you like. Any omitted
      keys *will* be submitted anyway, using the default value
      given below. If you don't want to use Mechanic's default
      value, make sure to *keep* the key in place below, setting
      it to whatever you like.
    {% endcomment %}
    "user_boolean": false,
    "user_email":   "hey@mechanic.invalid",
    "user_number":  0,
    "user_string":  "",
    "user_url":     "https://mechanic.invalid/"
  }
{% endaction %}

On the Flow side, configure workflows to start with the appropriate Mechanic trigger.

Flow → Mechanic

The Mechanic action, in Flow, sends new events to Mechanic.

Option
Notes

Event topic

Event data

Optional; must be valid JSON.

Task ID

Optional; restricts processing of the resulting event to a single Mechanic task. Note that the task must still subscribe to the event topic for it to receive these events.

{
  "customer_email": {{ customer.email | json }},
  "customer_note": {{ customer.note | json }}
}

If the event data configuration results in invalid JSON, the resulting Mechanic event will contain data reflecting the JSON error encountered. Here's an example:

{
  "__error": {
    "message": "An event was received from Flow with invalid JSON in its event data. Check the originating workflow's configuration and resolve the issue there. (Hint: the `json` Liquid filter is often useful in cases like this!)",
    "invalid_event_data_json": "{\n  \"user_boolean\": true,\n  \"user_email\": \"heyhey@mechanic.invalid\",\n  \"user_number\": 5,\n  \"user_string\": \"asdfasdf\",\n  \"user_url\": \"https://google.com/\",\n  \"mechanic_task_id\": \"6c461365-ae83-46c4-b33e-a0d7c81b03d5\",\n  \"mechanic_event_topic\": \"mechanic/user/trigger\",\n  \"mechanic_event_inspector_url\": \"https://mechanic-dev-isaac.myshopify.com/admin/apps/mechanic-dev-isaac/~/events/659df64b-7622-4bc4-924c-dda268c737b2?task_run_id=cd49135a-cdcc-452b-9338-4fa3288bd577\",,,\n}"
  }
}

Shopify Flow workflows are triggered from the Mechanic side, using Mechanic's . There are four triggers to choose from: General, Customer, Order, and Product. Mechanic's Flow action can produce any one of these four triggers, depending on the action options given.

Required; must start with "user/", resulting in an event in .

The resulting Mechanic event will have a topic and data reflecting the Flow action configuration. Event data is available to tasks via event.data, as usual. (For more on how to use event data, see .)

When using Flow's template variables for event data, remember to use as necessary, for making template variables safe for use in event data. Here's an example of event data, using template variables and the json filter:

Flow action
Event object
the json Liquid filter
Shopify Flow
Flow action
Flow's app store listing
the user domain
the User domain