n8n-nodes-bgos 1.4.0 → 1.4.1
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.
|
@@ -352,15 +352,6 @@ class BGOSAction {
|
|
|
352
352
|
description: 'Message text to post. The next reply in the chat will be returned as the tool result.',
|
|
353
353
|
displayOptions: { show: { resource: ['message'], operation: ['sendAndWaitForReply'] } },
|
|
354
354
|
},
|
|
355
|
-
{
|
|
356
|
-
displayName: 'User ID',
|
|
357
|
-
name: 'userId',
|
|
358
|
-
type: 'string',
|
|
359
|
-
default: '',
|
|
360
|
-
placeholder: 'user_xxx',
|
|
361
|
-
description: 'User ID who owns the chat — needed to poll its messages. Falls back to user_id / userId from input data.',
|
|
362
|
-
displayOptions: { show: { resource: ['message'], operation: ['sendAndWaitForReply'] } },
|
|
363
|
-
},
|
|
364
355
|
{
|
|
365
356
|
displayName: 'Additional Fields',
|
|
366
357
|
name: 'replyAdditionalFields',
|
|
@@ -369,6 +360,33 @@ class BGOSAction {
|
|
|
369
360
|
default: {},
|
|
370
361
|
displayOptions: { show: { resource: ['message'], operation: ['sendAndWaitForReply'] } },
|
|
371
362
|
options: [
|
|
363
|
+
{
|
|
364
|
+
displayName: 'Sender',
|
|
365
|
+
name: 'sender',
|
|
366
|
+
type: 'options',
|
|
367
|
+
default: 'assistant',
|
|
368
|
+
options: [
|
|
369
|
+
{ name: 'Assistant', value: 'assistant' },
|
|
370
|
+
{ name: 'User', value: 'user' },
|
|
371
|
+
],
|
|
372
|
+
description: 'Who is sending the outgoing message. Defaults to Assistant.',
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
displayName: 'File ID',
|
|
376
|
+
name: 'fileId',
|
|
377
|
+
type: 'string',
|
|
378
|
+
default: '',
|
|
379
|
+
placeholder: 'abc-123',
|
|
380
|
+
description: 'ID of a previously uploaded file to attach to the outgoing message. Use the "Upload a File" operation first to get the file ID.',
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
displayName: 'User ID',
|
|
384
|
+
name: 'userId',
|
|
385
|
+
type: 'string',
|
|
386
|
+
default: '',
|
|
387
|
+
placeholder: 'user_xxx',
|
|
388
|
+
description: 'User ID that owns the chat (required by the poll endpoint). Auto-falls-back to user_id / userId on the input data — typically passed in by an upstream BGOS Trigger — so most workflows can leave this empty.',
|
|
389
|
+
},
|
|
372
390
|
{
|
|
373
391
|
displayName: 'Timeout (Seconds)',
|
|
374
392
|
name: 'replyTimeoutSeconds',
|
|
@@ -746,8 +764,10 @@ class BGOSAction {
|
|
|
746
764
|
nodeParams.assistantId = String(this.getNodeParameter('assistantId', i, '') ?? '');
|
|
747
765
|
nodeParams.chatId = String(this.getNodeParameter('chatId', i, '') ?? '');
|
|
748
766
|
nodeParams.messageText = String(this.getNodeParameter('messageText', i, '') ?? '');
|
|
749
|
-
nodeParams.userId = String(this.getNodeParameter('userId', i, '') ?? '');
|
|
750
767
|
const replyAdditional = this.getNodeParameter('replyAdditionalFields', i, {});
|
|
768
|
+
nodeParams.userId = String(replyAdditional.userId ?? '');
|
|
769
|
+
nodeParams.sender = String(replyAdditional.sender ?? 'assistant');
|
|
770
|
+
nodeParams.fileId = String(replyAdditional.fileId ?? '');
|
|
751
771
|
nodeParams.replyTimeoutSeconds = Number(replyAdditional.replyTimeoutSeconds ?? 600);
|
|
752
772
|
nodeParams.replyPollIntervalMs = Number(replyAdditional.replyPollIntervalMs ?? 2000);
|
|
753
773
|
}
|
|
@@ -106,17 +106,23 @@ async function handleEventByType(eventType, eventData, nodeParams) {
|
|
|
106
106
|
const apiOptions = getApiOptions(nodeParams);
|
|
107
107
|
const assistantId = nodeParams.assistantId || (eventData.assistantId ?? eventData.assistant_id ?? assistant?.id);
|
|
108
108
|
const chatId = nodeParams.chatId || (eventData.chatId ?? eventData.chat_id ?? chat?.id ?? message?.chatId);
|
|
109
|
-
const userId = (nodeParams.userId
|
|
109
|
+
const userId = ((nodeParams.userId && String(nodeParams.userId).trim()) || eventData.user_id || eventData.userId);
|
|
110
110
|
const text = (nodeParams.messageText ?? '').trim() || (eventData.text ?? message?.text ?? '');
|
|
111
111
|
if (!assistantId || !chatId || !userId || !text) {
|
|
112
|
-
throw new Error('Assistant ID, Chat ID, User ID
|
|
112
|
+
throw new Error('Assistant ID, Chat ID, Text, and a User ID (from input data or the Additional Fields override) are required for Send and Wait for Reply. Make sure the upstream BGOS Trigger output includes user_id.');
|
|
113
113
|
}
|
|
114
|
+
// Optional file attachment
|
|
115
|
+
const fileIdParam = nodeParams.fileId?.trim();
|
|
116
|
+
const files = fileIdParam ? [{ id: fileIdParam }] : [];
|
|
117
|
+
const sender = nodeParams.sender || 'assistant';
|
|
114
118
|
// Step 1: post the outgoing message and capture its id
|
|
115
119
|
const sendResult = (await techWebhook_1.sendMessageToBackend.call(this, apiOptions, {
|
|
116
120
|
assistantId: assistantId,
|
|
117
121
|
chatId: chatId,
|
|
118
|
-
sender
|
|
122
|
+
sender,
|
|
119
123
|
text,
|
|
124
|
+
files,
|
|
125
|
+
isMixedAttachments: files.length > 0 ? true : null,
|
|
120
126
|
}));
|
|
121
127
|
const sentMessageId = Number(sendResult?.id
|
|
122
128
|
?? sendResult?.message?.id
|