At a glance
- Trigger
- Execute Workflow Trigger (Execute Workflow Trigger)
- Nodes
- 31
- Apps
- WooCommerce, DHL and OpenAI
- AI nodes
- 5
- Credentials
- 3 types
- Category
- E-commerce and payments
Apps and integrations
Node types used
How it works
The text below comes from the sticky notes inside the workflow. We removed links, code samples and anything that looks like a key or token.
Example Website Implementation
Example Code for a website can be found in node "Respond to Webhook".
More information about the embeddable chat can be found here.
- Change "webhookUrl" to the displayed in "Chat Trigger" node
- Set the encrypted email address dynamically. The value has to be calculated in the backend to make it truly secure
- Use a unique password for email en-/decryption and use it in the backend and this workflow (can be set in node "Decrypt email address")
The example page can be opened by calling the production Webhook-URL of the node "Webhook Example Page". It only works if the "For production use" steps on the left have been followed.
Find WooCommerce User-ID
User-ID is required to query past orders
How to supply user email
As we want to ensure that customers can only query information about their own orders, the email address gets encrypted in the backend, and then decrypt again in this workflow. If the email was allowed to be set unencrypted, anyone could query information from other customers.
The email address get supplied in the chat script at the following location
Example Scripts
Encrypt email on the backend
Run the following code in the backend of your website, send the data to the frontend, and then set it dynamically at the above defined location as email.
Decrypt email in workflow
This script is already used in this workflow and is only provided here again as an example.
Setup notes
The text below comes from the sticky notes inside the workflow. We removed links, code samples and anything that looks like a key or token.
Setup
Generally
- The environment variable NODE_FUNCTION_ALLOW_BUILTIN has to equal or include the value crypto (FYI: is default on n8n cloud) as it is required to run this workflow
To test the workflow
- Set a valid email address of a user that exists in WooCommerce in the Mock Node "Mock Data"
- Enable the node "Mock Data"
- Disable the node "Decrypt email address"
- Use the built-in chat by pressing the "Chat" button
For production use
- Update the "System Message" in the node "AI Agent" for specific use case. At least the name of the shop should be changed
- Integrate the chat into the website. An example can be found in the box "Example Website Implementation"
- Disable or delete the node "Mock Data"
- Enable the node "Decrypt email address"
- Enable Workflow
Add DHL tracking information
Queries the status of shipped orders from DHL.
Can be skipped if order tracking should not be available or replaced with other services like UPS.
Nodes in this workflow
The 31 nodes in file order (sticky notes excluded). Branches and connections determine execution order in n8n:
- No email provided (Edit Fields (Set))
- If email provided (If)
- If user found (If)
- No customer found (Edit Fields (Set))
- If contains DHL data (If)
- Extract Tracking Data (Edit Fields (Set))
- Merge Orders (Merge)
- Merge Order and Tracking Data (Merge)
- Split Out (Split Out)
- Aggregate (Aggregate)
- Merge Tracking Data (Merge)
- Window Buffer Memory (Window Buffer Memory)
- Execute Workflow Trigger (Execute Workflow Trigger)
- WooCommerce - Get User (WooCommerce)
- If order found (If)
- WooCommerce Get Orders (HTTP Request)
- No order found (Edit Fields (Set))
- Add Error Information (Edit Fields (Set))
- DHL (DHL)
- Send Response (Edit Fields (Set))
- OpenAI Chat Model (OpenAI Chat Model)
- WooCommerce_Tool (Call n8n Workflow Tool)
- Chat Trigger (Chat Trigger)
- Respond to Webhook (Respond to Webhook)
- Webhook Example Page (Webhook)
- Decrypt email (Code)
- Encrypt email (Code)
- Example encrypted email (Edit Fields (Set))
- Decrypt email address (Code)
- AI Agent (AI Agent)
- Mock Data (Edit Fields (Set))
Credentials you need
- DHL API – used by DHL
- OpenAI API – used by OpenAI Chat Model
- WooCommerce API – used by WooCommerce - Get User and WooCommerce Get Orders
Configure your own credentials after importing. Create each credential in n8n, then select it in the node.
How to import into n8n
- Download the JSON file with the button above.
- In n8n, open a new workflow, select the ... menu and choose Import from File. You can also paste the JSON straight into the editor canvas.
- Open each node that shows a warning and select or create its credential.
- Read the notes on the canvas, test the workflow with sample data, then activate it.
Do you need somewhere to run it? Read our guide to self-hosted n8n.