Webhooks are the nearly ubiquitous carriers of information to and from services across the internet - services like IFTTT, Zapier, Stripe, PayPal, JotForm, and countlessly more. You can use webhooks to send information from these services into Mechanic, where you can then perform any logic and actions you need.
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, scroll down to the "Your account" section, and click the "Manage settings" link.
Next, click the "+ Add a webhook" button, towards the end of the settings pag.
Webhooks should be named after the service that will be sending you data, with an event topic that makes sense, using the format
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 copy the resulting webhook URL.
The URL will look something like this:
However, if you wish to call your webhook from another origin (say, a third-party iframe within your storefront), you'll need to add its origin to your Mechanic account. Add the origin (comprised of the scheme, usually "https://", and the hostname) here:
... and save your settings.
Back on the Mechanic homepage, click the "Start a custom task" link.
Keeping things simple for this example, we'll title the task "Webhook test", fill in the subscription field with "user/webhook/text" (to match the webhook), and click the "Echo" button beneath the script editor to quickly fill in a simple "echo" action.
Lastly, save the task. Note the action preview that's generated: "When user/webhook/test is triggered…".
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 the "Recent activity" list on the app homepage to see the incoming event.
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! :) Modify to taste.