n8n/packages/@n8n/chat
github-actions[bot] b67b5ae6b2
🚀 Release 1.22.0 (#8115)
#
[1.22.0](https://github.com/n8n-io/n8n/compare/n8n@1.21.0...n8n@1.22.0)
(2023-12-21)


### Bug Fixes

* **core:** Close db connection gracefully when exiting
([#8045](https://github.com/n8n-io/n8n/pull/8045))
([e69707e](e69707efd4))
* **core:** Consider timeout in shutdown an error
([#8050](https://github.com/n8n-io/n8n/pull/8050))
([4cae976](4cae976a3b))
* **core:** Do not display error when stopping jobless execution in
queue mode ([#8007](https://github.com/n8n-io/n8n/pull/8007))
([8e6b951](8e6b951a76))
* **core:** Fix shutdown if terminating before hooks are initialized
([#8047](https://github.com/n8n-io/n8n/pull/8047))
([6ae2f5e](6ae2f5efea))
* **core:** Handle multiple termination signals correctly
([#8046](https://github.com/n8n-io/n8n/pull/8046))
([67bd8ad](67bd8ad698))
* **core:** Initialize queue once in queue mode
([#8025](https://github.com/n8n-io/n8n/pull/8025))
([53c0b49](53c0b49d15))
* **core:** Prevent axios from force setting a form-urlencoded
content-type ([#8117](https://github.com/n8n-io/n8n/pull/8117))
([bba9576](bba95761e2))
* **core:** Remove circular references before serializing executions in
public API ([#8043](https://github.com/n8n-io/n8n/pull/8043))
([989888d](989888d9bc))
* **core:** Restore workflow ID during execution creation
([#8031](https://github.com/n8n-io/n8n/pull/8031))
([c5e6ba8](c5e6ba8cdd))
* **core:** Use relative imports for dynamic imports in
SecurityAuditService ([#8086](https://github.com/n8n-io/n8n/pull/8086))
([785bf99](785bf9974e))
* **core:** Stop binary data restoration from preventing execution from
finishing ([#8082](https://github.com/n8n-io/n8n/pull/8082))
([5ffff1b](5ffff1bb22))
* **editor:** Add back credential `use` permission
([#8023](https://github.com/n8n-io/n8n/pull/8023))
([329e5bf](329e5bf9ee))
* **editor:** Cleanup Executions page component
([#8053](https://github.com/n8n-io/n8n/pull/8053))
([2689c37](2689c37e87))
* **editor:** Disable auto scroll and list size check when clicking on
executions ([#7983](https://github.com/n8n-io/n8n/pull/7983))
([fcb8b91](fcb8b91f37))
* **editor:** Ensure execution data overrides pinned data when copying
in executions view ([#8009](https://github.com/n8n-io/n8n/pull/8009))
([1d1cb0d](1d1cb0d3c5))
* **editor:** Fix copy/paste issue when switch node is in workflow
([#8103](https://github.com/n8n-io/n8n/pull/8103))
([4b86926](4b86926752))
* **editor:** Make keyboard shortcuts more strict; don't accept extra
Ctrl/Alt/Shift keys ([#8024](https://github.com/n8n-io/n8n/pull/8024))
([8df49e1](8df49e134d))
* **editor:** Show credential share info only to appropriate users
([#8020](https://github.com/n8n-io/n8n/pull/8020))
([b29b4d4](b29b4d442b))
* **editor:** Turn off executions list auto-refresh after leaving the
page ([#8005](https://github.com/n8n-io/n8n/pull/8005))
([e3c363d](e3c363d72c))
* **editor:** Update image sizes in template description not to be full
width always ([#8037](https://github.com/n8n-io/n8n/pull/8037))
([63a6e7e](63a6e7e034))
* **ActiveCampaign Node:** Fix pagination issue when loading tags
([#8017](https://github.com/n8n-io/n8n/pull/8017))
([1943857](1943857231))
* **HTTP Request Node:** Do not create circular references in HTTP
request node output ([#8030](https://github.com/n8n-io/n8n/pull/8030))
([5b7ea16](5b7ea16d9a))
* Upgrade axios to address CVE-2023-45857
([#7713](https://github.com/n8n-io/n8n/pull/7713))
([64eb9bb](64eb9bbc36))


### Features

* Add option to `returnIntermediateSteps` for AI agents
([#8113](https://github.com/n8n-io/n8n/pull/8113))
([7806a65](7806a65229))
* **core:** Add config option to prefer GET request over LIST when using
Hashicorp Vault ([#8049](https://github.com/n8n-io/n8n/pull/8049))
([439a22d](439a22d68f))
* **core:** Add N8N_GRACEFUL_SHUTDOWN_TIMEOUT env var
([#8068](https://github.com/n8n-io/n8n/pull/8068))
([614f488](614f488386))
* **editor:** Add lead enrichment suggestions to workflow list
([#8042](https://github.com/n8n-io/n8n/pull/8042))
([36a923c](36a923cf7b))
* **editor:** Finalize workers view
([#8052](https://github.com/n8n-io/n8n/pull/8052))
([edfa784](edfa78414d))
* **editor:** Gracefully ignore invalid payloads in postMessage handler
([#8096](https://github.com/n8n-io/n8n/pull/8096))
([9d22c7a](9d22c7a278))
* **editor:** Upgrade frontend tooling to address a few vulnerabilities
([#8100](https://github.com/n8n-io/n8n/pull/8100))
([19b7f1f](19b7f1ffb1))
* **Filter Node:** Overhaul UI by adding the new filter component
([#8016](https://github.com/n8n-io/n8n/pull/8016))
([3d53052](3d530522f8))
* **Respond to Webhook Node:** Overhaul with improvements like returning
all items ([#8093](https://github.com/n8n-io/n8n/pull/8093))
([32d397e](32d397eff3))


### Performance Improvements

* **editor:** Improve canvas rendering performance
([#8022](https://github.com/n8n-io/n8n/pull/8022))
([b780436](b780436a6b))

Co-authored-by: ivov <ivov@users.noreply.github.com>
2023-12-21 13:51:24 +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: Fix lint warnings in @n8n/chat and @n8n/nodes-langchain (no-changelog) (#7884) 2023-11-30 13:22:27 +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.22.0 (#8115) 2023-12-21 13:51:24 +01:00
README.md docs: Replace http://faircode.io to https://faircode.io in .md files (#7908) 2023-12-12 15:23:22 +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.