Skip to main content

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.

Written from Shopify documentation

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​

  1. Open Flows → Connections, press Connect a system and choose Shopify.
  2. Press Copy address. It looks like https://events.alphasms.net/hooks/<TOKEN> — keep it secret.

Step 2. Set up webhooks in Shopify​

  1. Open Settings → Notifications → Webhooks and press Create webhook.
  2. Event — Order creation (orders/create).
  3. Format — JSON.
  4. URL — the address from the cabinet.
  5. Webhook API version — the latest stable version.
  6. Press Save.
  7. 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.

  1. Open Apps → Shopify Flow, press Create workflow and choose the trigger Order created.
  2. Add the action Send HTTP request.
  3. HTTP method — Post.
  4. URL — the address from the cabinet.
  5. Headers — Content-Type with the value application/json.
  6. Body — the template below.
  7. On client error (4XX response) — Fail; On server error (5XX or 429 response) — Retry.
  8. 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 | json filter puts the quotes and escapes the value; an empty value stays null. 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 and order_shipped, for a cancellation — Order cancelled and order_cancelled. Change the event both in event and in message_id, for example shopify_flow:order_paid:{{ order.legacyResourceId }}. Never put order_paid into a workflow on Order created: a new order is not yet paid.
  • If order.phone is 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​

ShopifyAlphaFlow eventProperties
Webhook Order creation (orders/create)order_createdorder_id, order_number, total, currency, financial_status, status_url
Webhook Order payment (orders/paid)order_paidthe same
Webhook Order fulfillment (orders/fulfilled)order_shippedthe same, and fulfillment_status, ttn, carrier
Webhook Order cancellation (orders/cancelled)order_cancelledthe same, and cancel_reason
Webhooks Checkout creation, Checkout updatecart_updatedtotal, currency, checkout_url
Shopify Flow workflowthe event in eventorder_id, total, currency, status_url
  • order_id is the number the customer sees, for example #1001. status_url is the page with the status of the order for the customer, checkout_url — the link to the left checkout.
  • ttn and carrier come 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, 5XX and 429 for 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 with quota_exceeded and shown in the journal; the webhook in Shopify stays on.

Shopify documentation​