Feature Reference

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):

TagDescriptionExample Value
{{page_url}}Current page URLhttps://example.com/products
{{page_title}}Current page titleProducts - My Store
{{user_name}}Logged-in user's display nameJohn Doe
{{user_email}}Logged-in user's emailjohn@example.com
{{user_id}}Logged-in user's unique ID12345
{{session_id}}Unique session identifiersess_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:

TagDescriptionExample Value
{{cart_total}}Current cart total amount$129.99
{{cart_items}}Number of items in cart3
{{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 orderprocessing
{{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:

TagDescriptionExample Value
{{cart_token}}Shopify cart tokenc1-1234567890
{{shop_domain}}Your Shopify store domainmystore.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 Auth

Example 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"
  }
}