Creating a Mechanic webhook
Last updated
Last updated
Important Updates
đŖ Shopify REST DeprecationWebhooks are the nearly ubiquitous carriers of information to and from services across the internet - services like IFTTT, Zapier, Stripe, PayPal, JotForm, and countless more. You can use webhooks to send information from these services into Mechanic, where you can then perform any logic and actions you need.
This is a tutorial for getting started quickly. To learn more about webhooks themselves, see Mechanic webhooks.
When Mechanic receives data via a webhook, it fires off an event with the user topic of your choice. (For example, if you've set up an IFTTT webhook that sends you tweets, you might choose the Mechanic topic user/ifttt/tweet
.) To make use of these events, create one or more tasks that subscribe to this topic. That's it!
Let's review a detailed example.
Start by opening Mechanic, from the "Apps" section of Shopify. Once in Mechanic, click the "Settings" button in the upper-right corner, then navigate to the "Webhooks" tab.
Webhooks should be named after the service that will be sending you data, with an event topic that makes sense, using the format user/subject/verb
.
For this example, we'll simply call ours "Example", with an event topic of "user/webhook/test".
Click the submit button to save the webhook, and use the copy button to copy the resulting webhook URL.
The URL will look something like this:
Older webhook URLs resemble https://usemechanic.com/webhook/00...00
. This URL structure still works, but we recommend migrating to https://webhooks.mechanic.dev/00...00
instead, for enhanced reliability.
Back on the Mechanic homepage, click the "Add task" link.
Then, click the "Start a blank task" button.
Keeping things simple for this example, we'll title the task "Webhook test", with a subscription to "user/webhook/text" (to match the webhook configuration), and a simple Echo action in the task code.
Lastly, save the task.
Open https://reqbin.com/, and construct a request to our webhook. Here, we'll select "POST", paste in the webhook URL, and fill in a simple piece of content. (Webhooks support plain text, form-encoded content, and JSON; for this example, we'll use JSON.)
Click the "Send" button, and you'll see a 204 response returned within ReqBin.
Over in Mechanic, watch for the new event on the "Events" page (or in the "Recent events" section of the Mechanic homepage):
Click on that event to see the results of our task and its echo action.
This last part is up to you! Provide the webhook URL, generated by Mechanic, to whatever service you'd like to use. When provided with this URL, the service will start sending your data over to Mechanic for processing.
That's it! :) Adjust to taste.