@rjsebening/n8n-nodes-learningsuite 1.3.6 → 1.4.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/README.md CHANGED
@@ -88,9 +88,9 @@ This community node uses the public LearningSuite API and is not affiliated with
88
88
 
89
89
  - Send push notification
90
90
 
91
- ### 🤖 **AI** (3 operations)
91
+ ### 🤖 **AI** (4 operations)
92
92
 
93
- - Get agent actions, get AI agents, RAG Chat
93
+ - Agent chat, concierge chat, get agent actions, get AI agents
94
94
 
95
95
  ### 🛡️ **Role** (1 operation)
96
96
 
@@ -7,7 +7,7 @@ exports.aiProperties = [
7
7
  name: 'operation',
8
8
  type: 'options',
9
9
  noDataExpression: true,
10
- default: 'ragChat',
10
+ default: 'agentChat',
11
11
  displayOptions: { show: { resource: ['ai'] } },
12
12
  options: [
13
13
  {
@@ -16,6 +16,12 @@ exports.aiProperties = [
16
16
  description: 'Send a message to an AI agent and get the response',
17
17
  action: 'Send message to AI agent',
18
18
  },
19
+ {
20
+ name: 'Concierge Chat',
21
+ value: 'conciergeChat',
22
+ description: 'Send a message to the global AI Concierge agent and get the response',
23
+ action: 'Send message to AI concierge',
24
+ },
19
25
  {
20
26
  name: 'Get Agent Actions',
21
27
  value: 'getAgentActions',
@@ -28,12 +34,6 @@ exports.aiProperties = [
28
34
  description: 'List all enabled AI agents',
29
35
  action: 'List AI agents',
30
36
  },
31
- {
32
- name: 'RAG Chat',
33
- value: 'ragChat',
34
- description: 'Ask a question using the AI RAG chat endpoint',
35
- action: 'Ask AI question',
36
- },
37
37
  ],
38
38
  },
39
39
  {
@@ -54,7 +54,7 @@ exports.aiProperties = [
54
54
  required: true,
55
55
  default: '',
56
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'] } },
57
+ displayOptions: { show: { resource: ['ai'], operation: ['agentChat', 'conciergeChat'] } },
58
58
  },
59
59
  {
60
60
  displayName: 'Message',
@@ -62,7 +62,7 @@ exports.aiProperties = [
62
62
  type: 'string',
63
63
  default: '',
64
64
  description: 'The message you want to send to the AI agent',
65
- displayOptions: { show: { resource: ['ai'], operation: ['agentChat'] } },
65
+ displayOptions: { show: { resource: ['ai'], operation: ['agentChat', 'conciergeChat'] } },
66
66
  },
67
67
  {
68
68
  displayName: 'Chat ID',
@@ -70,7 +70,7 @@ exports.aiProperties = [
70
70
  type: 'string',
71
71
  default: '',
72
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'] } },
73
+ displayOptions: { show: { resource: ['ai'], operation: ['agentChat', 'conciergeChat'] } },
74
74
  },
75
75
  {
76
76
  displayName: 'Include Chat History',
@@ -78,7 +78,7 @@ exports.aiProperties = [
78
78
  type: 'boolean',
79
79
  default: false,
80
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'] } },
81
+ displayOptions: { show: { resource: ['ai'], operation: ['agentChat', 'conciergeChat'] } },
82
82
  },
83
83
  {
84
84
  displayName: 'End Chat',
@@ -86,7 +86,7 @@ exports.aiProperties = [
86
86
  type: 'boolean',
87
87
  default: false,
88
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'] } },
89
+ displayOptions: { show: { resource: ['ai'], operation: ['agentChat', 'conciergeChat'] } },
90
90
  },
91
91
  {
92
92
  displayName: 'Metadata',
@@ -94,134 +94,14 @@ exports.aiProperties = [
94
94
  type: 'json',
95
95
  default: '{}',
96
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'] } },
97
+ displayOptions: { show: { resource: ['ai'], operation: ['agentChat', 'conciergeChat'] } },
98
98
  },
99
99
  {
100
100
  displayName: 'Profile Context',
101
101
  name: 'profileContext',
102
102
  type: 'json',
103
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
- },
107
- {
108
- displayName: 'Question',
109
- name: 'question',
110
- type: 'string',
111
- required: true,
112
- default: '',
113
- description: 'The question to ask the AI',
114
- displayOptions: { show: { resource: ['ai'], operation: ['ragChat'] } },
115
- },
116
- {
117
- displayName: 'User Name or ID',
118
- name: 'userId',
119
- type: 'options',
120
- typeOptions: { loadOptionsMethod: 'member_getMembers' },
121
- default: '',
122
- description: 'The ID of the user making the request. Used to personalize and scope the AI response. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
123
- displayOptions: { show: { resource: ['ai'], operation: ['ragChat'] } },
124
- },
125
- {
126
- displayName: 'Conversation ID',
127
- name: 'conversationId',
128
- type: 'string',
129
- default: '',
130
- description: 'If set, the conversation history with this ID will be taken into account',
131
- displayOptions: { show: { resource: ['ai'], operation: ['ragChat'] } },
132
- },
133
- {
134
- displayName: 'Answer Length',
135
- name: 'answerLength',
136
- type: 'options',
137
- default: 'standard',
138
- description: 'The desired length of the AI’s answer',
139
- displayOptions: { show: { resource: ['ai'], operation: ['ragChat'] } },
140
- options: [
141
- {
142
- name: 'Concise',
143
- value: 'concise',
144
- description: 'A short and to-the-point answer',
145
- },
146
- {
147
- name: 'Standard',
148
- value: 'standard',
149
- description: 'A balanced answer with sufficient detail',
150
- },
151
- {
152
- name: 'Detailed',
153
- value: 'detailed',
154
- description: 'A comprehensive and detailed answer',
155
- },
156
- ],
157
- },
158
- {
159
- displayName: 'Tone',
160
- name: 'tone',
161
- type: 'options',
162
- default: 'neutral',
163
- description: 'The desired tone of the AI’s answer',
164
- displayOptions: { show: { resource: ['ai'], operation: ['ragChat'] } },
165
- options: [
166
- {
167
- name: 'Friendly',
168
- value: 'friendly',
169
- description: 'A warm and approachable tone',
170
- },
171
- {
172
- name: 'Neutral',
173
- value: 'neutral',
174
- description: 'A neutral and factual tone',
175
- },
176
- {
177
- name: 'Professional',
178
- value: 'professional',
179
- description: 'A formal and professional tone',
180
- },
181
- ],
182
- },
183
- {
184
- displayName: 'Format',
185
- name: 'format',
186
- type: 'options',
187
- default: 'markdown',
188
- description: 'The desired output format of the AI’s answer',
189
- displayOptions: { show: { resource: ['ai'], operation: ['ragChat'] } },
190
- options: [
191
- {
192
- name: 'Markdown',
193
- value: 'markdown',
194
- description: 'Formatted output using Markdown',
195
- },
196
- {
197
- name: 'Plain Text',
198
- value: 'plaintext',
199
- description: 'Unformatted plain text output',
200
- },
201
- ],
202
- },
203
- {
204
- displayName: 'Add Citations',
205
- name: 'addCitations',
206
- type: 'boolean',
207
- default: false,
208
- description: 'Whether the AI will add citations to its answer',
209
- displayOptions: { show: { resource: ['ai'], operation: ['ragChat'] } },
210
- },
211
- {
212
- displayName: 'Unlock Content Drip',
213
- name: 'unlockContentDrip',
214
- type: 'boolean',
215
- default: false,
216
- description: 'Whether the AI will have access to content that is normally restricted by content drip settings',
217
- displayOptions: { show: { resource: ['ai'], operation: ['ragChat'] } },
218
- },
219
- {
220
- displayName: 'System Prompt Addition',
221
- name: 'systemPromptAddition',
222
- type: 'string',
223
- default: '',
224
- description: 'Additional system prompt instructions to guide the AI’s behavior',
225
- displayOptions: { show: { resource: ['ai'], operation: ['ragChat'] } },
104
+ description: 'Optional profile context to use when interacting with custom field (forms). Only used if the agent config supports it. Leave as {} to omit. Expected structure: { "selectedProfileIdByCard": { "cardId": "profileId or null" } } - keys are custom field card IDs, values are profile IDs or null for the default profile.',
105
+ displayOptions: { show: { resource: ['ai'], operation: ['agentChat', 'conciergeChat'] } },
226
106
  },
227
107
  ];
@@ -1,7 +1,7 @@
1
1
  import type { ExecuteHandler } from '../exec.types';
2
2
  export declare const aiHandlers: {
3
3
  agentChat: ExecuteHandler;
4
+ conciergeChat: ExecuteHandler;
4
5
  getAgentActions: ExecuteHandler;
5
6
  getAiAgents: ExecuteHandler;
6
- ragChat: ExecuteHandler;
7
7
  };
@@ -13,24 +13,49 @@ function parseJsonObjectParam(ctx, i, name) {
13
13
  const raw = ctx.getNodeParameter(name, i, '');
14
14
  if (raw === undefined || raw === null || raw === '')
15
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)}`);
16
+ let parsed = raw;
17
+ if (typeof raw !== 'object') {
18
+ try {
19
+ parsed = JSON.parse(raw);
20
+ }
21
+ catch (err) {
22
+ throw new n8n_workflow_1.NodeOperationError(ctx.getNode(), `Invalid JSON in "${name}": ${String(err)}`);
23
+ }
24
24
  }
25
25
  if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
26
26
  throw new n8n_workflow_1.NodeOperationError(ctx.getNode(), `"${name}" must be a JSON object`);
27
27
  }
28
+ // The "{}" placeholder means "not set" - sending it would fail the API's schema validation
29
+ if (Object.keys(parsed).length === 0)
30
+ return undefined;
28
31
  return parsed;
29
32
  }
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');
33
+ const PROFILE_CONTEXT_EXAMPLE = '{ "selectedProfileIdByCard": { "<cardId>": "<profileId or null>" } }';
34
+ /** Reads and validates the optional profile context, which the API only accepts fully formed. */
35
+ function buildProfileContext(ctx, i) {
36
+ const profileContext = parseJsonObjectParam(ctx, i, 'profileContext');
37
+ if (!profileContext)
38
+ return undefined;
39
+ const selection = profileContext.selectedProfileIdByCard;
40
+ if (!selection || typeof selection !== 'object' || Array.isArray(selection)) {
41
+ throw new n8n_workflow_1.NodeOperationError(ctx.getNode(), '"Profile Context" must contain a "selectedProfileIdByCard" object', {
42
+ itemIndex: i,
43
+ description: `Expected structure: ${PROFILE_CONTEXT_EXAMPLE}. Keys are custom field card IDs, values are profile IDs (or null for the default profile).`,
44
+ });
45
+ }
46
+ const invalid = Object.entries(selection)
47
+ .filter(([, v]) => v !== null && typeof v !== 'string')
48
+ .map(([k]) => k);
49
+ if (invalid.length) {
50
+ throw new n8n_workflow_1.NodeOperationError(ctx.getNode(), `"Profile Context" contains invalid profile IDs for the following cards: ${invalid.join(', ')}`, {
51
+ itemIndex: i,
52
+ description: `Each value must be a profile ID string or null (= default profile). Expected structure: ${PROFILE_CONTEXT_EXAMPLE}.`,
53
+ });
54
+ }
55
+ return profileContext;
56
+ }
57
+ /** Builds the chat request body shared by the agent and concierge chat endpoints. */
58
+ function buildChatBody(ctx, i) {
34
59
  const body = {
35
60
  userId: ctx.getNodeParameter('userId', i),
36
61
  chatId: ctx.getNodeParameter('chatId', i, undefined),
@@ -38,30 +63,25 @@ const agentChat = async (ctx, i) => {
38
63
  includeChatHistory: ctx.getNodeParameter('includeChatHistory', i, false),
39
64
  endChat: ctx.getNodeParameter('endChat', i, false),
40
65
  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
- };
46
- const ragChat = async (ctx, i) => {
47
- const body = {
48
- question: ctx.getNodeParameter('question', i),
49
- userId: ctx.getNodeParameter('userId', i, undefined),
50
- conversationId: ctx.getNodeParameter('conversationId', i, undefined),
51
- addCitations: ctx.getNodeParameter('addCitations', i, false),
52
- systemPromptAddition: ctx.getNodeParameter('systemPromptAddition', i, undefined),
53
- answerLength: ctx.getNodeParameter('answerLength', i, 'standard'),
54
- tone: ctx.getNodeParameter('tone', i, 'neutral'),
55
- format: ctx.getNodeParameter('format', i, 'markdown'),
56
- unlockContentDrip: ctx.getNodeParameter('unlockContentDrip', i, false),
66
+ profileContext: buildProfileContext(ctx, i),
57
67
  };
58
68
  // Remove keys with undefined or empty string values so optional params are not sent as empty
59
- const cleanBody = Object.fromEntries(Object.entries(body).filter(([, v]) => v !== undefined && v !== ''));
60
- return await shared_1.lsRequest.call(ctx, 'POST', '/ai/rag-chat', { body: cleanBody });
69
+ return Object.fromEntries(Object.entries(body).filter(([, v]) => v !== undefined && v !== ''));
70
+ }
71
+ const agentChat = async (ctx, i) => {
72
+ const agentId = ctx.getNodeParameter('agentId', i);
73
+ if (!agentId)
74
+ throw new n8n_workflow_1.NodeOperationError(ctx.getNode(), 'AI Agent is required');
75
+ return await shared_1.lsRequest.call(ctx, 'POST', `/ai-agents/${encodeURIComponent(agentId)}/chat`, {
76
+ body: buildChatBody(ctx, i),
77
+ });
78
+ };
79
+ const conciergeChat = async (ctx, i) => {
80
+ return await shared_1.lsRequest.call(ctx, 'POST', '/ai-agents/concierge/chat', { body: buildChatBody(ctx, i) });
61
81
  };
62
82
  exports.aiHandlers = {
63
83
  agentChat,
84
+ conciergeChat,
64
85
  getAgentActions,
65
86
  getAiAgents,
66
- ragChat,
67
87
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rjsebening/n8n-nodes-learningsuite",
3
- "version": "1.3.6",
3
+ "version": "1.4.0",
4
4
  "description": "n8n node for LearningSuite API",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",