githubEdit

Events

Events are triggers that start Mechanic tasks — Shopify webhooks, schedules, or custom sources.

An event represents something that happened — a new order, a product update, midnight rolling around, or a webhook arriving from an external service. Events are the entry point to all Mechanic automation: when an event occurs, Mechanic checks which tasks are subscribed to it and runs them. Tasks can also emit new events, making it possible to build multi-step workflows where one task's output drives another.

An event always has a topic and data (even if the data is null/nil). Event attributes may be referenced in Liquid using the Event object.

Where events come from

Events reach Mechanic from several sources:

  • Shopify webhooks — Shopify sends events when something changes in your store. For example, shopify/orders/create fires when a new order is placed, and shopify/products/update fires when a product is edited. These are the most common event source.

  • Schedules — Mechanic can generate events on a schedule. A topic like mechanic/scheduler/daily fires once per day, useful for reporting, cleanup, or monitoring tasks.

  • On-demand runs — Tasks can be run manually using mechanic/user topics. Topics like mechanic/user/trigger, mechanic/user/text, and mechanic/user/form add a "Run task" button in the Mechanic app. Topics like mechanic/user/order respond to Shopify admin action links.

  • Custom events — Developers can define their own event topics in the user/ domain (e.g. user/orders/export). Tasks can generate them with the Event action, which is useful for chaining tasks together in multi-step workflows. Mechanic webhooks can generate them from external HTTP requests, and custom Shopify webhooks can generate them from filtered or customized Shopify webhook deliveries.

Each event carries data that tasks can use. For a Shopify webhook event, this is the resource data sent by Shopify (e.g. the order object). For scheduled events, the data is minimal. Tasks access this data through the Event object in Liquid.

For a complete reference of available event topics, see the Event topic list.

What happens next

When an event arrives, Mechanic creates a run to process it. Each run evaluates every task that subscribes to that event's topic. If a task generates actions (like a Shopify API call or an email), those actions are queued and performed after the task run completes.

This is the core execution flow: EventTask RunAction Run(s). To learn more, see Runs.

circle-info

Incoming events may be selectively skipped using event filters. For handling high-frequency events, see Debouncing events.

Last updated

Was this helpful?