Order Sync
In this guide, we'll take a look at how to use Alloy to configure Order Sync workflows with popular e-commerce applications.
Use Case Overview
Let's assume you're building an app that syncs order data from an e-commerce system such as Shopify to another application your business uses internally. You need to first obtain a historical listing of all the relevant orders and then subscribe to realtime events each and every time an order is placed.
To do this, we'll build a few workflows. Our first workflow will grab the historical list of all available orders. Our second workflow will set up realtime event forwarding to subscribe us to incoming orders placed and pass them along to your application. Lastly, our third and final workflow will subscribe to all order updates so you can be alerted each and every time an update (e.g. a status change) occurs on an order.
Let's dive in!
Syncing Historical Orders
Create a new workflow. For the trigger, we'll select "On Installation" as our trigger. This trigger tells Alloy to only run this workflow once - when you connect your Shopify account to Alloy.
Next, add an e-commerce connector. For our demo, we'll use Shopify but you can easily use others like BigCommerce, Adobe Magento, WooCommerce, etc. Select the list all orders action.
Lastly, add a Stream Data connector. This connector will tell Alloy where to send all the order records to. Specify a destination URL of your choosing. You can see an example of this workflow below.
Realtime Order Updates
Lastly, let's create a workflow that alerts us each time an order is updated in our e-commerce system. This is helpful to understand changes in the order state (i.e. if the status changed). For this workflow, we'll choose the Shopify Trigger as our starting point and subscribe to the Order Updated event.
Add a Stream Data connector to send over the order payload in real time to your application. You can see an example of this workflow below.
Wrapping Up
As you can see, it's easy to create workflows that subscribe to both historical and realtime order data in e-commerce systems. Let's take a look at what we covered in this tutorial:
- We used the On Installation connector to run a historical sync to fetch all historical Order records and send it back to your application.
- We set up another workflow to update us whenever an Order record is updated.