n8n/packages/@n8n/chat
github-actions[bot] 053503531f
🚀 Release 1.23.0 (#8205)
#
[1.23.0](https://github.com/n8n-io/n8n/compare/n8n@1.22.0...n8n@1.23.0)
(2024-01-03)


### Bug Fixes

* **Asana Node:** Omit body from GET, HEAD, and DELETE requests
([#8057](https://github.com/n8n-io/n8n/issues/8057))
([15ffd4f](15ffd4fb9f))
* **core:** Better input validation for the changeRole endpoint
([#8189](https://github.com/n8n-io/n8n/issues/8189))
([cfe9525](cfe9525dd4))
* **core:** Fix issue that pinnedData is not used with Test-Webhooks
([#8123](https://github.com/n8n-io/n8n/issues/8123))
([fa8bd8b](fa8bd8b9eb))
* **core:** Handle empty executions table in pruning in migrations
([#8121](https://github.com/n8n-io/n8n/issues/8121))
([ffaa30d](ffaa30ddc4))
* **core:** Remove circular dependency in WorkflowService and
ActiveWorkflowRunner
([#8128](https://github.com/n8n-io/n8n/issues/8128))
([21788d9](21788d9153))
* **core:** Use pinned data only for manual mode
([#8164](https://github.com/n8n-io/n8n/issues/8164))
([ea7e76f](ea7e76fa3b))
* **Discord Node:** Remove unnecessary requirement on parameters
([#8060](https://github.com/n8n-io/n8n/issues/8060))
([ef3a577](ef3a57719e))
* **editor:** Avoid sanitizing output to search node data
([#8126](https://github.com/n8n-io/n8n/issues/8126))
([c83d9f4](c83d9f45ba))
* **editor:** Enable explicit undo keyboard shortcut across all code
editors ([#8178](https://github.com/n8n-io/n8n/issues/8178))
([cf7f668](cf7f6688ba))
* **editor:** Fix operation change failing in certain conditions
([#8114](https://github.com/n8n-io/n8n/issues/8114))
([711fa2b](711fa2b925))
* **editor:** Fix templates view layout
([#8196](https://github.com/n8n-io/n8n/issues/8196))
([d01e42a](d01e42a2aa))
* **editor:** Fix UI urls when hosted behind a path prefix
([#8198](https://github.com/n8n-io/n8n/issues/8198))
([5c078f1](5c078f1b3d))
* **editor:** Prevent browser zoom when scrolling inside sticky edit
mode ([#8116](https://github.com/n8n-io/n8n/issues/8116))
([e928210](e928210ccd))
* **editor:** Prevent canvas undo/redo when NDV is open
([#8118](https://github.com/n8n-io/n8n/issues/8118))
([39e45d8](39e45d8b92))
* **editor:** Prevent storing pairedItem data inside of pinData
([#8173](https://github.com/n8n-io/n8n/issues/8173))
([405e267](405e26757e))
* **GitHub Node:** Fix issue that File->Get did not run once per item
([#8190](https://github.com/n8n-io/n8n/issues/8190))
([11cda41](11cda41214))
* **Invoice Ninja Node:** Fix issue with custom invoice numbers not
working with v5 ([#8200](https://github.com/n8n-io/n8n/issues/8200))
([3b6ae2d](3b6ae2d0a5))
* **Microsoft Excel 365 Node:** Ensure arg is string during worksheet
table search ([#8154](https://github.com/n8n-io/n8n/issues/8154))
([8e873ca](8e873ca2f3))
* **Notion Node:** Ensure arg is string during page ID extraction
([#8153](https://github.com/n8n-io/n8n/issues/8153))
([e94b8a6](e94b8a6c30))
* **Redis Trigger Node:** Activating a workflow with a Redis trigger
fails ([#8129](https://github.com/n8n-io/n8n/issues/8129))
([a169b74](a169b74062))
* **Schedule Trigger Node:** Use the correct `moment` import
([#8185](https://github.com/n8n-io/n8n/issues/8185))
([17a4e2e](17a4e2ea80))
* Show public API upgrade CTA when feature is not enabled
([#8109](https://github.com/n8n-io/n8n/issues/8109))
([e9c7fd7](e9c7fd7397))


### Features

* **core:** Add closeFunction support to Sub-Nodes
([#7708](https://github.com/n8n-io/n8n/issues/7708))
([bec0fae](bec0faed9e))
* **core:** Add user.profile.beforeUpdate hook
([#8144](https://github.com/n8n-io/n8n/issues/8144))
([e126ed7](e126ed74f3))
* **core:** Improvements/overhaul for nodes working with binary data
([#7651](https://github.com/n8n-io/n8n/issues/7651))
([5e16dd4](5e16dd4ab4))
* **core:** Remove discontinued crypto-js
([#8104](https://github.com/n8n-io/n8n/issues/8104))
([01e9a79](01e9a79238))
* **core:** Unify application components shutdown
([#8097](https://github.com/n8n-io/n8n/issues/8097))
([3a881be](3a881be6c2))
* **editor:** Add node execution status indicator to output panel
([#8124](https://github.com/n8n-io/n8n/issues/8124))
([ab74bad](ab74bade05))
* **editor:** Add template Id to workflow metadata
([#8088](https://github.com/n8n-io/n8n/issues/8088))
([517b050](517b050d0a))
* **Home Assistant Node:** Use the new Home Assistant logo
([#8150](https://github.com/n8n-io/n8n/issues/8150))
([518a99e](518a99e528))
* **Qdrant Vector Store Node:** Qdrant vector store support
([#8080](https://github.com/n8n-io/n8n/issues/8080))
([66460f6](66460f66b0))
* **Wordpress Node:** Add option to ignore error when using self signed
certificates ([#8199](https://github.com/n8n-io/n8n/issues/8199))
([65c8e12](65c8e12b96))

Co-authored-by: ivov <ivov@users.noreply.github.com>
2024-01-03 13:41:28 +01:00
..
.storybook feat: Add AI tool building capabilities (#7336) 2023-11-29 12:13:55 +01:00
.vscode feat: Add AI tool building capabilities (#7336) 2023-11-29 12:13:55 +01:00
public feat: Add AI tool building capabilities (#7336) 2023-11-29 12:13:55 +01:00
resources feat: Add AI tool building capabilities (#7336) 2023-11-29 12:13:55 +01:00
scripts feat: Add AI tool building capabilities (#7336) 2023-11-29 12:13:55 +01:00
src ci: Fix lint warnings in @n8n/chat and @n8n/nodes-langchain (no-changelog) (#7884) 2023-11-30 13:22:27 +01:00
.eslintignore feat: Add AI tool building capabilities (#7336) 2023-11-29 12:13:55 +01:00
.eslintrc.cjs ci: Disable import/no-extraneous-dependencies in frontend tests (no-changelog) (#8182) 2023-12-29 10:45:55 +01:00
.gitignore feat: Add AI tool building capabilities (#7336) 2023-11-29 12:13:55 +01:00
.np-config.json feat: Add AI tool building capabilities (#7336) 2023-11-29 12:13:55 +01:00
env.d.ts feat: Add AI tool building capabilities (#7336) 2023-11-29 12:13:55 +01:00
index.html feat: Add AI tool building capabilities (#7336) 2023-11-29 12:13:55 +01:00
LICENSE.md feat: Add AI tool building capabilities (#7336) 2023-11-29 12:13:55 +01:00
package.json 🚀 Release 1.23.0 (#8205) 2024-01-03 13:41:28 +01:00
README.md docs: Update workflow link from ai-beta to master (#8183) 2024-01-03 10:54:21 +00:00
tsconfig.json feat: Add AI tool building capabilities (#7336) 2023-11-29 12:13:55 +01:00
vite.config.ts feat: Add AI tool building capabilities (#7336) 2023-11-29 12:13:55 +01:00
vitest.config.ts feat: Add AI tool building capabilities (#7336) 2023-11-29 12:13:55 +01:00

n8n Chat

This is an embeddable Chat widget for n8n. It allows the execution of AI-Powered Workflows through a Chat window.

Prerequisites

Create a n8n workflow which you want to execute via chat. The workflow has to be triggered using a Webhook node and return data using the Respond to Webhook node.

Open the Webhook node and add your domain to the Domain Allowlist field. This makes sure that only requests from your domain are accepted.

See example workflow

Make sure the workflow is Active.

How it works

Each Chat request is sent to the n8n Webhook endpoint, which then sends back a response.

Each request is accompanied by an action query parameter, where action can be one of:

  • loadPreviousSession - When the user opens the Chatbot again and the previous chat session should be loaded
  • sendMessage - When the user sends a message

We use the Switch node to handle the different actions.

Installation

Open the Webhook node and replace YOUR_PRODUCTION_WEBHOOK_URL with your production URL. This is the URL that the Chat widget will use to send requests to.

a. CDN Embed

Add the following code to your HTML page.

<link href="https://cdn.jsdelivr.net/npm/@n8n/chat/style.css" rel="stylesheet" />
<script type="module">
	import { createChat } from 'https://cdn.jsdelivr.net/npm/@n8n/chat/chat.bundle.es.js';

	createChat({
		webhookUrl: 'YOUR_PRODUCTION_WEBHOOK_URL'
	});
</script>

b. Import Embed

Install and save n8n Chat as a production dependency.

npm install @n8n/chat

Import the CSS and use the createChat function to initialize your Chat window.

import '@n8n/chat/style.css';
import { createChat } from '@n8n/chat';

createChat({
	webhookUrl: 'YOUR_PRODUCTION_WEBHOOK_URL'
});
Vue.js
<script lang="ts" setup>
// App.vue
import { onMounted } from 'vue';
import '@n8n/chat/style.css';
import { createChat } from '@n8n/chat';

onMounted(() => {
	createChat({
		webhookUrl: 'YOUR_PRODUCTION_WEBHOOK_URL'
	});
});
</script>
<template>
	<div></div>
</template>
React
// App.tsx
import { useEffect } from 'react';
import '@n8n/chat/style.css';
import { createChat } from '@n8n/chat';

export const App = () => {
	useEffect(() => {
		createChat({
			webhookUrl: 'YOUR_PRODUCTION_WEBHOOK_URL'
		});
	}, []);

	return (<div></div>);
};

Options

The default options are:

createChat({
	webhookUrl: '',
	webhookConfig: {
		method: 'POST',
		headers: {}
	},
	target: '#n8n-chat',
	mode: 'window',
	defaultLanguage: 'en',
	initialMessages: [
		'Hi there! 👋',
		'My name is Nathan. How can I assist you today?'
	],
	i18n: {
		en: {
			title: 'Hi there! 👋',
			subtitle: "Start a chat. We're here to help you 24/7.",
			footer: '',
			getStarted: 'New Conversation',
			inputPlaceholder: 'Type your question..',
		},
	},
});

webhookUrl

  • Type: string
  • Required: true
  • Examples:
    • https://yourname.app.n8n.cloud/webhook/513107b3-6f3a-4a1e-af21-659f0ed14183
    • http://localhost:5678/webhook/513107b3-6f3a-4a1e-af21-659f0ed14183
  • Description: The URL of the n8n Webhook endpoint. Should be the production URL.

webhookConfig

  • Type: { method: string, headers: Record<string, string> }
  • Default: { method: 'POST', headers: {} }
  • Description: The configuration for the Webhook request.

target

  • Type: string
  • Default: '#n8n-chat'
  • Description: The CSS selector of the element where the Chat window should be embedded.

mode

  • Type: 'window' | 'fullscreen'
  • Default: 'window'
  • Description: The render mode of the Chat window.
    • In window mode, the Chat window will be embedded in the target element as a chat toggle button and a fixed size chat window.
    • In fullscreen mode, the Chat will take up the entire width and height of its target container.

defaultLanguage

  • Type: string
  • Default: 'en'
  • Description: The default language of the Chat window. Currently only en is supported.

i18n

  • Type: { [key: string]: Record<string, string> }
  • Description: The i18n configuration for the Chat window. Currently only en is supported.

initialMessages

  • Type: string[]
  • Description: The initial messages to be displayed in the Chat window.

Customization

The Chat window is entirely customizable using CSS variables.

:root {
	--chat--color-primary: #e74266;
	--chat--color-primary-shade-50: #db4061;
	--chat--color-primary-shade-100: #cf3c5c;
	--chat--color-secondary: #20b69e;
	--chat--color-secondary-shade-50: #1ca08a;
	--chat--color-white: #ffffff;
	--chat--color-light: #f2f4f8;
	--chat--color-light-shade-50: #e6e9f1;
	--chat--color-light-shade-100: #c2c5cc;
	--chat--color-medium: #d2d4d9;
	--chat--color-dark: #101330;
	--chat--color-disabled: #777980;
	--chat--color-typing: #404040;

	--chat--spacing: 1rem;
	--chat--border-radius: 0.25rem;
	--chat--transition-duration: 0.15s;

	--chat--window--width: 400px;
	--chat--window--height: 600px;

	--chat--textarea--height: 50px;

	--chat--message--bot--background: var(--chat--color-white);
	--chat--message--bot--color: var(--chat--color-dark);
	--chat--message--user--background: var(--chat--color-secondary);
	--chat--message--user--color: var(--chat--color-white);
	--chat--message--pre--background: rgba(0, 0, 0, 0.05);

	--chat--toggle--background: var(--chat--color-primary);
	--chat--toggle--hover--background: var(--chat--color-primary-shade-50);
	--chat--toggle--active--background: var(--chat--color-primary-shade-100);
	--chat--toggle--color: var(--chat--color-white);
	--chat--toggle--size: 64px;
}

Caveats

Fullscreen mode

In fullscreen mode, the Chat window will take up the entire width and height of its target container. Make sure that the container has a set width and height.

html,
body,
#n8n-chat {
	width: 100%;
	height: 100%;
}

License

n8n Chat is fair-code distributed under the Sustainable Use License.

Proprietary licenses are available for enterprise customers. Get in touch

Additional information about the license model can be found in the docs.