Skip to main content

AI Order Sub-Agent

AI Order Sub-Agent lets the AI Chat Agent answer order questions, such as "Where is my last order?". It reads orders from your store and replies with the order number, status, date, total and items.

The AI Chat Agent calls this workflow as a tool. A sub-agent inside it looks up an order by its ID, or lists orders by the user ID passed from the app.

It works with WooCommerce, Dokan, WCFM and Shopify. It is an AI Chat Add-on and needs the Lifetime, Ultra or Professional plan, or an Extended license.

Requirements​

WhatUsed for
AI Chat AgentCalls this workflow
OpenAI API keyRuns the sub-agent
WooCommerce REST API key (Read), or Shopify Admin API access token (read_orders)Reads your orders. Shopify returns only the last 60 days unless the token also has read_all_orders

1. Download and import the workflow​

  1. In FluxBuilder, go to Features > AI Chat Add-ons.

  2. Next to AI Order Sub-Agent, click DOWNLOAD WORKFLOW. You get the template for your app's platform.

  3. In n8n, open Workflows > Create > Import from File and pick the downloaded JSON.

2. Set the credentials​

NodeCredential
OpenAI Chat Model, Chat Model FallbackOpenAI
Get an order by order ID - WooCommerce, Get many orders by user ID - WooCommerceWooCommerce API
Get orders by user ID tool - Custom API - Shopify, Get Order info by order ID tool - Custom API - ShopifyShopify Access Token API

Pick a model your OpenAI account can use in both model nodes.

Nodes that are not connected, such as MCP Client or Get latest order by email - Custom API - Shopify, need no credential. You can delete them.

3. Shopify only: set your store URL​

The two Shopify tool nodes call a sample store. Open each one and change URL to your own store:

<https://your-store.myshopify.com/admin/api/2024-10/graphql.json>

4. Connect it to the AI Chat Agent​

  1. Save the workflow and click Publish.
  2. Open your AI Chat Agent workflow and the tool node Order Sub-Agent.
  3. In Workflow, select the Order Sub-Agent workflow you imported, then publish the AI Chat Agent again.

The AI Chat Agent passes the question, with the user ID and order ID when it has them, and your store platform. The app sends the user ID only when the shopper is signed in.

Troubleshooting​

ProblemFix
The agent says it cannot find any orderCheck the WooCommerce or Shopify credential, then test the node with Execute step
Shopify orders come from another storeChange the URL in both Shopify tool nodes
The AI Chat Agent never calls this workflowIn AI Chat Agent, check that Order Sub-Agent points to this workflow