Context Tags Reference
Context tags allow you to pass dynamic data from your website to your AI workflows, enabling personalized and context-aware chat responses.
What Are Context Tags?
Context tags are dynamic variables that automatically populate with real-time data from your website. When a user sends a chat message, N8.Chat includes relevant context tags in the webhook payload, allowing your AI to provide informed, personalized responses.
Example Use Cases
- •Show product recommendations based on current cart contents
- •Provide order status updates using the customer's order ID
- •Reference the current page URL to give page-specific help
- •Personalize greetings using the customer's name
General Context Tags
These tags are available on all platforms (WordPress, Shopify, and custom integrations):
| Tag | Description | Example Value |
|---|---|---|
{{page_url}} | Current page URL | https://example.com/products |
{{page_title}} | Current page title | Products - My Store |
{{user_name}} | Logged-in user's display name | John Doe |
{{user_email}} | Logged-in user's email | john@example.com |
{{user_id}} | Logged-in user's unique ID | 12345 |
{{session_id}} | Unique session identifier | sess_abc123xyz |
{{device_type}} | Device type (desktop, mobile, tablet) | mobile |
WooCommerce-Specific Tags
When N8.Chat is installed on a WordPress site with WooCommerce, these additional tags become available:
| Tag | Description | Example Value |
|---|---|---|
{{cart_total}} | Current cart total amount | $129.99 |
{{cart_items}} | Number of items in cart | 3 |
{{cart_contents}} | JSON array of cart items with details | [{...}] |
{{order_id}} | Most recent order ID (if available) | WC-12345 |
{{order_status}} | Status of the most recent order | processing |
{{product_id}} | Current product ID (on product pages) | 567 |
{{product_name}} | Current product name (on product pages) | Premium Headphones |
{{product_price}} | Current product price (on product pages) | $89.99 |
Shopify-Specific Tags
When N8.Chat is installed on Shopify, these platform-specific tags are available:
| Tag | Description | Example Value |
|---|---|---|
{{cart_token}} | Shopify cart token | c1-1234567890 |
{{shop_domain}} | Your Shopify store domain | mystore.myshopify.com |
{{collection_handle}} | Current collection handle (on collection pages) | summer-sale |
{{variant_id}} | Product variant ID (on product pages) | 39876543210 |
{{customer_id}} | Shopify customer ID (if logged in) | 3456789012 |
Usage Examples
Example 1: Cart Abandonment Recovery
Use cart context tags to create personalized cart recovery messages:
n8n Workflow Prompt:
You are a helpful shopping assistant.
The customer has {{cart_items}} items in their cart
totaling {{cart_total}}. Help them complete their purchase.Example 2: Order Status Lookup
Automatically fetch order details using the order ID:
n8n HTTP Node Configuration:
URL: https://yourstore.com/wp-json/wc/v3/orders/{{order_id}}
Method: GET
Authentication: Basic AuthExample 3: Personalized Product Recommendations
Recommend related products based on the current product page:
AI Prompt:
The customer is viewing {{product_name}}
priced at {{product_price}}.
Recommend 3 complementary products.Accessing Context Tags in n8n
Context tags are sent in the webhook request body. Access them using n8n's expression syntax:
Basic Access
{{ $json.context.page_url }}Conditional Logic
{{ $json.context.cart_items > 0 ? 'You have items in cart' : 'Your cart is empty' }}Full Context Object
{
"message": "Help me with my order",
"context": {
"page_url": "https://example.com/checkout",
"page_title": "Checkout",
"user_name": "John Doe",
"user_email": "john@example.com",
"cart_total": "$129.99",
"cart_items": 3,
"device_type": "mobile"
}
}