How to build custom ChatHub interface on n8n
Build a custom ChatHub interface on n8n by creating a webhook workflow that receives chat messages, processes them through AI nodes, and returns responses. Use HTTP Request nodes to connect multiple chat services and the HTML node to create a custom interface.
Prerequisites
- n8n workspace access
- Basic knowledge of HTTP requests and webhooks
- Understanding of chat applications
- Familiarity with n8n node types
Step-by-Step Instructions
Set up the Webhook Trigger
POST and Path as /chathub. Click Listen for Test Event to generate your webhook URL.Create the Chat Interface HTML
<div id="chatContainer"><div id="messages"></div><input id="messageInput" placeholder="Type your message..."><button onclick="sendMessage()">Send</button></div>Include JavaScript to handle message sending with
fetch() calls to your webhook URL.Configure Chat Message Processing
{{$json.body.messageType}} with values like text, image, or file. For each message type, add corresponding processing branches using Set nodes to structure the data format.Connect AI Service Nodes
Chat and configure the Model to gpt-3.5-turbo. Map the incoming message to {{$json.body.message}} in the Messages field. Add multiple AI service nodes to create a true ChatHub experience.Implement Response Formatting
return [{
messageId: new Date().getTime(),
sender: 'assistant',
content: $input.first().json.choices[0].message.content,
timestamp: new Date().toISOString()
}];Set up Message Storage
Append and map fields like {{$json.messageId}}, {{$json.sender}}, and {{$json.content}}. This enables chat history and conversation continuity.Configure Response Webhook
200 and Response Body to return the formatted chat response as JSON. Include headers like Content-Type: application/json and enable CORS with Access-Control-Allow-Origin: *.Deploy and Test ChatHub
Common Issues & Troubleshooting
Webhook not receiving messages from chat interface
Verify CORS settings in your Respond to Webhook node and ensure the webhook URL is correctly configured in your HTML JavaScript fetch() calls.
AI service responses taking too long
Add a Wait node with timeout settings and implement fallback responses using the Switch node to handle API delays.
Chat history not saving properly
Check your storage node credentials and field mappings. Use the Code node to validate data structure before sending to storage services.
Multiple AI services not load balancing
Implement a Code node with random selection logic or use the Switch node with conditions based on current load or response times.