n8n/packages/@n8n/chat
github-actions[bot] 1516c84dad
🚀 Release 1.21.0 (#8019)
#
[1.21.0](https://github.com/n8n-io/n8n/compare/n8n@1.20.0...n8n@1.21.0)
(2023-12-13)


### Bug Fixes

* **core:** Ensure inviter and invitee are set correctly in invite link
([#7943](https://github.com/n8n-io/n8n/issues/7943))
([386bd61](386bd61967))
* **core:** Fix user comparison in same-user subworkflow caller policy
([#7913](https://github.com/n8n-io/n8n/issues/7913))
([92bab72](92bab72cff))
* **core:** Perform multi-main leader check against key ID
([#7964](https://github.com/n8n-io/n8n/issues/7964))
([1a87f70](1a87f70e84))
* **core:** Ensure external hooks post workflow execute run in queue
mode ([#7947](https://github.com/n8n-io/n8n/issues/7947))
([3ba7deb](3ba7deb337))
* **core:** Fix issue preventing secrets from loading if the path
contains - or / ([#7988](https://github.com/n8n-io/n8n/issues/7988))
([0ac9594](0ac959463f))
* **core:** Restrict updating/deleting of shared but not owned
credentials ([#7950](https://github.com/n8n-io/n8n/issues/7950))
([42e828d](42e828d5c6))
* **core:** Prevent workflow history saving error from happening
([#7812](https://github.com/n8n-io/n8n/issues/7812))
([e5581ce](e5581ce802))
* **editor:** Add missing string for worker in log streaming
([#7971](https://github.com/n8n-io/n8n/issues/7971))
([148bc1d](148bc1d303))
* **editor:** Allow SSH protocol in git repository URL for environments
([#7944](https://github.com/n8n-io/n8n/issues/7944))
([bc1c72f](bc1c72f992))
* **editor:** Fix bug with node names with certain characters
([#8013](https://github.com/n8n-io/n8n/issues/8013))
([26f0d57](26f0d57f5f))
* **editor:** Fix Webhook URL expansion icon
([#8011](https://github.com/n8n-io/n8n/issues/8011))
([b00b905](b00b9057a4))
* **editor:** Prevent opening NDV search if `/` is typed in a
contenteditable element
([#7968](https://github.com/n8n-io/n8n/issues/7968))
([e8a493f](e8a493f718))
* **editor:** Return early in ws message handler if no 'command' keyword
is found ([#7946](https://github.com/n8n-io/n8n/issues/7946))
([5b2defc](5b2defc867))
* **FileMaker Node:** Prevent erroring on zero fields loaded
([#7955](https://github.com/n8n-io/n8n/issues/7955))
([10ad386](10ad386604))
* **Google Sheets Node:** Prevent erroring on zero sheet search results
([#7957](https://github.com/n8n-io/n8n/issues/7957))
([9b877a9](9b877a9427))
* **Google Sheets Node:** Prevent erroring when fetching mapping columns
([#7972](https://github.com/n8n-io/n8n/issues/7972))
([29a1066](29a10668d1))
* **Postgres Node:** Do not include id column in upsert fields selection
if it's not unique ([#7975](https://github.com/n8n-io/n8n/issues/7975))
([435392c](435392cbfe))
* **Postgres Trigger Node:** Increase manual trigger timeout from 30 to
60 seconds ([#8015](https://github.com/n8n-io/n8n/issues/8015))
([09a5729](09a5729305))
* **Webhook Node:** Binary data handling
([#7804](https://github.com/n8n-io/n8n/issues/7804))
([565b409](565b409a82))
* **Webhook Node:** Do not create binary data when there is no data in
the request ([#8000](https://github.com/n8n-io/n8n/issues/8000))
([70f0755](70f0755278))


### Features

* **core:** Add config option for external secret update interval
([#7995](https://github.com/n8n-io/n8n/issues/7995))
([b6c1c04](b6c1c04b54))
* AI nodes usability fixes + Summarization Chain V2
([#7949](https://github.com/n8n-io/n8n/issues/7949))
([dcf1286](dcf12867b3))
* **editor:** Data transformation nodes and actions in Nodes Panel
([#7760](https://github.com/n8n-io/n8n/issues/7760))
([675ec21](675ec21d33))
* **editor:** Add AppCues tracking for onboarding event
([#7945](https://github.com/n8n-io/n8n/issues/7945))
([04cabaf](04cabafef7))
* **editor:** Add option to disable NDV in workflow previews
([#7990](https://github.com/n8n-io/n8n/issues/7990))
([393afef](393afef174))
* **editor:** Filter component + implement in If node
([#7490](https://github.com/n8n-io/n8n/issues/7490))
([8a53434](8a5343401d))
* **editor:** Show template credential setup based on feature flag
([#7989](https://github.com/n8n-io/n8n/issues/7989))
([08ee307](08ee307209))
* **editor:** Introduce advanced permissions
([#7844](https://github.com/n8n-io/n8n/issues/7844))
([dbd62a4](dbd62a4992))
* **Google Ads Node:** Update to support v15
([#7962](https://github.com/n8n-io/n8n/issues/7962))
([7f01269](7f0126915a))
* **Local File Trigger Node:** Add polling option typically good to
watch network files/folders
([#7942](https://github.com/n8n-io/n8n/issues/7942))
([2fbdfec](2fbdfec0c0))
* **n8n Form Trigger Node:** Improvements
([#7571](https://github.com/n8n-io/n8n/issues/7571))
([953a58f](953a58f18b))

Co-authored-by: ivov <ivov@users.noreply.github.com>
2023-12-13 16:34:00 +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.21.0 (#8019) 2023-12-13 16:34:00 +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.