@rjsebening/n8n-nodes-learningsuite 1.3.2 → 1.3.3
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.
|
@@ -10,6 +10,12 @@ exports.aiProperties = [
|
|
|
10
10
|
default: 'ragChat',
|
|
11
11
|
displayOptions: { show: { resource: ['ai'] } },
|
|
12
12
|
options: [
|
|
13
|
+
{
|
|
14
|
+
name: 'Agent Chat',
|
|
15
|
+
value: 'agentChat',
|
|
16
|
+
description: 'Send a message to an AI agent and get the response',
|
|
17
|
+
action: 'Send message to AI agent',
|
|
18
|
+
},
|
|
13
19
|
{
|
|
14
20
|
name: 'Get Agent Actions',
|
|
15
21
|
value: 'getAgentActions',
|
|
@@ -30,6 +36,74 @@ exports.aiProperties = [
|
|
|
30
36
|
},
|
|
31
37
|
],
|
|
32
38
|
},
|
|
39
|
+
{
|
|
40
|
+
displayName: 'AI Agent Name or ID',
|
|
41
|
+
name: 'agentId',
|
|
42
|
+
type: 'options',
|
|
43
|
+
typeOptions: { loadOptionsMethod: 'ai_getAiAgents' },
|
|
44
|
+
required: true,
|
|
45
|
+
default: '',
|
|
46
|
+
description: 'The AI agent to chat with. For the global AI Concierge agent, you may also use the shortcut "concierge". Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
47
|
+
displayOptions: { show: { resource: ['ai'], operation: ['agentChat'] } },
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
displayName: 'User Name or ID',
|
|
51
|
+
name: 'userId',
|
|
52
|
+
type: 'options',
|
|
53
|
+
typeOptions: { loadOptionsMethod: 'member_getMembers' },
|
|
54
|
+
required: true,
|
|
55
|
+
default: '',
|
|
56
|
+
description: 'The user ID of the member sending the message. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
57
|
+
displayOptions: { show: { resource: ['ai'], operation: ['agentChat'] } },
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
displayName: 'Message',
|
|
61
|
+
name: 'message',
|
|
62
|
+
type: 'string',
|
|
63
|
+
default: '',
|
|
64
|
+
description: 'The message you want to send to the AI agent',
|
|
65
|
+
displayOptions: { show: { resource: ['ai'], operation: ['agentChat'] } },
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
displayName: 'Chat ID',
|
|
69
|
+
name: 'chatId',
|
|
70
|
+
type: 'string',
|
|
71
|
+
default: '',
|
|
72
|
+
description: 'The chat/conversation you want to send the message to. Leave empty to start a new chat.',
|
|
73
|
+
displayOptions: { show: { resource: ['ai'], operation: ['agentChat'] } },
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
displayName: 'Include Chat History',
|
|
77
|
+
name: 'includeChatHistory',
|
|
78
|
+
type: 'boolean',
|
|
79
|
+
default: false,
|
|
80
|
+
description: 'Whether to return the full chat history in the response. Otherwise, only the latest agent response is returned.',
|
|
81
|
+
displayOptions: { show: { resource: ['ai'], operation: ['agentChat'] } },
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
displayName: 'End Chat',
|
|
85
|
+
name: 'endChat',
|
|
86
|
+
type: 'boolean',
|
|
87
|
+
default: false,
|
|
88
|
+
description: 'Whether to end the chat after this message. The agent will not generate a response. Useful when filling out a form is complete.',
|
|
89
|
+
displayOptions: { show: { resource: ['ai'], operation: ['agentChat'] } },
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
displayName: 'Metadata',
|
|
93
|
+
name: 'metadata',
|
|
94
|
+
type: 'json',
|
|
95
|
+
default: '{}',
|
|
96
|
+
description: 'If a previous agent response included metadata, it should be included in the next request. Provide as JSON object.',
|
|
97
|
+
displayOptions: { show: { resource: ['ai'], operation: ['agentChat'] } },
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
displayName: 'Profile Context',
|
|
101
|
+
name: 'profileContext',
|
|
102
|
+
type: 'json',
|
|
103
|
+
default: '{}',
|
|
104
|
+
description: 'Optional profile context to use when interacting with custom field (forms). Only used if the agent config supports it. Provide as JSON object with a "selectedProfileIdByCard" property.',
|
|
105
|
+
displayOptions: { show: { resource: ['ai'], operation: ['agentChat'] } },
|
|
106
|
+
},
|
|
33
107
|
{
|
|
34
108
|
displayName: 'Question',
|
|
35
109
|
name: 'question',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.aiHandlers = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
4
5
|
const shared_1 = require("../shared");
|
|
5
6
|
const getAgentActions = async (ctx) => {
|
|
6
7
|
return await shared_1.lsRequest.call(ctx, 'GET', '/agent-actions');
|
|
@@ -8,6 +9,40 @@ const getAgentActions = async (ctx) => {
|
|
|
8
9
|
const getAiAgents = async (ctx) => {
|
|
9
10
|
return await shared_1.lsRequest.call(ctx, 'GET', '/ai-agents');
|
|
10
11
|
};
|
|
12
|
+
function parseJsonObjectParam(ctx, i, name) {
|
|
13
|
+
const raw = ctx.getNodeParameter(name, i, '');
|
|
14
|
+
if (raw === undefined || raw === null || raw === '')
|
|
15
|
+
return undefined;
|
|
16
|
+
if (typeof raw === 'object')
|
|
17
|
+
return raw;
|
|
18
|
+
let parsed;
|
|
19
|
+
try {
|
|
20
|
+
parsed = JSON.parse(raw);
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
throw new n8n_workflow_1.NodeOperationError(ctx.getNode(), `Invalid JSON in "${name}": ${String(err)}`);
|
|
24
|
+
}
|
|
25
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
26
|
+
throw new n8n_workflow_1.NodeOperationError(ctx.getNode(), `"${name}" must be a JSON object`);
|
|
27
|
+
}
|
|
28
|
+
return parsed;
|
|
29
|
+
}
|
|
30
|
+
const agentChat = async (ctx, i) => {
|
|
31
|
+
const agentId = ctx.getNodeParameter('agentId', i);
|
|
32
|
+
if (!agentId)
|
|
33
|
+
throw new n8n_workflow_1.NodeOperationError(ctx.getNode(), 'AI Agent is required');
|
|
34
|
+
const body = {
|
|
35
|
+
userId: ctx.getNodeParameter('userId', i),
|
|
36
|
+
chatId: ctx.getNodeParameter('chatId', i, undefined),
|
|
37
|
+
message: ctx.getNodeParameter('message', i, undefined),
|
|
38
|
+
includeChatHistory: ctx.getNodeParameter('includeChatHistory', i, false),
|
|
39
|
+
endChat: ctx.getNodeParameter('endChat', i, false),
|
|
40
|
+
metadata: parseJsonObjectParam(ctx, i, 'metadata'),
|
|
41
|
+
profileContext: parseJsonObjectParam(ctx, i, 'profileContext'),
|
|
42
|
+
};
|
|
43
|
+
const cleanBody = Object.fromEntries(Object.entries(body).filter(([, v]) => v !== undefined && v !== ''));
|
|
44
|
+
return await shared_1.lsRequest.call(ctx, 'POST', `/ai-agents/${encodeURIComponent(agentId)}/chat`, { body: cleanBody });
|
|
45
|
+
};
|
|
11
46
|
const ragChat = async (ctx, i) => {
|
|
12
47
|
const body = {
|
|
13
48
|
question: ctx.getNodeParameter('question', i),
|
|
@@ -25,6 +60,7 @@ const ragChat = async (ctx, i) => {
|
|
|
25
60
|
return await shared_1.lsRequest.call(ctx, 'POST', '/ai/rag-chat', { body: cleanBody });
|
|
26
61
|
};
|
|
27
62
|
exports.aiHandlers = {
|
|
63
|
+
agentChat,
|
|
28
64
|
getAgentActions,
|
|
29
65
|
getAiAgents,
|
|
30
66
|
ragChat,
|