n8n-nodes-bgos 1.4.0 → 1.4.2

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.
@@ -3,15 +3,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BGOSAction = void 0;
4
4
  const n8n_workflow_1 = require("n8n-workflow");
5
5
  const eventHandler_1 = require("./handler/eventHandler");
6
+ // Read npm package version at compile/load time so the user-facing description
7
+ // reflects what's actually installed in n8n. Different from the n8n typeVersion
8
+ // (which signals SCHEMA evolution and is bumped per Telegram-style array form
9
+ // below). Both are exposed so users see real info either way.
10
+ const package_json_1 = require("../../package.json");
6
11
  class BGOSAction {
7
12
  description = {
8
13
  displayName: 'BGOS Action',
9
14
  name: 'bgosAction',
10
15
  icon: 'file:bgos-icon.svg',
11
16
  group: ['transform'],
12
- version: 1,
17
+ // n8n typeVersion. ARRAY form: each new entry signals an additive schema
18
+ // change; old workflows pinned at the older version keep working. Bump the
19
+ // last element on each meaningful UI/parameter addition.
20
+ // 1 — original
21
+ // 1.1 — v1.4.0 added: usableAsTool, editMessage, pinMessage, getChat,
22
+ // sendAndWaitForReply
23
+ // 1.2 — v1.4.1 reorganised sendAndWaitForReply additional fields
24
+ // (Sender / File ID / User ID moved into collection)
25
+ version: [1, 1.1, 1.2],
13
26
  subtitle: '={{$parameter["resource"] + ": " + $parameter["operation"]}}',
14
- description: 'Interact with the BGOS chat platform. Send/edit/pin/delete messages, ask the user a question, send a message and wait for the reply, fetch chat metadata, manage assistants and files. Usable as an AI agent tool.',
27
+ description: `Interact with the BGOS chat platform. Send/edit/pin/delete messages, ask the user a question, send a message and wait for the reply, fetch chat metadata, manage assistants and files. Usable as an AI agent tool. (n8n-nodes-bgos v${package_json_1.version})`,
15
28
  defaults: { name: 'BGOS Action' },
16
29
  usableAsTool: true,
17
30
  inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
@@ -352,15 +365,6 @@ class BGOSAction {
352
365
  description: 'Message text to post. The next reply in the chat will be returned as the tool result.',
353
366
  displayOptions: { show: { resource: ['message'], operation: ['sendAndWaitForReply'] } },
354
367
  },
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
368
  {
365
369
  displayName: 'Additional Fields',
366
370
  name: 'replyAdditionalFields',
@@ -369,6 +373,33 @@ class BGOSAction {
369
373
  default: {},
370
374
  displayOptions: { show: { resource: ['message'], operation: ['sendAndWaitForReply'] } },
371
375
  options: [
376
+ {
377
+ displayName: 'Sender',
378
+ name: 'sender',
379
+ type: 'options',
380
+ default: 'assistant',
381
+ options: [
382
+ { name: 'Assistant', value: 'assistant' },
383
+ { name: 'User', value: 'user' },
384
+ ],
385
+ description: 'Who is sending the outgoing message. Defaults to Assistant.',
386
+ },
387
+ {
388
+ displayName: 'File ID',
389
+ name: 'fileId',
390
+ type: 'string',
391
+ default: '',
392
+ placeholder: 'abc-123',
393
+ 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.',
394
+ },
395
+ {
396
+ displayName: 'User ID',
397
+ name: 'userId',
398
+ type: 'string',
399
+ default: '',
400
+ placeholder: 'user_xxx',
401
+ 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.',
402
+ },
372
403
  {
373
404
  displayName: 'Timeout (Seconds)',
374
405
  name: 'replyTimeoutSeconds',
@@ -746,8 +777,10 @@ class BGOSAction {
746
777
  nodeParams.assistantId = String(this.getNodeParameter('assistantId', i, '') ?? '');
747
778
  nodeParams.chatId = String(this.getNodeParameter('chatId', i, '') ?? '');
748
779
  nodeParams.messageText = String(this.getNodeParameter('messageText', i, '') ?? '');
749
- nodeParams.userId = String(this.getNodeParameter('userId', i, '') ?? '');
750
780
  const replyAdditional = this.getNodeParameter('replyAdditionalFields', i, {});
781
+ nodeParams.userId = String(replyAdditional.userId ?? '');
782
+ nodeParams.sender = String(replyAdditional.sender ?? 'assistant');
783
+ nodeParams.fileId = String(replyAdditional.fileId ?? '');
751
784
  nodeParams.replyTimeoutSeconds = Number(replyAdditional.replyTimeoutSeconds ?? 600);
752
785
  nodeParams.replyPollIntervalMs = Number(replyAdditional.replyPollIntervalMs ?? 2000);
753
786
  }
@@ -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 ?? eventData.user_id ?? eventData.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, and Text are required for Send and Wait for Reply.');
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: 'assistant',
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
@@ -7,6 +7,7 @@ const chat_1 = require("./resources/chat");
7
7
  const assistant_1 = require("./resources/assistant");
8
8
  const user_1 = require("./resources/user");
9
9
  const scheduledTask_1 = require("./resources/scheduledTask");
10
+ const package_json_1 = require("../../package.json");
10
11
  /**
11
12
  * Extracts the actual backend error message from a failed HTTP response.
12
13
  * NestJS ValidationPipe returns { statusCode, message: string | string[], error }.
@@ -56,7 +57,7 @@ class Bgos {
56
57
  group: ['transform'],
57
58
  version: 1,
58
59
  subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
59
- description: 'Interact with the BGOS AI assistant platform',
60
+ description: `Interact with the BGOS AI assistant platform. (n8n-nodes-bgos v${package_json_1.version})`,
60
61
  defaults: {
61
62
  name: 'BGOS',
62
63
  },
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BgosTrigger = void 0;
4
4
  const n8n_workflow_1 = require("n8n-workflow");
5
+ const package_json_1 = require("../../package.json");
5
6
  const RATE_WINDOW_MS = 1000;
6
7
  const RATE_MAX_EVENTS = 10;
7
8
  const GLOBAL_KEY = '__bgosRateLimiter';
@@ -30,7 +31,7 @@ class BgosTrigger {
30
31
  group: ['trigger'],
31
32
  version: 1,
32
33
  subtitle: '={{$parameter["updates"]}}',
33
- description: 'Starts the workflow on a BGOS Assistant update',
34
+ description: `Starts the workflow on a BGOS Assistant update. (n8n-nodes-bgos v${package_json_1.version})`,
34
35
  defaults: { name: 'BGOS Trigger' },
35
36
  inputs: [],
36
37
  outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "n8n-nodes-bgos",
3
+ "version": "1.4.2",
4
+ "description": "n8n community nodes for BGOS (Brand Growth OS) - AI assistant chat platform",
5
+ "keywords": [
6
+ "n8n-community-node-package",
7
+ "n8n",
8
+ "bgos",
9
+ "chat",
10
+ "assistant",
11
+ "ai"
12
+ ],
13
+ "license": "MIT",
14
+ "homepage": "https://github.com/BrandGrowthOS/bgos-n8n-nodes",
15
+ "author": {
16
+ "email": "alinur.dzjeenbekov@plus8soft.com",
17
+ "name": "BGOS Team",
18
+ "url": "https://github.com/BrandGrowthOS"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/BrandGrowthOS/bgos-n8n-nodes.git"
23
+ },
24
+ "engines": {
25
+ "node": ">=18.10",
26
+ "pnpm": ">=9.1"
27
+ },
28
+ "packageManager": "pnpm@9.1.4",
29
+ "main": "dist/nodes/Bgos/Bgos.node.js",
30
+ "scripts": {
31
+ "preinstall": "npx only-allow pnpm",
32
+ "build": "tsc && gulp build:icons",
33
+ "dev": "tsc --watch",
34
+ "format": "prettier nodes credentials --write",
35
+ "lint": "ESLINT_USE_FLAT_CONFIG=true eslint -c eslint.config.cjs .",
36
+ "lintfix": "ESLINT_USE_FLAT_CONFIG=true eslint -c eslint.config.cjs . --fix",
37
+ "prepack": "pnpm build",
38
+ "prepublishOnly": "pnpm build"
39
+ },
40
+ "files": [
41
+ "dist",
42
+ "README.md",
43
+ "LICENSE.md"
44
+ ],
45
+ "n8n": {
46
+ "n8nNodesApiVersion": 1,
47
+ "credentials": [
48
+ "dist/credentials/BgosApi.credentials.js"
49
+ ],
50
+ "nodes": [
51
+ "dist/nodes/BgosTrigger/BgosTrigger.node.js",
52
+ "dist/nodes/Bgos/Bgos.node.js",
53
+ "dist/nodes/BGOSAction/BGOSAction.node.js"
54
+ ]
55
+ },
56
+ "dependencies": {},
57
+ "devDependencies": {
58
+ "@types/node": "^20.0.0",
59
+ "@typescript-eslint/parser": "~7.18.0",
60
+ "eslint": "~8.56.0",
61
+ "eslint-plugin-n8n-nodes-base": "~1.16.2",
62
+ "gulp": "~5.0.0",
63
+ "n8n-workflow": "*",
64
+ "prettier": "~3.3.3",
65
+ "typescript": "~5.6.3"
66
+ },
67
+ "peerDependencies": {
68
+ "n8n-workflow": "*"
69
+ }
70
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-bgos",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "n8n community nodes for BGOS (Brand Growth OS) - AI assistant chat platform",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",