Skip to content

The open-source AI receptionist for businesses. Answers every call, books the appointment and hands over to a person when needed. You own the code and the data.

Shopify: ask for read_all_orders so orders older than 60 days are found (PR 2060)

Tim Gutberletf36e68862d9c
diff --git a/docs/crm-sync.md b/docs/crm-sync.md
index a8e756d5..b327c2ab 100644
--- a/docs/crm-sync.md
+++ b/docs/crm-sync.md
@@ -86,7 +86,7 @@ Shopify is the store of a business that sells online. Unlike the other apps it a
- Webhook (`shopify-webhook.ts`; the privacy topics come from the app's configuration, `app/uninstalled` is subscribed per store right after it connects, since the legacy install flow allows no app-wide one), signed with the client secret (`X-Shopify-Hmac-SHA256`, 401 when wrong): `app/uninstalled` and `shop/redact` delete every connection to the store; `customers/redact` deletes the links to that customer; `customers/data_request` is answered 200 (Linedesk keeps no Shopify customer data besides those links).
- During the call (`apps/api/src/shopify-calls.ts`, `apps/agent/src/shopify-tools.ts`): `call.start` says whether a store is connected and which changes and checks are on. The agent asks `shopify.callContext` beside the greeting (the customer with the caller's number and their last three orders, the store's policies, cut at 1500 characters and kept 10 minutes) and adds it to the instructions when it arrives; a slow store never holds up the greeting. Tools: `find_orders` (order number, email, name, phone or the caller's own number; a postcode narrows; optional status), `find_products` (active products: price, variants, stock), and only when switched on `start_return` (a return request the store approves), `change_shipping_address` (merged into the current address; only unfulfilled orders) and `cancel_order` (only unfulfilled orders; restock, refund to the original payment, the customer is notified). Reading needs no check, so reads never give what a check compares: an order shows its status, items, total, shipments and the city and country it goes to, never the name, street, postcode or email; the call-start customer is named by first name only, and only for a caller whose number the carrier vouched for (security review of #1531). A change needs the checks the business picked (`verify_*`, default the name and the postcode the order ships to; at least one, the settings refuse none): the API compares, never the model. The family name must match the order's; postcodes compare without spaces (US on five digits); the caller's number counts only with full STIR/SHAKEN attestation (A); the order number never counts as the one check that must stay on. Three wrong answers in a call and no change is possible on it; one change per call. A changed address tags the order `Linedesk: address changed by phone` (Shopify emails the customer nothing for it). Store data reaches the model fenced as data.
- After the call: `pushCallToCrm` with customers: found by the stored link, the caller's number (`phone:`) or email; created only with `create_contacts` on (off by default for Shopify); the call goes on top of the customer's note (Shopify has one note per customer; the oldest calls are cut at 4500 characters) and the customer gets the tag `Linedesk`.
-- Protected customer data: a store that is not a development store answers names, emails, phones and addresses only once the app has Shopify's protected customer data approval (Partner Dashboard › API access). Orders older than 60 days need `read_all_orders`, which Shopify grants on request; without it searches see the last 60 days.
+- Protected customer data: a store that is not a development store answers names, emails, phones and addresses only once the app has Shopify's protected customer data approval (Partner Dashboard › API access). Orders older than 60 days need `read_all_orders`, which Shopify grants on request; the app asks for it, and without it (a store connected before) searches see the last 60 days.
## Zoho CRM
diff --git a/integrations/shopify/README.md b/integrations/shopify/README.md
index a68250ce..aafb3b9a 100644
--- a/integrations/shopify/README.md
+++ b/integrations/shopify/README.md
@@ -32,7 +32,10 @@ Linedesk.
- Tokens: expiring offline tokens (one hour, rotating refresh token). A refresh token not used for 90 days runs out:
the connection then needs to be connected again.
-- Orders older than 60 days need the `read_all_orders` scope, which Shopify grants on request.
+- Orders older than 60 days need the `read_all_orders` scope, which Shopify grants on request (Dev Dashboard › the app ›
+ Settings › Access requests › Read all orders). Without it, Shopify's searches see only the last 60 days: a caller's
+ older order is not found by its number. The app asks for it; a store connected before keeps its old scopes until it
+ connects again.
- Every request names the Admin API version (`SHOPIFY_API_VERSION` in `packages/connectors/src/shopify.ts`). Shopify
supports each version for 12 months: move it forward each year with the changelog at shopify.dev/changelog.
@@ -49,7 +52,7 @@ embedded = false
[access_scopes]
use_legacy_install_flow = true
-scopes = "read_customers,write_customers,read_orders,write_orders,read_returns,write_returns,read_products,read_inventory,read_legal_policies"
+scopes = "read_customers,write_customers,read_orders,read_all_orders,write_orders,read_returns,write_returns,read_products,read_inventory,read_legal_policies"
[auth]
redirect_urls = ["<origin>/v1/apps/callback/shopify"]
diff --git a/packages/connectors/src/shopify.ts b/packages/connectors/src/shopify.ts
index 64815075..6e68130b 100644
--- a/packages/connectors/src/shopify.ts
+++ b/packages/connectors/src/shopify.ts
@@ -26,12 +26,15 @@ import {
export const SHOPIFY_API_VERSION = '2026-10'
/**
* The scopes the app asks for in the consent URL: customers to find the caller and add the call note; orders,
- * returns and products for the assistant's tools; the shop's policies for what it knows. Write scopes include read.
+ * returns and products for the assistant's tools, `read_all_orders` so an order older than 60 days is found too (a
+ * caller asks about it by its number; Shopify grants it on request, LIN-899); the shop's policies for what it knows.
+ * Write scopes include read.
*/
export const SHOPIFY_SCOPES = [
'read_customers',
'write_customers',
'read_orders',
+ 'read_all_orders',
'write_orders',
'read_returns',
'write_returns',