intermediate

WooCommerce order lookup chatbot for n8n

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

ChatbotAI agentEcommerce

Prerequisites

  • An n8n instance, cloud or self-hosted
  • A WooCommerce store, with WordPress permalinks set to anything other than Plain
  • A WooCommerce REST API key with Read permission (consumer key and secret)
  • 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 WooCommerce. 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 order status, total and items.

Why both. WooCommerce order numbers are sequential by default, 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 billing email matches the order. 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 fetches the order from the WooCommerce REST API and only replies if the billing email matches. If it 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.

Things that differ from the other recipes:

Note: Authentication is HTTP Basic: your REST API consumer key is the username and the consumer secret is the password. That is WooCommerce's own native method, not a workaround.

Note: There is no tracking number by default. WooCommerce core does not store one. Tracking comes from whichever shipping plugin your store uses, with its own separate API, which this recipe does not call. It reports status, total and items only.

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. The WooCommerce REST API has no extra cost.

Set it up

  1. Create a REST API key. In WordPress admin go to WooCommerce → Settings → Advanced → REST API → Add key. Set permissions to Read and generate. Copy the consumer key and secret now; the secret is only shown once. Check that Settings → Permalinks is not set to Plain, because the REST API does not work on the default Plain setting.
  2. Create the credential. In n8n, create an HTTP Basic Auth credential with your consumer key as the username and your consumer secret as the password.
  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 WooCommerce API.
  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 store_url, your site's full URL with no trailing slash.
  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 billing email. Status, total and items should come back.
  • 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 or 403 from WooCommerce

Check your permalinks are not set to Plain. This is the most common cause of WooCommerce REST API failures and looks like an auth problem even though it is not.

I get a 401 immediately, even with correct credentials

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

The lookup returns nothing for a real order number

WooCommerce order numbers usually equal the internal order ID. Some stores use a plugin that generates separate sequential order numbers. If yours does, the lookup needs to search by that plugin's field instead of the ID. Check the plugin's documentation for its field name.

Does it work with WooCommerce Subscriptions or other extensions?

The core lookup reads standard order data, so it works whichever extensions you run. Extension-specific data, such as subscription renewal dates, is not included.

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 Shopify store, see the Shopify version. If your product and shipping content outgrows a pasted block, the Supabase knowledge base chatbot shows the swap to a vector store.