Self-Hosted Chat Widget for n8n w/ OpenAI-Compatible LLM
Self-Hosted Chat Widget for n8n w/ OpenAI-Compatible LLM
Regular price
£16.99
Regular price
£16.99
Sale price
Unit price
/
per
⬇
Instant Digital Download
∞
Unlimited Downloads
★
Lifetime Access in Your Account
Couldn't load pickup availability
🔥
128+ Sold
Popular with n8n builders
âš¡
23 people viewing
High interest right now
✅
9 added today
Fast-moving digital product
Self-Hosted Chat Widget for n8n w/ OpenAI-Compatible LLM
Regular price
£16.99
Regular price
£16.99
Sale price
Unit price
/
per
Embed a self-hosted AI chat widget on your website—powered by an OpenAI-compatible LLM through n8n
This n8n automation provides an embeddable website chat widget that sends visitor messages to an OpenAI-compatible /chat/completions endpoint, keeps lightweight per-session conversation context, and returns the assistant’s reply to the browser—fully self-hosted.
What this workflow does
-
Serves a ready-to-embed chat script: On
GET /webhook/chat-widget.js, the workflow returns a JavaScript snippet that renders a chat bubble and posts user messages to your n8n endpoint. -
Accepts chat messages from visitors: On
POST /webhook/chat-message, it receives a payload containingsessionIdandmessage. - Maintains session history: It loads and updates conversation history using n8n workflow static data, keeping only the most recent messages.
-
Calls your OpenAI-compatible LLM: It sends the configured system prompt plus the session history to an OpenAI-compatible
/chat/completionsAPI using environment variables for base URL, model, and API key. -
Returns a JSON reply to the widget: It extracts the assistant response, appends it to history, and returns
{ "reply": "..." }to the front-end.
Use cases
- Add a branded AI support chat to your site without using third-party widget platforms.
- Enable SaaS onboarding Q&A with persistent per-session context handled by n8n.
- Let automation engineers test OpenAI-compatible providers by swapping
CHAT_LLM_API_BASEandCHAT_LLM_MODEL.
Technical details
-
Webhook endpoints:
/webhook/chat-widget.jsand/webhook/chat-message. - Nodes used: code, webhook, http request, respond to webhook.
-
Environment variables:
CHAT_LLM_API_KEY(required), plus optionalCHAT_LLM_API_BASE,CHAT_LLM_MODEL, andCHAT_LLM_SYSTEM_PROMPT.
Activate the workflow, copy both webhook URLs, and embed the script tags on your website by setting window.N8N_CHAT_WIDGET_CONFIG.endpoint to your POST webhook URL (optionally configure title and accent color).
