Skip to main content
All CollectionsConnecting to Automation Apps
Connecting Admin Buttons to Mechanic
Connecting Admin Buttons to Mechanic

Trigger any Mechanic automation right from a Shopify admin page

Updated this week

Admin Buttons provides Shopify merchants with a flexible way to manually trigger automations right from their Shopify Admin pages. While Shopify Flow is a popular option for automating tasks, another powerful automation tool available for Shopify stores is Mechanic. Mechanic allows for more advanced, code-based automations and can integrate seamlessly with Admin Buttons to execute custom workflows.

In this article, we’ll guide you through the process of connecting Admin Buttons to Mechanic, enabling you to create custom actions that can be manually triggered by your store team.

Step 1: Create an Admin Button in Admin Toolkit

The first step to integrating Admin Buttons with Mechanic is to create a button in Admin Toolkit. This button will serve as the manual trigger for your Mechanic automation.

  1. Open the Admin Toolkit App: Navigate to the Admin Buttons section.

  2. Create a New Button: You can create a button from scratch or use one of the provided templates, such as those for applying tags to orders or creating draft orders.

  3. Customize the Button: Tailor the button’s title, appearance, and form fields based on the specific Mechanic automation you want to trigger.

Here's a detailed example of a commonly used Admin Button, and how to get it set up: Create a Draft Order from an Existing Order

Step 2: Set Up a Mechanic Task

Mechanic tasks are script-based automations that can be triggered by a wide range of Shopify events, or manually via API calls—perfect for integrating with Admin Buttons. To set up your Mechanic task:

  1. Log in to Mechanic: From your Shopify Admin, go to the Mechanic app.

  2. Create a New Task: Click on “Create new task” and write or paste the code for the task you want to trigger. Mechanic offers a variety of pre-built task templates, or you can write custom code to suit your needs.

  3. Add a Webhook Trigger: Mechanic can trigger tasks via a webhook, which will allow the Admin Button to start the task. The webhook URL for your Mechanic task can be found within the task’s settings.

If you’re new to Mechanic, their community templates and examples offer a good starting point. You can also use the Mechanic API documentation to explore advanced customization options.

Step 3: Integrate the Admin Button with Mechanic

Once you’ve set up both the Admin Button and the Mechanic task, it’s time to link them together using a webhook trigger:

  1. Get the Webhook URL: Copy the webhook URL from the Mechanic task settings.

  2. Add Webhook to the Admin Button: Go back to your Admin Toolkit app and edit the button you’ve created. In the button’s settings, add a form field where the webhook URL can be used as the action upon submission.

  3. Customize the Form: If necessary, you can customize the Admin Button’s form to capture additional data that will be passed to Mechanic when the button is clicked. This data can include order details, customer information, or any other variables relevant to your task.

Step 4: Test and Activate Your Mechanic Automation

After setting up the connection between the Admin Button and Mechanic, it’s important to test everything to ensure it works as expected:

  1. Test the Button: Go to the page where the button is placed (e.g., an order page) and click it to trigger the webhook.

  2. Monitor the Mechanic Task: In Mechanic, check the task logs to confirm that the task was triggered successfully and that all necessary data was passed through.

  3. Make Adjustments if Needed: If the data isn’t flowing correctly or the task doesn’t execute as expected, review the button’s form setup and the Mechanic task code for any issues.

Once the test is successful, your automation is ready to go live!

Another option: connecting to Mechanic with Flow

You can also trigger Mechanic tasks with their custom Flow action. In this case, you'd connect your Admin Button to Flow and then find the Mechanic action to “Send Event to Mechanic”. You can do any steps you'd like in Flow before or after triggering the Mechanic step. For instance, you can use the Run Code step to parse data out of the Admin Button form. See our article Getting Started with Shopify Flow and Admin Buttons for more details.

Use Cases for Admin Buttons and Mechanic

The combination of Admin Buttons and Mechanic opens up a wide array of possibilities for automating Shopify workflows. Here are a few use cases where this integration can be particularly powerful:

  • Automated Draft Orders with Special Rules: Create a form gathers info about the draft being created and then triggers a Mechanic task to generate draft orders with customized line items, discounts, or payment terms, beyond the options available in Shopify Flow

  • Custom Product Updates: Mechanic can update product details, inventory, or pricing based on criteria you define. With Admin Buttons, store staff can manually trigger these updates as needed from the product page.

Best Practices for Using Admin Buttons with Mechanic

To make the most of Admin Buttons and Mechanic, consider these best practices:

  1. Leverage Webhooks Efficiently: Mechanic’s webhook system allows Admin Buttons to trigger a wide range of custom actions. Ensure your webhook configuration is properly set up for reliable task execution.

  2. Use Variables for Flexibility: Admin Buttons can pass data from Shopify Admin pages into Mechanic tasks. Make sure to define these variables clearly in both the Admin Button form and the Mechanic task code.

  3. Test Regularly: Since Mechanic tasks often involve code, it’s important to test each integration carefully to avoid errors that could disrupt store operations.

Connecting Admin Buttons to Mechanic empowers Shopify merchants to build more advanced automations, triggered directly by store staff from Shopify Admin. Whether you’re managing complex tagging rules, automating draft orders, or updating product data, the flexibility of Mechanic combined with the ease of Admin Buttons offers a highly customizable way to streamline your Shopify store’s workflows.

Did this answer your question?