intermediate

Shopify order lookup chatbot for n8n

An n8n chatbot that answers where-is-my-order questions from Shopify, checking the order number and email together so it never exposes someone else's order.

ChatbotAI agentEcommerce

Prerequisites

  • An n8n instance, cloud or self-hosted
  • A Shopify store and a custom app with the read_orders scope
  • The custom app's Admin API access token
  • An OpenAI API key (or another chat model credential)
  • Your product, shipping and returns FAQ copy as plain text

A chatbot that answers where is my order by looking the order up in Shopify. It also answers general product and shipping questions from your own content.

What you'll build

The bot asks for the order number and the email used on the order, both, then reports the fulfilment status, payment status, items and tracking number if one exists.

Why both. Order numbers are sequential, so anyone could type a nearby number and see someone else's order if the bot checked nothing else. The tool only replies if the email matches the order's own email. It is the same lightweight verification most track-my-order pages use, done inside a conversation.

How it works

  • A webhook receives each widget message and checks a shared secret.
  • An AI agent answers product and shipping questions from your knowledge text, and asks for both values before looking anything up.
  • The look_up_order tool is a separate workflow. It queries Shopify's GraphQL Admin API for the order and compares the email. If the order is missing or the email does not match, it replies that it cannot find a match and returns no order details.
  • The agent is told to state only what the tool returns and never to invent tracking numbers, statuses or delivery dates.

Two limits to know before you build:

Note: Only the last 60 days of orders are visible by default. The read_orders scope only exposes recent orders. Anything older needs read_all_orders, which requires separate approval from Shopify.

Note: This needs its own custom app with API read access, created in your Shopify admin. It is unrelated to any app you installed to embed your widget on your storefront.

What it costs

The workflow is free to download and use. Your AI provider charges per conversation, and your n8n hosting and the plan for the service you connect apply as normal. For N8N Chat UI plans, see pricing. There is no extra Shopify cost for creating a custom app or using the API.

Set it up

  1. Create a custom app. In Shopify admin go to Settings → Apps and sales channels → Develop apps → Create an app. Give it the read_orders scope (add read_all_orders if you need older orders and have Shopify's approval). Install it, then copy the Admin API access token from the API credentials tab. Shopify only shows it once.
  2. Create the credential. In n8n, create an HTTP Header Auth credential with Name X-Shopify-Access-Token and Value the token. This is not a Bearer token: Shopify uses its own header name, and pasting the token into an Authorization header will not work.
  3. Import the workflow. Download the file with the button at the top of this page and import it with Workflows → Import from File. It holds the main chatbot and its tool workflow on one canvas, each in a labelled section.
  4. Move each tool into its own workflow. n8n tools call a separate workflow, so for each tool section below the main flow: select its nodes, copy them, create a new empty workflow and paste. Save it, then open the matching tool node under the agent and select that workflow. Attach the credential to Call Shopify GraphQL.
  5. Fill in the settings. In Chatbot settings set company_name, knowledge and a random webhook_secret. In the look up order workflow's Tool settings set shop_domain (your .myshopify.com domain) and api_version. Shopify releases API versions quarterly, so check the value is not stale if you come back to this later.
  6. Add your AI credential. Open GPT-4.1 mini model and add your OpenAI credential. Swap the node for another chat model if you prefer.

Test it

Send a test message before you connect a widget. n8n's built-in chat panel needs a Chat Trigger, so it will not open for this workflow. Instead, click Test workflow, then send a POST request to the Test URL shown on the Chat webhook node:

curl -X POST 'YOUR_TEST_URL' \
  -H 'Content-Type: application/json' \
  -d '{"chatInput":"Hello","sessionId":"test-1","metadata":{"webhook_secret":"YOUR_SECRET"}}'

The test URL listens for one request each time you click Test workflow. For a longer conversation, activate the workflow and send requests to the production URL, then read each run under Executions. Reuse the same sessionId to continue a conversation, because memory is kept per session.

Things to try:

  • Ask a general question covered by knowledge. It should answer directly.
  • Give a real order number and its real email. Status, items and tracking should come back correctly.
  • Give a real order number with the wrong email. It should say it cannot find a match and show nothing.
  • Give a made-up order number. It should say it cannot find that order.
  • Ask to cancel or change an order. It should decline and explain it can only look up status.

Add it to your site

Activate the workflow and use its production webhook URL as your widget's chat endpoint. Send the same secret in the widget metadata, for example metadata: { page_url: window.location.href, webhook_secret: 'YOUR_SECRET' }. The metadata docs explain how metadata reaches n8n.

Any chat front end that can POST chatInput, sessionId and metadata to a webhook and read { "output": "..." } back will work. N8N Chat UI is built for exactly this.

What this bot cannot do

This recipe is read-only by design. It cannot cancel an order, issue a refund or change an address. If a visitor asks for any of that, the bot says so plainly and offers to note the request down rather than pretend it can help. Write capability is a different, larger trust surface than a status lookup and is not in scope here.

Troubleshooting

I get a 401 from Shopify

Check the credential's header name is exactly X-Shopify-Access-Token, not Authorization.

I get a 401 immediately, even with correct credentials

The workflow's own secret check runs before your request reaches Shopify. Check metadata.webhook_secret in your request matches webhook_secret in Chatbot settings.

The bot cannot find older orders

Expected on the default scope. See the 60-day note above.

Tracking numbers are not showing for a shipped order

The tracking fields in the GraphQL query have not been confirmed against a live order with tracking. If a shipped order shows no tracking, check the code in Verify email match and format and the query in Call Shopify GraphQL against Shopify's current schema.

Does it work with Shopify Plus?

Yes. Nothing here is specific to Plus.

The bot replies but the tool never runs

The tool node is not linked to its workflow. Open it and select the workflow you created from the tool section. A bare placeholder ID means it is still unlinked.

My conversations reset when n8n restarts

Memory is an in-memory buffer so the template works as soon as you import it. A restart or redeploy drops conversations in progress. Before a busy launch, swap Conversation memory for Postgres Chat Memory. Nothing else changes.

Take it further

For a WordPress store, see the WooCommerce version. If your product and shipping content outgrows a pasted block, the Supabase knowledge base chatbot shows the swap to a vector store.