HTML Chat Trigger

Enhanced chat trigger that allows HTML rendering for rich user experiences

Overview

This node implements an enhanced HTML chat trigger that provides a rich, interactive chat interface supporting formatted text, tables, charts, and media content. It can be used to create conversational experiences where users interact with a bot or service through a web-based chat UI that supports HTML rendering.

Common scenarios include:

  • Customer support chats with rich content responses.
  • Interactive data presentation via chat (e.g., showing charts or tables).
  • Embedding a customizable chat widget on websites or applications.
  • Prototyping conversational UIs that require formatted output beyond plain text.

The node offers two modes:

  • Hosted Chat: Serves a full-featured chat UI directly from the webhook URL.
  • Embedded Chat: Provides only the webhook endpoint for message exchange, allowing embedding the chat UI elsewhere.

Properties

Name Meaning
Make Chat Publicly Available Boolean flag to make the chat accessible publicly without restrictions.
Chat Mode How users access the chat: "Hosted Chat" (full UI served) or "Embedded Chat" (webhook only).
Initial Messages Text shown as initial messages when the chat starts; supports line breaks with \n.
Options Collection of additional settings:
- Enable HTML Rendering Boolean to enable or disable HTML rendering in chat responses.
- Chat Title Title displayed at the top of the chat interface.
- Chat Subtitle Subtitle displayed below the chat title.
- Session Timeout (minutes) Duration in minutes to keep chat sessions active before cleanup.
Webhook Path The URL path segment for the webhook endpoint serving the chat or receiving messages.

Output

The node outputs JSON data representing incoming chat messages and session metadata. For each POST request with a chat message, it returns:

  • chatInput: The user's input message.
  • sessionId: Unique identifier for the chat session.
  • timestamp: ISO timestamp of the message.
  • mode: Current chat mode ("hostedChat" or "webhook").
  • messageHistory: Array of all messages exchanged in the session, each with role (user or bot), content, and timestamp.
  • userAgent: User agent string from the request headers.
  • ip: IP address of the client.

If the chat is accessed via GET in hosted mode, the node responds with a complete HTML page containing the chat UI, including embedded JavaScript to handle user interaction and rendering.

Binary data output is not applicable here; however, the chat supports rich HTML content rendering within the chat messages.

Dependencies

  • Requires a webhook URL exposed by n8n to serve the chat interface and receive messages.
  • Uses Chart.js loaded from CDN for rendering interactive charts inside chat messages.
  • No external API keys are required by default, but the webhook must be accessible to clients.
  • The node manages chat sessions internally with in-memory storage and session timeout cleanup.

Troubleshooting

  • Chat interface not loading:
    Ensure the webhook URL is correctly configured and accessible. If using "Embedded Chat" mode, the full UI is not served by the node, so you need to provide your own frontend.

  • Connection errors in chat:
    The chat UI shows connection error messages if the webhook is unreachable or returns errors. Verify network connectivity and that the webhook path matches the configured path.

  • Session timeout issues:
    Sessions expire after the configured timeout (default 30 minutes). Users may lose chat history if inactive longer than this period.

  • Chart rendering errors:
    Charts rely on Chart.js loaded from CDN. If charts do not render, check browser console for errors and ensure internet access to the CDN.

  • Method not allowed errors:
    Only GET and POST HTTP methods are supported. Other methods will return a 405 error.

Links and References

Discussion