Configuration Guide

n8n Webhook Setup Guide

Configure n8n workflows to power your N8.Chat widget with AI capabilities. This guide covers cloud and self-hosted setups.

Prerequisites

  • N8.Chat plugin installed on WordPress or Shopify
  • n8n account (cloud or self-hosted)
  • API keys for your preferred AI service (OpenAI, Anthropic, etc.)

Step 1: Create an n8n Account

n8n Cloud (Recommended)

  • βœ“Fully managed hosting
  • βœ“Automatic updates
  • βœ“Built-in SSL certificates
  • βœ“Free tier available
Sign up for n8n Cloud

Self-Hosted

  • βœ“Full control over data
  • βœ“Run on your own infrastructure
  • βœ“Free and open source
  • !Requires Docker or npm setup
Self-hosting documentation

Tip: For beginners, we recommend starting with n8n Cloud. You can always migrate to self-hosted later if needed.

Step 2: Create a Webhook Workflow

1. Create a New Workflow

In your n8n dashboard, click + New Workflow to create a blank workflow.

2. Add a Webhook Trigger Node

Click the + button and search for "Webhook". Add the Webhook node to your workflow.

Webhook Configuration:

HTTP Method:POST
Path:chat-webhook
Response Mode:Last Node

3. Copy the Webhook URL

Click the Test workflow button, then copy the Production URL from the Webhook node.

https://your-instance.app.n8n.cloud/webhook/chat-webhook

Step 3: Add AI Nodes (OpenAI, Claude, etc.)

Connect your preferred AI service to process chat messages. Here are popular options:

OpenAI (ChatGPT)

  1. 1.Add an OpenAI Chat Model node after your Webhook
  2. 2.Create OpenAI credentials in n8n with your API key
  3. 3.Set the model (e.g., gpt-4)
  4. 4.Configure the prompt using {{ $json.message }}

Example Configuration:

{
  "model": "gpt-4",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant."
    },
    {
      "role": "user",
      "content": "{{ $json.message }}"
    }
  ]
}

Anthropic (Claude)

  1. 1.Add an HTTP Request node after your Webhook
  2. 2.Set URL to https://api.anthropic.com/v1/messages
  3. 3.Add headers: x-api-key and anthropic-version

Example Headers:

x-api-key: YOUR_ANTHROPIC_API_KEY
anthropic-version: 2023-06-01
Content-Type: application/json

Step 4: Test Your Connection

Test Workflow in n8n

Click the "Test workflow" button and send a test message through your chat widget

Verify Response

Check that the AI response appears in your chat widget

Activate Workflow

Once testing is successful, activate your workflow to make it live

Pro Tip: Use n8n's execution logs to debug any issues. Each webhook request is logged with full details.

Best Practices

Secure Your Webhook

Use webhook authentication headers to prevent unauthorized access

Optimize Response Time

Keep workflows simple for faster response times

Handle Errors Gracefully

Add error handling nodes to provide fallback responses

Monitor Usage

Track API usage to avoid exceeding rate limits

Example Webhook Response

Your n8n workflow should return a JSON response in this format:

{
  "message": "Hello! How can I help you today?",
  "metadata": {
    "model": "gpt-4",
    "timestamp": "2024-01-15T10:30:00Z"
  }
}