Package Information
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:
- Enhanced Chat Trigger Node - Handles webhook requests and returns JSON responses
- @n8n/chat Widget - Provides the chat UI interface (separate package)
- 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)
- Go to Settings > Community Nodes in your n8n instance
- Click Install a community node
- Enter
n8n-enhanced-chat-trigger
in the npm package name field - 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
- Add the Enhanced Chat Trigger node to your workflow
- Configure the chat settings (file uploads, session management, etc.)
- Connect additional nodes to process the chat data
- 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
- Open your HTML file in a browser
- Click the chat button that appears in the bottom right
- Send a message to test the integration
- 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 filesloadPreviousSession
- 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
- Build the package:
npm run build
- Link locally:
npm link
- In your n8n instance:
npm link n8n-enhanced-chat-trigger
- 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.