> Every page of the Heythere docs is listed in https://heythere.io/docs/llms.txt: fetch it to find a page instead of guessing its URL.

# Shopify: send WhatsApp order updates from your store

> Confirm each Shopify order on WhatsApp, tell customers it shipped, and keep their WhatsApp marketing consent, with what to set in Shopify and Heythere.

Camille orders a lamp from the Lumen store on Shopify, order #1001, and a few seconds later the store's WhatsApp number thanks her for it. Heythere has no Shopify app: Shopify posts each order to a [webhook source](https://heythere.io/docs/concepts/webhook-sources) of the workspace, whose request starts an [automation](https://heythere.io/docs/concepts/automations) at a `webhook.received` [trigger](https://heythere.io/docs/concepts/triggers), and the automation sends Camille a [template](https://heythere.io/docs/concepts/message-templates).

## What do I set in Shopify?

In the Shopify admin, open Settings, then Notifications, then Webhooks, and select Create webhook once per event below. Each takes the event, the format JSON, the URL of its own webhook source, and the latest API version. No Shopify app is needed.

Below the list, Shopify shows the key every webhook of the store is signed with. A member types it as the value of one workspace [secret](https://heythere.io/docs/concepts/secrets), such as `shopify_signing_secret`, declared with no origin, since Heythere only checks signatures with it.

## What do I set in Heythere?

One webhook source per Shopify event, created with `saveWebhookSource`: an automation takes one trigger per source, and each event holds the customer's phone number in another place. Every source checks Shopify's signature the same way:

- `verification`: type `hmac_sha256`, the secret `shopify_signing_secret`, header `X-Shopify-Hmac-Sha256`, encoding `base64`, and an empty prefix.
- `eventKeyPath`: `headers.x-shopify-webhook-id`, so a delivery Shopify sends again starts nothing twice.

Each source's trigger reads the customer's phone number at the first of its `contactPhoneNumberPaths` that holds one:

| Shopify event                              | Source             | `contactPhoneNumberPaths`                            |
| ------------------------------------------ | ------------------ | ---------------------------------------------------- |
| Order creation                             | `shopify_orders`   | `body.customer.phone`, `body.shipping_address.phone` |
| Order fulfillment                          | `shopify_shipping` | `body.customer.phone`, `body.shipping_address.phone` |
| Customer WhatsApp marketing consent update | `shopify_consent`  | `body.phone_number`                                  |

Shopify checks a customer's phone number and sends it in international format, such as +33639980101. A number typed only in a shipping address can come as 06 39 98 01 01, which the trigger reads once its `contactPhoneNumberCountry` is the store's country, such as `FR`. When no contact has the number, the trigger adds Camille, so her first order reaches her.

## How does Camille get her order confirmation?

The `shopify_orders` trigger reads her first name at `body.customer.first_name`, #1001 at `body.name`, 49.90 at `body.total_price` and the lamp at `body.line_items.0.title`, each as a field such as `order_number`. It leads to a `send_template` [step](https://heythere.io/docs/concepts/steps) sending a utility template, such as "Thanks {{first_name}}, your order {{order_number}} for {{item}}, {{total}} €, is confirmed", whose variables the step fills with `{{trigger.first_name}}`, `{{trigger.order_number}}`, and so on. Its run sends only templates, since Camille may never have written to the number, and her `utility` [consent](https://heythere.io/docs/concepts/contacts#what-does-a-contact-consent-to-) lets it through unless she withdrew it.

## How does Camille learn her order shipped?

For an order shipped in one parcel, whose tracking number the store types as it marks the order fulfilled, choose Shopify's Order fulfillment event. Shopify sends it with the whole order once every item has shipped, so it holds her phone number and the tracking number at `body.fulfillments.0.tracking_number`, with its link at `body.fulfillments.0.tracking_url`. Fulfillment creation holds no customer phone number, only the order's ID, so it starts no run.

## Can an automation read her order?

Yes: an `http_request` step reads it from the Admin API, sending a Dev Dashboard app's token kept in a [secret](https://heythere.io/docs/concepts/secrets#what-about-a-service-that-gives-an-app-its-own-token-such-as-shopify-), such as `shopify_admin`, in the `X-Shopify-Access-Token` header.

## How does her WhatsApp marketing consent reach Heythere?

When Camille's WhatsApp marketing consent changes in Shopify, such as when the store ticks it on her customer page, Shopify sends a consent update. A `condition` step on its state, read at `body.whats_app_marketing_consent.state`, leads `subscribed` to a `set_value` step setting `contact.marketingConsent` to `granted`, and `unsubscribed` to one setting it to `withdrawn`.

## What does not work today?

- **Trying it before a real order.** Shopify's Send test posts a made-up order whose phone numbers are not real, which starts nothing, and a [test](https://heythere.io/docs/concepts/tests) starts only from a message. Once an administrator published the automation and Meta approved its template, a member tries it with a real order placed with their own phone number.
- **An event while a run or a live chat holds Camille's conversation.** An order, a shipment or a consent update then starts nothing (`run_active`, `live_chat_ongoing`), and Shopify does not send it again, since Heythere took it.

## Where do I look when Camille got nothing?

Each source's events (`listWebhookSourceEvents`) show what it received in the last 30 days, with what each trigger did, such as `contact_phone_number_country_missing` for a national number read without the store's country. A request whose signature failed shows only in the source's `lastRefusal`, where a `signature_mismatch` refusal means its secret holds another key than the one Shopify shows under Webhooks.
