Shopify
Shopify is a hosted platform for online shops. It can call an address in two ways: webhooks in the admin send the order as Shopify keeps it, and the Send HTTP request action of the Shopify Flow app sends a body you write yourself. Either way the request starts your flows: an order is placed, paid, fulfilled or cancelled, a checkout is left without an order — and the customer gets the right message in Viber or SMS.
This page is written from the public documentation of Shopify and has not been checked on a live account yet.
What you need
- Webhooks in the admin — any plan, Basic included, and no app. They are in Settings → Notifications.
- Shopify Flow — plans Grow, Advanced and Plus. On Basic there is no Send HTTP request action: use webhooks.
- One address for everything. Webhooks: one webhook per event. Shopify Flow: one workflow per event.
Step 1. Create a connection
- Open
Flows → Connections, press Connect a system and choose Shopify. - Press Copy address. It looks like
https://events.alphasms.net/hooks/<TOKEN>— keep it secret.
Step 2. Set up webhooks in Shopify
- Open Settings → Notifications → Webhooks and press Create webhook.
- Event — Order creation (
orders/create). - Format — JSON.
- URL — the address from the cabinet.
- Webhook API version — the latest stable version.
- Press Save.
- Create a webhook the same way for each event you need: Order payment (
orders/paid), Order fulfillment (orders/fulfilled), Order cancellation (orders/cancelled); for abandoned checkouts — Checkout creation (checkouts/create) and Checkout update (checkouts/update). The URL is the same.
- The names of the events in the list are not confirmed by the Shopify help, which speaks only of "any of the supported webhook events"; the topics in brackets come from the developer documentation.
- The event of a webhook cannot be changed after it is created: create a new webhook instead.
- Under the list of webhooks Shopify shows the line "Your webhooks are signed with …". You can paste this key into the connection as its secret, and AlphaFlow then checks the signature of every request. It is optional.
Shopify Flow: a body of your own
In Shopify Flow you write the body of the request yourself, so it carries the event in the AlphaFlow format straight away. Plans Grow and higher.
- Open Apps → Shopify Flow, press Create workflow and choose the trigger Order created.
- Add the action Send HTTP request.
- HTTP method — Post.
- URL — the address from the cabinet.
- Headers —
Content-Typewith the valueapplication/json. - Body — the template below.
- On client error (4XX response) — Fail; On server error (5XX or 429 response) — Retry.
- Turn on workflow.
{
"event": "order_created",
"message_id": "shopify_flow:order_created:{{ order.legacyResourceId }}",
"occurred_at": {{ order.createdAt | json }},
"dedupe_key": {{ order.name | json }},
"contact": {
"external_id": {{ order.customer.legacyResourceId | json }},
"phone": {{ order.phone | json }},
"email": {{ order.email | json }}
},
"traits": {
"first_name": {{ order.customer.firstName | json }},
"last_name": {{ order.customer.lastName | json }}
},
"properties": {
"order_id": {{ order.name | json }},
"total": {{ order.totalPriceSet.shopMoney.amount | json }},
"currency": {{ order.currencyCode | json }},
"status_url": {{ order.statusPageUrl | json }}
},
"context": { "source": "shopify_flow" }
}
- The
| jsonfilter puts the quotes and escapes the value; an empty value staysnull. Do not put quotes around variables by hand: a name or an address with a quote in it would break the JSON. - One workflow is one event. For a payment choose the trigger Order paid and the event
order_paid, for a fulfillment — Order fulfilled andorder_shipped, for a cancellation — Order cancelled andorder_cancelled. Change the event both ineventand inmessage_id, for exampleshopify_flow:order_paid:{{ order.legacyResourceId }}. Never putorder_paidinto a workflow on Order created: a new order is not yet paid. - If
order.phoneis empty (the phone is optional at checkout), use{{ order.shippingAddress.phone | json }}. - The path to the tracking number in the variables of Order fulfilled is not confirmed by the documentation, and neither are the variables of the abandoned checkout trigger (Customer abandons checkout).
Step 3. Send a test
- Webhooks: in the row of the webhook press ⋯ → Send test — Shopify sends a sample order with made-up data. Then place a test order with your own phone number.
- Shopify Flow: place a test order or run a test of the workflow (Run test — the name of the button is not confirmed by the documentation). The run is listed in the Run history of the workflow.
The event appears in Flows → Connections → Event journal
within seconds. The connection shows Recognised: Shopify for webhooks and Recognised: Shopify Flow for
workflows.
Events
| Shopify | AlphaFlow event | Properties |
|---|---|---|
Webhook Order creation (orders/create) | order_created | order_id, order_number, total, currency, financial_status, status_url |
Webhook Order payment (orders/paid) | order_paid | the same |
Webhook Order fulfillment (orders/fulfilled) | order_shipped | the same, and fulfillment_status, ttn, carrier |
Webhook Order cancellation (orders/cancelled) | order_cancelled | the same, and cancel_reason |
| Webhooks Checkout creation, Checkout update | cart_updated | total, currency, checkout_url |
| Shopify Flow workflow | the event in event | order_id, total, currency, status_url |
order_idis the number the customer sees, for example#1001.status_urlis the page with the status of the order for the customer,checkout_url— the link to the left checkout.ttnandcarriercome only if the tracking number was entered before the order was fulfilled.
The contact of a webhook is found by the first phone that is filled in — of the order, of the shipping address, of
the billing address, of the customer (the phone of the order itself is often empty), — by the email and by the
Shopify id of the customer. The phone is optional at checkout: an order without it reaches the contact by the
email. In Shopify Flow the contact is what you put into contact. The names of the events are the ones the ready-made templates expect — see
Recommended events.
Good to know
- Shopify waits 1 second for the connection and 5 seconds for the whole request. If the answer is not
2xx(a redirect included) or there is no answer, it repeats the request 8 times within 4 hours, and a subscription that keeps failing is deleted. A repeat carries the same webhook id and is not recorded twice. - Shopify Flow waits 30 seconds for the answer; with Retry it repeats on
4XX,5XXand429for up to 24 hours. - Order fulfillment comes when all items of the order are fulfilled. A tracking number entered later comes with
another webhook (
fulfillments/update), which this connection does not read. The tracking number is an ordinary property: AlphaFlow does not track the parcel. - Refunds (
refunds/create) carry neither a phone nor an email, and order updates (orders/updated) fire on any edit — neither is among the events of this connection. - The address always answers
200. Above the daily event limit the event is refused in AlphaFlow withquota_exceededand shown in the journal; the webhook in Shopify stays on.