@n8n/chat 0.9.0 → 0.10.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.
- package/.storybook/main.ts +2 -25
- package/.storybook/preview.ts +0 -1
- package/package.json +1 -1
- package/src/plugins/chat.ts +11 -1
- package/src/types/webhook.ts +2 -1
- package/vite.config.ts +1 -0
package/.storybook/main.ts
CHANGED
|
@@ -1,27 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { sharedConfig } from '@n8n/storybook/main';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* This function is used to resolve the absolute path of a package.
|
|
7
|
-
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
|
|
8
|
-
*/
|
|
9
|
-
function getAbsolutePath(value: string): any {
|
|
10
|
-
return dirname(require.resolve(join(value, 'package.json')));
|
|
11
|
-
}
|
|
12
|
-
const config: StorybookConfig = {
|
|
13
|
-
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
|
|
14
|
-
addons: [
|
|
15
|
-
getAbsolutePath('@storybook/addon-links'),
|
|
16
|
-
getAbsolutePath('@storybook/addon-essentials'),
|
|
17
|
-
getAbsolutePath('@storybook/addon-interactions'),
|
|
18
|
-
],
|
|
19
|
-
framework: {
|
|
20
|
-
name: getAbsolutePath('@storybook/vue3-vite'),
|
|
21
|
-
options: {},
|
|
22
|
-
},
|
|
23
|
-
docs: {
|
|
24
|
-
autodocs: 'tag',
|
|
25
|
-
},
|
|
26
|
-
};
|
|
3
|
+
const config = { ...sharedConfig };
|
|
27
4
|
export default config;
|
package/.storybook/preview.ts
CHANGED
package/package.json
CHANGED
package/src/plugins/chat.ts
CHANGED
|
@@ -45,9 +45,19 @@ export const ChatPlugin: Plugin<ChatOptions> = {
|
|
|
45
45
|
options,
|
|
46
46
|
);
|
|
47
47
|
|
|
48
|
+
let textMessage = sendMessageResponse.output ?? sendMessageResponse.text ?? '';
|
|
49
|
+
|
|
50
|
+
if (textMessage === '' && Object.keys(sendMessageResponse).length > 0) {
|
|
51
|
+
try {
|
|
52
|
+
textMessage = JSON.stringify(sendMessageResponse, null, 2);
|
|
53
|
+
} catch (e) {
|
|
54
|
+
// Failed to stringify the object so fallback to empty string
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
48
58
|
const receivedMessage: ChatMessage = {
|
|
49
59
|
id: uuidv4(),
|
|
50
|
-
text:
|
|
60
|
+
text: textMessage,
|
|
51
61
|
sender: 'bot',
|
|
52
62
|
createdAt: new Date().toISOString(),
|
|
53
63
|
};
|
package/src/types/webhook.ts
CHANGED