Shopify Webhooks using Otto
Otto from Proof+Geist can be used to receive webhooks from Shopify and have new Shopify Orders pushed automatically to your fmEcommerce Link (Shopify Edition) file. You will need to make a few small modifications to your copy of fmEcommerce Link (Shopify Edition) - we've added support for Otto webhooks in v2.1.8 of fmEcommerce Link (Shopify Edition).
If you're using an earlier version of fmEcommerce Link the required changes are outlined on the Otto website here and include creating a new layout, 2 new fields and 1 new script. You can copy/paste the OttoReceiver script from the v2.1.8 file to your file. Your new OttoReceiver layout (based on the Orders table) should look like this:
In the following example we will show you how to create an Otto webhook to receive new order notifications from Shopify (similar to the webhookNewOrder.php file). You can also adapt this for other supported webhooks such as order updates and new customer/customer updates.
Once you've made the necessary changes you need to create a new Otto Data API key by following the instructions here. We recommend using the supplied OttoDeveloperAPI.fmp12 FileMaker file to create the key which only takes a few minutes. When creating the Data API Key you can use the same FileMaker account that the webhookSignedEnvelope.php file uses here as it has the required access privileges for receiving incoming webhooks via the Data API:
Once you've generated the Data API Key for the fmEcommerce Link file you can make a note of the URL for the Shopify webhook. We are using the query parameter option to handle the authentication. The webhook URL should look something like this:
https://otto-server-url:3030/receiver/fmEcommerce Link (Shopify Edition).fmp12/shopify?apiKey=<your-api-key>
You now need to test the webhook trigger by creating a Shopify webhook on your Shopify store for a new order. fmEcommerce Link (Shopify Edition) supports creating webhooks from within the fmEcommerce Link file as well as those created on the Shopify website. We recommend creating the webhook on the Shopify website as you can send a test notification without having to enter a new test order. You can find instructions for creating a webhook on the Shopify admin page for your store here. Make sure you select the appropriate option for the Event (e.g. for the New Order webhook select Order creation) and enter the Otto webhook URL in the Delivery URL field. Once you have created and saved the Webhook it should look something like this:
After you have saved your webhook scroll to the right and click the Send test notification button to send a sample webhook to your Otto webhook URL:
Shopify will send a sample request to the Otto webhook URL to confirm that it is responding correctly. You should see the new order created and the data for the order populated into the appropriate fields - the the OttoReceiver layout should look like this for the newly created record:
You can also test this is working successfully by entering a test order on your Shopify store and confirming that the order record was created and the data for the order populated into the appropriate fields.