@rjsebening/n8n-nodes-learningsuite 1.3.1 → 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.
@@ -57,6 +57,8 @@ export declare class LearningSuiteTrigger implements INodeType {
57
57
  community_getBadges(this: import("n8n-workflow").ILoadOptionsFunctions): Promise<import("n8n-workflow").INodePropertyOptions[]>;
58
58
  community_getLatestPosts(this: import("n8n-workflow").ILoadOptionsFunctions): Promise<import("n8n-workflow").INodePropertyOptions[]>;
59
59
  bundle_getBundles(this: import("n8n-workflow").ILoadOptionsFunctions): Promise<import("n8n-workflow").INodePropertyOptions[]>;
60
+ ai_getAgentActions(this: import("n8n-workflow").ILoadOptionsFunctions): Promise<import("n8n-workflow").INodePropertyOptions[]>;
61
+ ai_getAiAgents(this: import("n8n-workflow").ILoadOptionsFunctions): Promise<import("n8n-workflow").INodePropertyOptions[]>;
60
62
  };
61
63
  };
62
64
  webhookMethods: {
@@ -39,6 +39,7 @@ const request_1 = require("./shared/request");
39
39
  const trigger_instant_properties_1 = require("./descriptions/trigger.instant.properties");
40
40
  const parsing_1 = require("./shared/parsing");
41
41
  // methods - loadOptions
42
+ const loAi = __importStar(require("./methods/loadOptions/ai.loadOptions"));
42
43
  const loBundle = __importStar(require("./methods/loadOptions/bundle.loadOptions"));
43
44
  const loCommunity = __importStar(require("./methods/loadOptions/community.loadOptions"));
44
45
  const loCourse = __importStar(require("./methods/loadOptions/course.loadOptions"));
@@ -102,6 +103,17 @@ function buildDesiredFilter(event) {
102
103
  }
103
104
  };
104
105
  switch (event) {
106
+ // ---------------- Agent Action
107
+ case 'agentAction.executed': {
108
+ const col = getCol('additionalAgentActionExecuted');
109
+ if (col === null || col === void 0 ? void 0 : col.toolKey) {
110
+ filter.toolKey = String(col.toolKey);
111
+ }
112
+ if (col === null || col === void 0 ? void 0 : col.agentId) {
113
+ filter.agentId = String(col.agentId);
114
+ }
115
+ break;
116
+ }
105
117
  // ---------------- Community
106
118
  case 'communityPost.commented': {
107
119
  const col = getCol('additionalCommunityPostCommented');
@@ -291,6 +303,7 @@ class LearningSuiteTrigger {
291
303
  };
292
304
  this.methods = {
293
305
  loadOptions: {
306
+ ...loAi,
294
307
  ...loBundle,
295
308
  ...loCommunity,
296
309
  ...loCourse,
@@ -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',
@@ -94,6 +94,33 @@ exports.instantProperties = [
94
94
  },
95
95
  ],
96
96
  },
97
+ // Agent Action Executed
98
+ {
99
+ displayName: 'Agent Action Executed Options',
100
+ name: 'additionalAgentActionExecuted',
101
+ type: 'collection',
102
+ default: {},
103
+ placeholder: 'Add option',
104
+ displayOptions: { show: { event: ['agentAction.executed'] } },
105
+ options: [
106
+ {
107
+ displayName: 'Tool Key Name or ID',
108
+ name: 'toolKey',
109
+ type: 'options',
110
+ default: '',
111
+ description: 'Optional: Only trigger for a specific agent action. Leave empty to trigger for all actions. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
112
+ typeOptions: { loadOptionsMethod: 'ai_getAgentActions' },
113
+ },
114
+ {
115
+ displayName: 'Agent Name or ID',
116
+ name: 'agentId',
117
+ type: 'options',
118
+ default: '',
119
+ description: 'Optional: Only trigger for actions executed by a specific AI agent. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
120
+ typeOptions: { loadOptionsMethod: 'ai_getAiAgents' },
121
+ },
122
+ ],
123
+ },
97
124
  // New Login
98
125
  {
99
126
  displayName: 'Login Options',
@@ -129,6 +129,39 @@ exports.webhookProperties = [
129
129
  ],
130
130
  },
131
131
  // ====== Optionen pro Event (identisch zu instantProperties) ======
132
+ // Agent Action Executed
133
+ {
134
+ displayName: 'Agent Action Executed Options',
135
+ name: 'additionalAgentActionExecuted',
136
+ type: 'collection',
137
+ default: {},
138
+ placeholder: 'Add option',
139
+ displayOptions: {
140
+ show: {
141
+ resource: ['webhook'],
142
+ operation: ['createSubscription', 'updateSubscription'],
143
+ eventType: ['agentAction.executed'],
144
+ },
145
+ },
146
+ options: [
147
+ {
148
+ displayName: 'Tool Key Name or ID',
149
+ name: 'toolKey',
150
+ type: 'options',
151
+ default: '',
152
+ description: 'Optional: Only trigger for a specific agent action. Leave empty to trigger for all actions. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
153
+ typeOptions: { loadOptionsMethod: 'ai_getAgentActions' },
154
+ },
155
+ {
156
+ displayName: 'Agent Name or ID',
157
+ name: 'agentId',
158
+ type: 'options',
159
+ default: '',
160
+ description: 'Optional: Only trigger for actions executed by a specific AI agent. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
161
+ typeOptions: { loadOptionsMethod: 'ai_getAiAgents' },
162
+ },
163
+ ],
164
+ },
132
165
  // Login Options
133
166
  {
134
167
  displayName: 'Login Options',
@@ -1,5 +1,6 @@
1
1
  import type { ExecuteHandler } from '../exec.types';
2
2
  export declare const aiHandlers: {
3
+ agentChat: ExecuteHandler;
3
4
  getAgentActions: ExecuteHandler;
4
5
  getAiAgents: ExecuteHandler;
5
6
  ragChat: ExecuteHandler;
@@ -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,
@@ -34,6 +34,17 @@ function buildDesiredFilter(ctx, i, eventType) {
34
34
  var _a;
35
35
  const filter = {};
36
36
  switch (eventType) {
37
+ // ---------------- Agent Action
38
+ case 'agentAction.executed': {
39
+ const col = getCol(ctx, i, 'additionalAgentActionExecuted');
40
+ if (col === null || col === void 0 ? void 0 : col.toolKey) {
41
+ filter.toolKey = String(col.toolKey);
42
+ }
43
+ if (col === null || col === void 0 ? void 0 : col.agentId) {
44
+ filter.agentId = String(col.agentId);
45
+ }
46
+ break;
47
+ }
37
48
  // ---------------- Community
38
49
  case 'communityPost.commented': {
39
50
  const col = getCol(ctx, i, 'additionalCommunityPostCommented');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rjsebening/n8n-nodes-learningsuite",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "n8n node for LearningSuite API",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",