Enhanced Chat Trigger

Enhanced Chat Trigger with advanced features, better UI, and multimedia support

Overview

This node implements an Enhanced Chat Trigger designed to provide a rich, interactive chat interface within n8n workflows. It supports advanced features such as session management, message history, file uploads, typing indicators, and customizable UI styling. The node listens for incoming chat messages via a webhook and triggers workflow executions accordingly.

Common scenarios where this node is beneficial include:

  • Building AI-powered chat assistants or customer support bots.
  • Creating interactive chat interfaces that maintain conversation context.
  • Handling multimedia inputs like images or documents uploaded by users.
  • Integrating chat-based user interactions directly into automated workflows.

Practical examples:

  • A helpdesk chatbot that remembers previous conversations and can accept screenshots or PDFs from users.
  • An internal team assistant that provides information based on chat queries with a fully styled chat window embedded in a web app.
  • A conversational interface that outputs responses either as plain text, JSON, HTML, or directly from workflow data.

Properties

Name Meaning
Chat Title Title displayed at the top of the chat interface (default: "Enhanced AI Assistant").
Chat Subtitle Subtitle shown below the title in the welcome message (default: "How can I help you today?").
Welcome Messages List of initial welcome messages shown when the chat loads. Multiple messages can be configured, each with custom text.
Chat Mode Display mode of the chat interface:
- Window Mode: Toggle button with hide/show functionality.
- Fullscreen Mode: Chat occupies entire available space.
Enable File Uploads Boolean flag to allow users to upload files through the chat interface.
Allowed File Types Comma-separated list of MIME types and extensions allowed for file uploads (e.g., images, PDFs, text files). Only shown if file uploads are enabled.
Load Previous Session Whether to load previous chat messages from the current session when the chat starts.
Response Mode Format of responses sent back to the chat:
- Text Response: Plain text.
- JSON Response: Structured JSON.
- HTML Response: HTML formatted.
- Workflow Output: Use output from the triggered workflow.
Default Response Default message sent when the workflow does not provide any output. Used only for text, JSON, or HTML response modes.
Enhanced Features Collection of advanced options:
- Enable Session Management: Maintain conversation context.
- Enable Message History: Store and retrieve past messages.
- Auto-save Conversations: Save chats automatically.
- Enable Typing Indicators: Show typing status.
- Enable Message Timestamps: Show timestamps.
- Custom CSS Classes: Add custom CSS classes to the chat UI.
Styling Options UI customization options including primary/secondary colors, background color, text color, and chat window dimensions (width and height in pixels).
Advanced Options Additional settings:
- Custom Webhook Path: Override default webhook URL path.
- CORS Origins: Allowed origins for cross-origin requests.
- Rate Limiting: Control message rate (none, basic, moderate, strict).
- Message Timeout: Timeout in seconds for processing messages.
Chat Interface Informational notice indicating where the live chat interface will appear when the workflow is active.

Output

The node outputs data structured as follows:

  • json: Contains the incoming chat message details with metadata, including:

    • id: Unique message ID.
    • content: The user's message text.
    • timestamp: ISO timestamp of when the message was received.
    • sessionId: Identifier for the chat session.
    • action: Action type (e.g., "sendMessage", "loadPreviousSession").
    • files: Array of uploaded files metadata if any.
    • enhanced: Flag indicating enhanced chat message.
    • metadata: Additional info such as user agent, IP address, source identifier, and enabled features.
  • webhookResponse: The HTTP response sent back to the chat client, containing:

    • Status code (200).
    • Headers for CORS and content type.
    • Body with the response message formatted according to the selected response mode (text, JSON, HTML, or workflow output).

If file uploads are enabled, the node supports receiving and processing binary data representing those files.

Dependencies

  • Requires an active webhook endpoint exposed by n8n to receive chat messages.
  • No external API keys or services are required by default; however, the node expects the workflow it triggers to handle message processing and generate responses.
  • Configuration of CORS origins may be necessary depending on deployment environment to allow chat clients to communicate with the webhook.
  • Optional rate limiting can be configured to prevent abuse.

Troubleshooting

  • Common Issues:

    • Chat interface not loading: Ensure the workflow is active and the webhook URL is correctly configured.
    • File uploads failing: Verify that file uploads are enabled and the allowed file types match the uploaded files.
    • Responses not appearing: Check that the workflow returns output compatible with the selected response mode.
    • Session data lost after restart: The node attempts to recover sessions but persistent storage depends on workflow design.
  • Error Messages:

    • "Enhanced Chat Trigger error: <message>" indicates an internal error processing the incoming message. Review the workflow logic and input data.
    • CORS errors in browser console suggest misconfigured allowed origins; update the "CORS Origins" property accordingly.
    • Rate limit exceeded errors occur if message frequency surpasses configured limits; adjust rate limiting or reduce message frequency.

Links and References

Discussion