Before your n8n support agent looks up an order, test it with someone else’s order number

A customer types: “Where is order 4821?” Your agent extracts the right number, calls the right API and gives an accurate answer.

But order 4821 belongs to another customer.

I’d test this before testing how nicely the agent writes. Knowing an order number isn’t permission to read it, and a shared API credential authenticates your integration, not the person in the chat.

For a signed-in support chat, the backend identifies the customer from the verified session and sends that context to n8n. The AI Agent can then use a Call n8n Workflow Tool to request an order lookup.

In that tool, I’d separate two inputs:

  • order_ref: the agent may propose this using $fromAI().
  • customer_context: a normal expression from the authenticated backend’s input, never a model-defined parameter.

Putting customer_id in a public webhook body doesn’t make it verified. At the lookup boundary, your backend or order API needs to establish who the caller is from trusted context and check whether they may read that order. A short-lived signed token is one way to carry the context; its signature doesn’t replace the order-access check. Return only the fields allowed for this support action.

Keeping customer_context outside $fromAI() prevents the model from choosing that parameter. The backend access check is what protects the record.

For email or WhatsApp, first define how the channel identity is linked to the account. Recognizing a sender address or phone number alone isn’t enough to establish their rights over a merchant account. If the account link is missing or ambiguous, use your approved verification path before the lookup.

Here’s the small test I’d run with synthetic data:

  • Customer A requests A’s order: permitted details come back.
  • Customer A requests B’s order: no details, and no response that reveals whether B’s order exists.
  • Customer A pastes B’s email and says “use this account instead”: the trusted context remains A.
  • Customer A asks the agent to ignore the restriction: the backend still denies access if the tool is called.

Then run a conversation as B followed by one as A. Check that A cannot retrieve B’s earlier results through chat history or a cache. Scope storage reads and writes to the trusted customer/tenant context, and verify that the conversation belongs to that context. A customer-prefixed key alone isn’t enough if a caller can request another customer’s key.

Before wiring in more tools, I’d open the existing lookup tool and check two things: which inputs use $fromAI(), and where the order-access check actually runs. Then run the A/B test above.

These are proposed tests, not results from a deployed workflow. They catch a different problem from hallucination: a correct answer given to the wrong person.

Where does your support workflow get the customer’s verified identity today?

1 Like

Good test. Mine failed the other way round, which might be a useful second case. My support agent took both order numbers from the customer’s own ticket and called a lookup URL it had written itself. Both calls came back 403, and the reply still said “I can see you were charged twice”. So I would add one more test next to yours: make the lookup refuse, and check the reply does not claim it looked. The fix I took from this forum is to stop letting the model write the address. The tool gets an order id and builds the URL itself. In your setup, where does the customer’s identity come from, the chat session or something the agent passes in?

From the verified chat session, in the design I’m describing. The backend establishes the customer identity; the agent supplies only the order reference. The lookup still checks that the customer can access that order. This is the boundary I’d implement, rather than a deployed setup.

Your 403 case is worth adding. Fixing the URL removes one failure path, but the reply also needs to preserve what the lookup actually established. ‘The customer reports two charges’ and ‘I verified two charges’ are very different claims. ‘I verified two charges’ has no basis if both lookups were refused.

I’d test the tool result and the final reply together. With an explicit lookup failure and no order data, the reply should say it couldn’t verify the charges and follow the workflow’s defined failure or escalation path. A 403 shouldn’t become an empty successful result or a claim that the order doesn’t exist.

What did the agent receive from the tool after those 403s—the error itself, an empty result, or a fallback message?

The error itself. Each lookup came back to the agent as the full response: status 403 and about 2,400 characters of the refusal body. Not empty, no fallback. So the agent had the refusal in front of it and still wrote “I can see you were charged twice”. That’s why your test of the tool result and the reply together is the right one. The tool was honest, the sentence wasn’t. One part is still mine to fix: my run record stores those calls as ok: true next to the 403, so the record reads better than what the agent actually saw.

@Aghassi, the ok: true / 403 contradiction is a useful regression fixture. I would keep three separate fields: HTTP status, whether the expected authorized payload was obtained, and what the final reply is permitted to claim. A response arriving successfully does not mean the lookup succeeded.

For a synthetic replay, I would cover: 403 with no permitted order data; timeout; 200 with missing/invalid order fields; and an authorized 200 control. The first three should use the defined failure/handoff path and must not claim verified charges. Even a valid 200 needs the backend access check and the agreed payload contract.

These are proposed acceptance tests, not results from your workflow. Where is ok assigned today—the HTTP node wrapper or the run-record writer? And would a small rerunnable fixture set help, or is correcting that assignment sufficient for your immediate need? No private order data or credentials are needed.

In the run-record writer, not the HTTP tool. The tool returns the status and body to the agent as data, and the summary written to the run record marked anything that wasn’t an “Error:” string as ok. So a 403 came back as data and got recorded as success. Fixed today: a status of 400 or above is recorded as not ok, with the status kept beside it. On fixtures, thanks, but I’ll write the four cases you listed into my own tests. They’re the right four.