Relay Shopify webhook with custom payload in Shopify by using Arigato Automation
Simplify the process of relaying webhooks from Shopify to another system by leveraging Arigato Automation, saving you the hassle of setting up an entire server and serving as a significant time-saver for sending order data to external systems.
This example automation is triggered when an order is paid, but you can choose a different trigger if you'd like. It checks if the order contains your special product. If the product is found in the order, it sends a POST request to the URL of your choice, relaying the Shopify webhook with your own payload. The headers and the body data of the POST are fully configurable.
This example is an ideal starting point for any Shopify integration project that would normally require setting up a server just to manipulate Shopify webhook payload data before sending it to your own system or a third-party system. Instead of setting up and maintaining a server for such a simple task, you could easily change the payload into the format you need using the Arigato Automation app before sending it on to its final endpoint.
Testing your relayed webhook
To test this workflow, we recommend the handy tool at https://webhook.site which allows you to send it data that is displayed in real time. This is incredibly helpful for debugging.
For testing, in the app, set up your POST URL to use the URL that the webhook.site tool assigns to you. Then, using our Test Center, trigger the action. You'll immediately see your payload posted on the testing website.
Formatting Your Payload
Usually, you'll want to send the payload as JSON, or sometimes as form data instead of JSON. Remember, Arigato Automation has a filter to convert object data to JSON. Here is an example where we simply build up an array of data and then convert it to JSON when we print it. Our example simply creates an array of all the SKUs in an order and prints the array as JSON.
{% set myarray = [] %}
{% for line_item in order.line_items %}
{% set myarray = myarray|merge([{ 'sku': line_item.sku }]) %}
{% endfor %}
{{ myarray | to_json }}