n8n/packages/@n8n/chat
github-actions[bot] 303cf31331
🚀 Release 1.19.0 (#7863)
#
[1.19.0](https://github.com/n8n-io/n8n/compare/n8n@1.18.0...n8n@1.19.0)
(2023-11-29)


### Bug Fixes

* **core:** Ensure member and admin cannot be promoted to owner
([#7830](https://github.com/n8n-io/n8n/issues/7830))
([9b87a59](9b87a596ca)),
closes
[/linear.app/n8n/issue/PAY-985/add-user-role-modification-endpoint#comment-62355f6](https://github.com//linear.app/n8n/issue/PAY-985/add-user-role-modification-endpoint/issues/comment-62355f6)
* **core:** Prevent error messages due to statistics about data loading
([#7824](https://github.com/n8n-io/n8n/issues/7824))
([847f6ac](847f6ac771))
* **core:** Tighten checks for multi-main setup usage
([#7788](https://github.com/n8n-io/n8n/issues/7788))
([fdb2c18](fdb2c18ecc))
* **core:** Use AbortController to notify nodes to abort execution
([#6141](https://github.com/n8n-io/n8n/issues/6141))
([d2c18c5](d2c18c5727))
* **editor:** Add telemetry to workflow history
([#7811](https://github.com/n8n-io/n8n/issues/7811))
([d497041](d4970410e1))
* **editor:** Allow owners and admins to share workflows and credentials
they don't own ([#7833](https://github.com/n8n-io/n8n/issues/7833))
([3ab3ec9](3ab3ec9da8))
* **editor:** Disable context menu actions in read-only mode
([#7789](https://github.com/n8n-io/n8n/issues/7789))
([902beff](902beffce5))
* **editor:** Fix cloud plan data loading on instance
([#7841](https://github.com/n8n-io/n8n/issues/7841))
([8b99384](8b99384367))
* **editor:** Fix credential icon for old node type version
([#7843](https://github.com/n8n-io/n8n/issues/7843))
([4074107](4074107511))
* **editor:** Fix icon for unknown node type
([#7842](https://github.com/n8n-io/n8n/issues/7842))
([28ac5a7](28ac5a750e))
* **editor:** Fix mouse position in workflow previews
([#7853](https://github.com/n8n-io/n8n/issues/7853))
([c063398](c0633987bf))
* **editor:** Show nice error when environment is not set up
([#7778](https://github.com/n8n-io/n8n/issues/7778))
([5835e05](5835e055d3))
* **editor:** Suppress dev server websocket messages in workflow view
([#7808](https://github.com/n8n-io/n8n/issues/7808))
([685ffd7](685ffd7413))
* **Google Sheets Node:** Read operation execute for each item
([#7800](https://github.com/n8n-io/n8n/issues/7800))
([d548872](d5488725a8))
* **HTTP Request Node:** Enable expressions for binary input data fields
([#7782](https://github.com/n8n-io/n8n/issues/7782))
([6208af0](6208af07eb))
* **Microsoft SQL Node:** Prevent double escaping table name
([#7801](https://github.com/n8n-io/n8n/issues/7801))
([73ec753](73ec7533ce))


### Features

* Add AI tool building capabilities
([#7336](https://github.com/n8n-io/n8n/issues/7336))
([87def60](87def60979))
* Add initial scope checks via decorators
([#7737](https://github.com/n8n-io/n8n/issues/7737))
([a37f1cb](a37f1cb0ba))
* Ado 1296 spike credential setup in templates
([#7786](https://github.com/n8n-io/n8n/issues/7786))
([aae45b0](aae45b043b))
* **core:** Add Support for custom CORS origins for webhooks
([#7455](https://github.com/n8n-io/n8n/issues/7455))
([99a9ea4](99a9ea497a))
* **core:** Allow user role modification
([#7797](https://github.com/n8n-io/n8n/issues/7797))
([7a86d36](7a86d36068))
* **core:** Set up endpoint for all existing roles with license flag
([#7834](https://github.com/n8n-io/n8n/issues/7834))
([2356fb0](2356fb0f0c))
* **editor:** Add node name and version to NDV node settings
([#7731](https://github.com/n8n-io/n8n/issues/7731))
([da85198](da851986f6))
* **editor:** Add routing middleware, permission checks, RBAC store,
RBAC component ([#7702](https://github.com/n8n-io/n8n/issues/7702))
([67a8891](67a88914f2))
* **editor:** Replace middleware for Role checks with Scope checks
([#7847](https://github.com/n8n-io/n8n/issues/7847))
([72852a6](72852a60eb))
* **editor:** Show avatars for users currently working on the same
workflow ([#7763](https://github.com/n8n-io/n8n/issues/7763))
([77bc8ec](77bc8ecd4b))
* **Notion Node:** Option to simplify output in getChildBlocks operation
([#7791](https://github.com/n8n-io/n8n/issues/7791))
([d667bca](d667bca658))
* **Slack Node:** Add support for getting the profile of a user
([#7829](https://github.com/n8n-io/n8n/issues/7829))
([90bb6ba](90bb6ba417))

Co-authored-by: ivov <ivov@users.noreply.github.com>
2023-11-29 13:17:03 +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 feat: Add AI tool building capabilities (#7336) 2023-11-29 12:13:55 +01:00
.eslintignore feat: Add AI tool building capabilities (#7336) 2023-11-29 12:13:55 +01:00
.eslintrc.cjs feat: Add AI tool building capabilities (#7336) 2023-11-29 12:13: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.19.0 (#7863) 2023-11-29 13:17:03 +01:00
README.md feat: Add AI tool building capabilities (#7336) 2023-11-29 12:13:55 +01: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.