Quick overview
This workflow serves a demo web page with an n8n chat widget and runs an OpenAI-powered support agent that looks up WooCommerce orders and DHL tracking details by calling the same workflow as a tool.
How it works
- Serves a demo HTML page via a webhook that embeds the n8n Chat widget configured to start a chat session.
- Triggers a new conversation when the chat widget connects and provides a customer email (mocked in this template) as session metadata.
- Uses an OpenAI (GPT-4) chat model with short-term memory to answer order-related questions and decide when to fetch live order data.
- Calls the same workflow as a tool with the customer email (and optional comma-separated order IDs) to retrieve matching WooCommerce orders.
- Looks up the WooCommerce customer by email, fetches their orders, and extracts shipment tracking metadata from each order.
- For orders with DHL tracking numbers, queries the DHL API for current shipment status, then merges tracking results back into the order data.
- Returns a JSON response containing the customer’s orders and any available DHL tracking details to the agent for use in the chat reply.
Setup
- Add a WooCommerce API credential and update the store URL used for the WooCommerce orders request.
- Add an OpenAI API credential for the GPT-4 chat model.
- Add a DHL API credential for shipment tracking lookups.
- If you use the demo page, replace the chat widget’s
webhookUrl in the embedded HTML with your n8n Chat Trigger URL.
- If you pass customer emails via widget metadata, enable the decrypt step and replace the hardcoded AES password in the encrypt/decrypt code with a securely stored secret.