@aparte/n8n-chat 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +207 -2
  3. package/dist/cdn/chunks/chunk-MU6PIUJC.js +206 -0
  4. package/dist/cdn/chunks/chunk-MU6PIUJC.js.map +7 -0
  5. package/dist/cdn/chunks/chunk-XAWE4EAK.js +2 -0
  6. package/dist/cdn/chunks/chunk-XAWE4EAK.js.map +7 -0
  7. package/dist/cdn/chunks/de-WJNL5YNK.js +2 -0
  8. package/dist/cdn/chunks/de-WJNL5YNK.js.map +7 -0
  9. package/dist/cdn/chunks/es-DV5N3CXP.js +2 -0
  10. package/dist/cdn/chunks/es-DV5N3CXP.js.map +7 -0
  11. package/dist/cdn/chunks/fr-YU75PBOR.js +2 -0
  12. package/dist/cdn/chunks/fr-YU75PBOR.js.map +7 -0
  13. package/dist/cdn/chunks/highlight-HDJ3ROJ4.js +153 -0
  14. package/dist/cdn/chunks/highlight-HDJ3ROJ4.js.map +7 -0
  15. package/dist/cdn/chunks/it-DZTHWNO3.js +2 -0
  16. package/dist/cdn/chunks/it-DZTHWNO3.js.map +7 -0
  17. package/dist/cdn/chunks/ja-QO442LBN.js +2 -0
  18. package/dist/cdn/chunks/ja-QO442LBN.js.map +7 -0
  19. package/dist/cdn/chunks/ko-EGFZJCXQ.js +2 -0
  20. package/dist/cdn/chunks/ko-EGFZJCXQ.js.map +7 -0
  21. package/dist/cdn/chunks/pt-BR-526LHI67.js +2 -0
  22. package/dist/cdn/chunks/pt-BR-526LHI67.js.map +7 -0
  23. package/dist/cdn/chunks/ru-5WNEMKNP.js +2 -0
  24. package/dist/cdn/chunks/ru-5WNEMKNP.js.map +7 -0
  25. package/dist/cdn/chunks/zh-CN-ABSHNLG6.js +2 -0
  26. package/dist/cdn/chunks/zh-CN-ABSHNLG6.js.map +7 -0
  27. package/dist/cdn/n8n-chat.js +97 -0
  28. package/dist/cdn/n8n-chat.js.map +7 -0
  29. package/dist/create-chat.d.ts +187 -0
  30. package/dist/highlight-DDyMJYBk.js +29 -0
  31. package/dist/highlight-DDyMJYBk.js.map +1 -0
  32. package/dist/highlight.d.ts +2 -0
  33. package/dist/icons.d.ts +7 -0
  34. package/dist/index.d.ts +11 -0
  35. package/dist/index.js +593 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/strings.d.ts +40 -0
  38. package/dist/style.css +370 -0
  39. package/dist/theme.css +368 -0
  40. package/package.json +81 -5
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 aparté
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,208 @@
1
- # Temporary Holding Version
1
+ # @aparte/n8n-chat
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **n8n's chat widget, drawn by [aparté](https://apartejs.dev).** `createChat()` takes
4
+ [`@n8n/chat`](https://www.npmjs.com/package/@n8n/chat)'s options and mounts the same widget on
5
+ your n8n Chat Trigger — a button in the corner, or a chat that fills its target. Change the import,
6
+ keep your call.
7
+
8
+ <p>
9
+ <img src="docs/widget-light.png" alt="The widget open in a corner of a page, in n8n's light look: a question and the workflow's answer" width="300">
10
+ <img src="docs/widget-dark.png" alt="The same widget in its dark scheme" width="300">
11
+ </p>
12
+
13
+ - Every option of `@n8n/chat` 1.43, the same defaults, the same session in the browser — and the
14
+ Chat nodes' messages and buttons of a workflow that answers through response nodes.
15
+ - Ten languages, keyboard and screen-reader access, readable contrast, a dark scheme.
16
+ - About 100 KB (brotli) on the first load, against about 465 KB.
17
+ - A handle to drive it from your page: `open`, `close`, `toggle`, `send`, `reset`, `setDisabled`,
18
+ `destroy`.
19
+ - MIT.
20
+
21
+ ## Install
22
+
23
+ ### From a CDN — no build step
24
+
25
+ ```html
26
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@aparte/n8n-chat@0.1.0/dist/style.css">
27
+ <script type="module">
28
+ import { createChat } from 'https://cdn.jsdelivr.net/npm/@aparte/n8n-chat@0.1.0/dist/cdn/n8n-chat.js';
29
+
30
+ createChat({ webhookUrl: 'https://your-n8n.example.com/webhook/<id>/chat' });
31
+ </script>
32
+ ```
33
+
34
+ `dist/cdn/n8n-chat.js` is one module with aparté inside it. What only some pages need is fetched
35
+ when used, from beside it: a language other than English, and the code highlighter with the first
36
+ code block. Keep the version in the URL: the widget you tested is the widget your visitors get.
37
+
38
+ ### From npm
39
+
40
+ ```bash
41
+ npm install @aparte/n8n-chat
42
+ ```
43
+
44
+ ```ts
45
+ import { createChat } from '@aparte/n8n-chat';
46
+ import '@aparte/n8n-chat/style.css';
47
+
48
+ const chat = createChat({ webhookUrl: 'https://your-n8n.example.com/webhook/<id>/chat' });
49
+ chat.open();
50
+ ```
51
+
52
+ ## Coming from `@n8n/chat`
53
+
54
+ Replace the stylesheet and the import; the call stays as it is:
55
+
56
+ ```diff
57
+ - <link href="https://cdn.jsdelivr.net/npm/@n8n/chat/dist/style.css" rel="stylesheet" />
58
+ + <link href="https://cdn.jsdelivr.net/npm/@aparte/n8n-chat@0.1.0/dist/style.css" rel="stylesheet" />
59
+ <script type="module">
60
+ - import { createChat } from 'https://cdn.jsdelivr.net/npm/@n8n/chat/dist/chat.bundle.es.js';
61
+ + import { createChat } from 'https://cdn.jsdelivr.net/npm/@aparte/n8n-chat@0.1.0/dist/cdn/n8n-chat.js';
62
+ createChat({ webhookUrl: 'https://your-n8n.example.com/webhook/<id>/chat' });
63
+ </script>
64
+ ```
65
+
66
+ The session is kept where n8n's widget keeps it (`localStorage`, key `n8n-chat/sessionId`), so a
67
+ visitor keeps their conversation across the switch. `enableStreaming` needs no tuning: a streamed
68
+ answer and a whole one are both read.
69
+
70
+ ## Set up the workflow
71
+
72
+ In the **Chat Trigger** node:
73
+
74
+ 1. Turn on **Make Chat Publicly Available**. The production URL that ends in `/chat` is your
75
+ `webhookUrl`.
76
+ 2. Put your site's origin in **Allowed Origins (CORS)**.
77
+ 3. Choose how it answers, under **Response Mode**:
78
+ - **Streaming** — the AI Agent streams its answer as it writes it;
79
+ - **When Last Node Finishes** — one whole answer;
80
+ - **Using Response Nodes** — Chat nodes send the messages, and can ask questions with buttons
81
+ (see [Response nodes and buttons](#response-nodes-and-buttons)).
82
+ 4. **Publish** the workflow.
83
+
84
+ To show a visitor's earlier messages after a reload, attach a memory to the agent, set **Load
85
+ Previous Session** to **From Memory**, and connect that memory to the Chat Trigger as well: with the
86
+ memory on the agent only, n8n answers that request with an error.
87
+
88
+ ## Options
89
+
90
+ | Option | What it does | Default |
91
+ | --- | --- | --- |
92
+ | `webhookUrl` | the Chat Trigger's production URL, ending in `/chat` | required |
93
+ | `webhookConfig` | `headers` sent with every request, read each time (a refreshed token is sent); `method` is accepted, every request is a POST | `{}` |
94
+ | `target` | where it mounts: an element, or a selector | `'#n8n-chat'` |
95
+ | `mode` | `'window'` (a button in the corner) or `'fullscreen'` (fills its target) | `'window'` |
96
+ | `showWindowCloseButton` | a ✕ in the header, in window mode | `false` |
97
+ | `showWelcomeScreen` | a screen with a "New Conversation" button first | `false` |
98
+ | `loadPreviousSession` | keep the session in the browser and show its earlier messages | `true` |
99
+ | `sessionId` | use this session instead of the stored one | — |
100
+ | `chatInputKey`, `chatSessionKey` | the body fields the workflow reads | `'chatInput'`, `'sessionId'` |
101
+ | `defaultLanguage` | the language, as a tag (`'de'`, `'pt-BR'`) | `'en'` |
102
+ | `i18n` | the chrome's words by language, over the built-in ones | — |
103
+ | `locale` | the chat's own words, for a language not shipped | — |
104
+ | `initialMessages` | messages shown first, from the assistant | n8n's two |
105
+ | `messageHistory` | a conversation to show when n8n has none (text, `type: 'component'`, `transparent`) | — |
106
+ | `messageComponents` | functions that draw `type: 'component'` history messages | — |
107
+ | `metadata` | sent with every message, as `metadata` in the trigger's output | — |
108
+ | `allowFileUploads`, `allowedFilesMimeTypes` | let the person attach files, and which | `false`, any |
109
+ | `enableMessageActions` | "Repost" and "Reuse" on the person's own messages | `false` |
110
+ | `disabled` | block the input (`true`, or n8n's `{ value }`) | `false` |
111
+ | `beforeMessageSent`, `afterMessageSent` | hooks around each message | — |
112
+ | `suggestions` | questions offered above the input until the first message | — |
113
+ | `colorScheme` | `'light'`, `'dark'` or `'auto'` (the visitor's) | `'light'` |
114
+ | `fetch` | the `fetch` every request goes through | the global one |
115
+ | `enableStreaming`, `theme` | accepted for compatibility | — |
116
+
117
+ ## The handle
118
+
119
+ `createChat()` returns what your page drives it with:
120
+
121
+ ```ts
122
+ const chat = createChat({ webhookUrl });
123
+
124
+ chat.open(); // open the window (close, toggle too)
125
+ chat.send('Where is my order?'); // as the visitor; waits for an answer on its way
126
+ chat.reset(); // a new conversation, in a new session
127
+ chat.setDisabled(true); // block the input, or let the visitor type again
128
+ chat.destroy(); // remove it (unmount does the same)
129
+
130
+ chat.sessionId; // the session the conversation runs in
131
+ chat.element; // the widget's root element
132
+ ```
133
+
134
+ ## Response nodes and buttons
135
+
136
+ A Chat Trigger set to **Using Response Nodes** answers through **Chat** nodes placed in the
137
+ workflow. Each message a Chat node sends is drawn as a block of its own. A Chat node that **waits
138
+ for a written reply** gets the visitor's next message. A Chat node that **waits for an approval**
139
+ sends buttons, asked above the input with the labels you gave them; the one chosen goes back to n8n
140
+ and the workflow carries on.
141
+
142
+ **Block User Input**, on that Chat node, decides whether the visitor may write instead of choosing:
143
+ on, the answer has to be a button; off, the words reach n8n as a message and the node goes on as
144
+ not approved — as with n8n's own widget.
145
+
146
+ On n8n 2.x, Chat nodes run only when the Chat Trigger's **Mode** is **Hosted Chat**; an embedded
147
+ one stops with "Embedded chat is not supported". A button whose link leads off your n8n is not
148
+ shown.
149
+
150
+ ## Files
151
+
152
+ With `allowFileUploads`, the visitor picks, drops or pastes files, and n8n receives them as
153
+ `files`, as from n8n's widget. A file can be removed with the keyboard; a picture or a file the
154
+ visitor sent opens in a new tab.
155
+
156
+ ## Languages
157
+
158
+ English, French, Spanish, Portuguese (Brazil), German, Italian, Russian, Japanese, Korean and
159
+ Chinese (Simplified). A page downloads only the language it uses. Set `defaultLanguage`; override
160
+ any word of the header or the input with `i18n`; give a whole `locale` for another language.
161
+
162
+ ## Look
163
+
164
+ It wears n8n's look by default and reads n8n's main `--chat--*` variables — colors, fonts, radii,
165
+ the window's size, the button — so a page that themed n8n's widget keeps most of its theme:
166
+
167
+ ```css
168
+ :root {
169
+ --chat--color--primary: #e74266;
170
+ --chat--color--secondary: #178272;
171
+ --chat--window--width: 420px;
172
+ }
173
+ ```
174
+
175
+ CSS written against n8n's `.chat-*` classes does not carry over; the variables do.
176
+ `colorScheme: 'dark'` (or `'auto'`) gives the dark scheme. `@aparte/n8n-chat/theme.css` is the n8n
177
+ look alone, for a chat you compose yourself with
178
+ [`@aparte/runner-n8n`](https://apartejs.dev/providers/agent/n8n/) and aparté's React, Vue, Svelte
179
+ or Angular components, inside an `.aparte-n8n` element.
180
+
181
+ ## Compared with `@n8n/chat`
182
+
183
+ | | `@n8n/chat` 1.43 | `@aparte/n8n-chat` |
184
+ | --- | --- | --- |
185
+ | Drive it from the page | — | `open`, `close`, `toggle`, `send`, `reset`, `setDisabled`, `destroy` |
186
+ | A new conversation | not until the browser's storage is cleared | `reset()` |
187
+ | A tool's steps after a reload | bubbles with raw JSON | left out, as while chatting |
188
+ | An error | the raw message | a sentence in the visitor's language, the workflow's own words under it, what to fix on the console |
189
+ | Languages | English | ten, loaded one at a time |
190
+ | Keyboard and screen reader | buttons without names | named controls, a labelled window, a modal sheet on a phone |
191
+ | Contrast of the visitor's bubble | 2.55:1 | 4.7:1 (WCAG AA) |
192
+ | Dark scheme | — | ✓ |
193
+ | Weight, first load (brotli) | ~465 KB | ~100 KB, +~103 KB with the first code block |
194
+ | License | Sustainable Use License | MIT |
195
+
196
+ ## Versions
197
+
198
+ The widget depends on **exact** versions of aparté's packages, and moves to a newer aparté only in
199
+ a release of its own. Pin the widget's version in a CDN URL and in your `package.json`, and what you
200
+ tested is what your visitors run.
201
+
202
+ ## Links
203
+
204
+ - [aparté](https://apartejs.dev) — the library it is built with.
205
+ - [`@aparte/runner-n8n`](https://apartejs.dev/providers/agent/n8n/) — the n8n protocol alone, to put
206
+ an n8n workflow behind a chat you compose yourself.
207
+
208
+ MIT © Paul Richez