Tasks
In Mechanic, a task is a bundle of logic and configuration, that responds to and interprets events. The result of a task can define actions, which are the task's opportunities to have an effect on the world.
A task responds to events based on its subscriptions. When an event is received that matches a subscription, the task processes the event using its code. The code has access to the event data; it also has access to the user's task configuration, through options. Task code is written in Liquid, and is responsible for rendering a series of JSON objects (including action, error, and log objects), defining work to be performed once task rendering is complete.
A task uses its preview to communicate ahead of time the work it intends to do. Previews are important for users, and are also important for Mechanic itself â Mechanic looks to the task preview to understand what permissions a task requires.
Tasks may be written from scratch, or installed from the Mechanic library (available in-app and on GitHub). Once installed, a task's code may be modified at any time.
Working on getting better at task-writing? See Practicing writing tasks, and Writing a high-quality task.
Example
This very basic task subscribes to shopify/customers/create, and renders an Email action, using an email subject and body taken from user-configured options.
Last updated