n8n-enhanced-chat-trigger

Package Information

Released: 7/10/2025
Downloads: 0 weeklyΒ /Β 0 monthly
Latest Version: 1.0.0
Author: vinoth320

Documentation

n8n Enhanced Chat Trigger

An enhanced Chat Trigger node for n8n that provides advanced chat capabilities including callback support, multimedia handling, and session management. This node follows the official n8n Chat Trigger pattern and works seamlessly with the @n8n/chat widget.

✨ Features

  • πŸš€ JSON API Responses - Returns structured JSON data like the official n8n Chat Trigger
  • πŸ’¬ Chat Widget Integration - Works with the official @n8n/chat widget package
  • πŸ“ File Upload Support - Handle multimedia files (images, PDFs, documents)
  • πŸ”„ Session Management - Maintain conversation continuity across interactions
  • πŸ”— Callback URLs - Generate dynamic callback URLs for enhanced interactions
  • πŸ“ Multiple Response Formats - Support for text, JSON, and HTML responses
  • 🎯 Action-Based Routing - Handle different chat actions (sendMessage, loadPreviousSession)
  • πŸ›‘οΈ Security Features - Content sanitization and file type validation

πŸ—οΈ Architecture

This package follows the official n8n Chat Trigger architecture:

  1. Enhanced Chat Trigger Node - Handles webhook requests and returns JSON responses
  2. @n8n/chat Widget - Provides the chat UI interface (separate package)
  3. Workflow Integration - Processes chat data through your n8n workflow
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Chat Widget   │───▢│ Enhanced Chat Trigger │───▢│  Your Workflow  β”‚
β”‚  (@n8n/chat)   β”‚    β”‚      (JSON API)      β”‚    β”‚   (Processing)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“¦ Installation

Option 1: Community Nodes (Recommended)

  1. Go to Settings > Community Nodes in your n8n instance
  2. Click Install a community node
  3. Enter n8n-enhanced-chat-trigger in the npm package name field
  4. Click Install

Option 2: Manual Installation

# For self-hosted n8n
npm install n8n-enhanced-chat-trigger

# For Docker
docker exec -it n8n npm install n8n-enhanced-chat-trigger

πŸš€ Quick Start

1. Create Your Workflow

  1. Add the Enhanced Chat Trigger node to your workflow
  2. Configure the chat settings (file uploads, session management, etc.)
  3. Connect additional nodes to process the chat data
  4. Activate the workflow to get the webhook URL

2. Set Up the Chat Widget

Create an HTML file with the chat widget:

<!DOCTYPE html>
<html>
<head>
    <link href="https://cdn.jsdelivr.net/npm/@n8n/chat/dist/style.css" rel="stylesheet" />
</head>
<body>
    <div id="n8n-chat"></div>
    
    <script type="module">
        import { createChat } from 'https://cdn.jsdelivr.net/npm/@n8n/chat/dist/chat.bundle.es.js';
        
        createChat({
            webhookUrl: 'https://your-n8n-instance.com/webhook/your-workflow-id',
            allowFileUploads: true,
            allowedFilesMimeTypes: 'image/*,application/pdf,text/*',
            initialMessages: [
                'Hi! πŸ‘‹',
                'I\'m your Enhanced Chat Assistant. How can I help you today?'
            ]
        });
    </script>
</body>
</html>

3. Test Your Chat

  1. Open your HTML file in a browser
  2. Click the chat button that appears in the bottom right
  3. Send a message to test the integration
  4. Check your n8n workflow execution to see the processed data

βš™οΈ Configuration

Enhanced Chat Trigger Node Settings

Chat Configuration

  • Enable Enhanced Features - Activate advanced chat capabilities
  • Session Management - Enable conversation continuity
  • Allow File Uploads - Accept file uploads from users
  • Allowed File Types - Specify accepted MIME types
  • Max File Size (MB) - Set maximum file size limit

Response Configuration

  • Enable Callbacks - Generate dynamic callback URLs
  • Callback Base URL - Base URL for callback endpoints
  • Response Format - Choose between text, JSON, or HTML
  • Enable Dynamic HTML - Allow dynamic HTML content
  • Sanitize Response - Enable security sanitization

Chat Widget Options

The widget supports all standard @n8n/chat options plus enhanced features:

createChat({
    webhookUrl: 'YOUR_WEBHOOK_URL',
    allowFileUploads: true,
    allowedFilesMimeTypes: 'image/*,application/pdf,text/*',
    loadPreviousSession: true,
    chatInputKey: 'chatInput',
    chatSessionKey: 'sessionId',
    // ... other @n8n/chat options
});

πŸ“Š Data Structure

Incoming Chat Data

The Enhanced Chat Trigger receives and processes:

{
    "action": "sendMessage",
    "chatInput": "User message text",
    "sessionId": "session_123",
    "files": [
        {
            "name": "image.png",
            "type": "image/png",
            "size": 1024,
            "data": "base64_encoded_data"
        }
    ]
}

Workflow Output

The node outputs structured data to your workflow:

{
    "message": {
        "id": "msg_123",
        "content": "User message text",
        "timestamp": "2024-01-15T10:30:00Z",
        "sessionId": "session_123",
        "files": [...],
        "metadata": {
            "userAgent": "Mozilla/5.0...",
            "ip": "192.168.1.1",
            "enhanced": true
        }
    },
    "response": {
        "text": "Message received",
        "format": "text",
        "callbackUrl": "https://your-domain.com/callback/cb_123",
        "sessionId": "session_123"
    },
    "action": "sendMessage"
}

πŸ”„ Action Types

The Enhanced Chat Trigger handles different action types:

  • sendMessage - Process user messages and files
  • loadPreviousSession - Load conversation history
  • Custom actions - Handle application-specific events

🎯 Use Cases

1. AI Chatbot with File Analysis

Chat Widget β†’ Enhanced Chat Trigger β†’ OpenAI Node β†’ Response

2. Customer Support with Session History

Chat Widget β†’ Enhanced Chat Trigger β†’ Database Lookup β†’ CRM Integration

3. Interactive Forms with Callbacks

Chat Widget β†’ Enhanced Chat Trigger β†’ Form Processing β†’ Callback URL Generation

πŸ› οΈ Development

Building from Source

git clone https://github.com/vinoth320/n8n-enhanced-chat-trigger.git
cd n8n-enhanced-chat-trigger
npm install
npm run build

Testing

  1. Build the package: npm run build
  2. Link locally: npm link
  3. In your n8n instance: npm link n8n-enhanced-chat-trigger
  4. Restart n8n and test the node

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“„ License

MIT License - see the LICENSE file for details.

πŸ”— Related


Note: This package follows the official n8n Chat Trigger architecture and is designed to work seamlessly with the @n8n/chat widget. The Enhanced Chat Trigger returns JSON responses only - the chat UI is handled by the separate @n8n/chat package.

Discussion