Enhanced Callback

A callback node for n8n to handle chat callbacks and render output

Overview

This node implements an enhanced callback handler designed for chat or webhook interactions within n8n workflows. It listens for incoming HTTP POST requests on a webhook endpoint and processes the payload to render a customizable output page. The node supports rendering text or HTML responses, optionally sanitizing or allowing dynamic HTML content. It can also render interactive forms and support audio/video file uploads directly in the callback UI.

Common scenarios where this node is beneficial include:

  • Handling chat message callbacks from external chat services.
  • Rendering formatted responses with optional user input forms.
  • Collecting audio or video files uploaded by users during a chat interaction.
  • Displaying received headers and metadata alongside the main message content.

Practical examples:

  • A chatbot workflow that receives messages and displays them in a styled HTML page with safe rendering.
  • A feedback form embedded in the callback response allowing users to submit additional input.
  • Uploading voice notes or short videos as part of a chat conversation, which are then processed downstream.

Properties

Name Meaning
Output Format Format for callback output; options: Text (plain text wrapped in <pre>), HTML (render raw or sanitized HTML).
Enable Dynamic HTML Allow rendering of dynamic HTML content in the chat UI. If enabled, raw HTML is rendered (optionally sanitized).
Sanitize Response Whether to sanitize the callback response before rendering to remove scripts and event handlers. Defaults to true.
Enable Form Rendering Render a form in the callback output to allow user input submission back to the webhook.
Enable Audio Upload Show an audio file upload input in the callback output form, allowing users to upload audio files.
Enable Video Upload Show a video file upload input in the callback output form, allowing users to upload video files.

Output

The node outputs JSON data containing:

  • received: Boolean indicating if the callback was successfully received.
  • content: The main message content extracted from the request body (message or content field).
  • receivedHeaders: Headers included in the JSON body under headers.
  • xChatHeaders: HTTP headers starting with x-chat- collected from the request.
  • submittedValue: If form input was submitted, contains the submitted text value.
  • uploadedAudioName: Filename of any uploaded audio file.
  • uploadedVideoName: Filename of any uploaded video file.

The node also returns an HTML response rendered dynamically based on the above properties and settings, including displaying the message content, headers, form inputs, and uploaded media previews.

Dependencies

  • No external API dependencies.
  • Requires the node to be used as a webhook trigger in n8n.
  • No special environment variables needed.
  • Relies on standard HTTP POST requests with JSON or multipart/form-data bodies.

Troubleshooting

  • Issue: Callback does not display HTML correctly.

    • Cause: Dynamic HTML rendering disabled or response sanitized.
    • Resolution: Enable "Enable Dynamic HTML" property or disable sanitization to allow raw HTML rendering.
  • Issue: Uploaded audio/video files do not appear.

    • Cause: Corresponding upload option not enabled or files not sent properly.
    • Resolution: Ensure "Enable Audio Upload" or "Enable Video Upload" is enabled and that the client sends files with correct field names.
  • Issue: Script tags or event handlers still execute despite sanitization.

    • Cause: Sanitization only removes <script> tags and inline event handlers but may not cover all XSS vectors.
    • Resolution: Use caution with enabling dynamic HTML and consider additional sanitization layers if needed.
  • Error: Missing expected fields in the request body.

    • Cause: Incoming webhook payload structure differs.
    • Resolution: Verify the sending service matches expected JSON format with message or content fields.

Links and References

Discussion