n8n-nodes-bgos 1.0.7 → 1.0.8
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/dist/credentials/BgosApi.credentials.js +9 -0
- package/dist/nodes/BGOSAction/BGOSAction.node.js +0 -2
- package/dist/nodes/BGOSAction/handler/eventHandler.js +1 -5
- package/dist/nodes/Bgos/resources/assistant/index.js +1 -1
- package/dist/nodes/Bgos/resources/chat/index.js +1 -1
- package/dist/nodes/Bgos/resources/message/index.js +50 -10
- package/dist/nodes/BgosTrigger/BgosTrigger.node.js +57 -0
- package/package.json +1 -1
|
@@ -24,6 +24,15 @@ class BgosApi {
|
|
|
24
24
|
required: true,
|
|
25
25
|
description: 'Your BGOS API key. Find it by calling POST /api/v1/users — the apiKey field in the response.',
|
|
26
26
|
},
|
|
27
|
+
{
|
|
28
|
+
displayName: 'Webhook Secret',
|
|
29
|
+
name: 'webhookSecret',
|
|
30
|
+
type: 'string',
|
|
31
|
+
typeOptions: { password: true },
|
|
32
|
+
default: '',
|
|
33
|
+
required: false,
|
|
34
|
+
description: 'Optional HMAC-SHA256 secret for validating inbound webhook signatures (X-BGOS-Signature header).',
|
|
35
|
+
},
|
|
27
36
|
];
|
|
28
37
|
authenticate = {
|
|
29
38
|
type: 'generic',
|
|
@@ -129,8 +129,6 @@ class BGOSAction {
|
|
|
129
129
|
const eventData = items[i].json;
|
|
130
130
|
const rawEventType = eventData.event_type;
|
|
131
131
|
const eventType = typeof rawEventType === 'string' ? rawEventType : String(rawEventType ?? '');
|
|
132
|
-
if (!eventType)
|
|
133
|
-
throw new Error('Event type (event_type) is required in input data');
|
|
134
132
|
const creds = (await this.getCredentials('bgosApi'));
|
|
135
133
|
const apiBaseUrl = creds?.baseUrl ?? creds?.apiUrl ?? '';
|
|
136
134
|
const nodeParams = {
|
|
@@ -90,8 +90,6 @@ async function handleEventByType(eventType, eventData, nodeParams) {
|
|
|
90
90
|
const userId = (nodeParams.userId ?? eventData.user_id ?? eventData.userId);
|
|
91
91
|
if (!userId)
|
|
92
92
|
throw new Error('User ID is required.');
|
|
93
|
-
if (eventType !== EventTypes_1.EventType.NEW_ASSISTANT)
|
|
94
|
-
throw new Error(`Operation 'createAssistant' can only be used with NEW_ASSISTANT event. Current event type: ${eventType}`);
|
|
95
93
|
if (!assistant)
|
|
96
94
|
throw new Error('Assistant data is required for createAssistant operation.');
|
|
97
95
|
const { id: _id, userId: _u, ...assistantData } = assistant;
|
|
@@ -122,10 +120,8 @@ async function handleEventByType(eventType, eventData, nodeParams) {
|
|
|
122
120
|
const userId = (nodeParams.userId ?? eventData.user_id ?? eventData.userId);
|
|
123
121
|
if (!userId)
|
|
124
122
|
throw new Error('User ID is required.');
|
|
125
|
-
if (eventType !== EventTypes_1.EventType.CHAT_RENAMED)
|
|
126
|
-
throw new Error(`Operation 'renameChat' can only be used with CHAT_RENAMED event. Current event type: ${eventType}`);
|
|
127
123
|
const chatId = eventData.chat_id ?? chat?.id;
|
|
128
|
-
const newName = eventData.new_name ?? chat?.title;
|
|
124
|
+
const newName = eventData.new_name ?? eventData.title ?? chat?.title;
|
|
129
125
|
if (!chatId || !newName)
|
|
130
126
|
throw new Error('Chat ID and new name are required for renameChat operation.');
|
|
131
127
|
return await techWebhook_1.renameChat.call(this, getApiOptions(nodeParams), userId, String(chatId), String(newName));
|
|
@@ -76,11 +76,11 @@ exports.messageOperations = [
|
|
|
76
76
|
{
|
|
77
77
|
name: 'Button Callback',
|
|
78
78
|
value: 'buttonCallback',
|
|
79
|
-
description: '
|
|
79
|
+
description: 'Report success/error after processing a button click',
|
|
80
80
|
routing: {
|
|
81
81
|
request: {
|
|
82
82
|
method: 'POST',
|
|
83
|
-
url: '
|
|
83
|
+
url: '/api/v1/messages/callback-result',
|
|
84
84
|
},
|
|
85
85
|
},
|
|
86
86
|
action: 'Trigger button callback',
|
|
@@ -114,7 +114,7 @@ exports.messageOperations = [
|
|
|
114
114
|
},
|
|
115
115
|
];
|
|
116
116
|
exports.messageFields = [
|
|
117
|
-
// --- messageId (shared by editMessage, deleteMessage
|
|
117
|
+
// --- messageId (shared by editMessage, deleteMessage) ---
|
|
118
118
|
{
|
|
119
119
|
displayName: 'Message ID',
|
|
120
120
|
name: 'messageId',
|
|
@@ -124,7 +124,7 @@ exports.messageFields = [
|
|
|
124
124
|
displayOptions: {
|
|
125
125
|
show: {
|
|
126
126
|
resource: ['message'],
|
|
127
|
-
operation: ['editMessage', 'deleteMessage'
|
|
127
|
+
operation: ['editMessage', 'deleteMessage'],
|
|
128
128
|
},
|
|
129
129
|
},
|
|
130
130
|
description: 'The ID of the message',
|
|
@@ -431,6 +431,46 @@ exports.messageFields = [
|
|
|
431
431
|
description: 'The new message text',
|
|
432
432
|
},
|
|
433
433
|
// --- buttonCallback fields ---
|
|
434
|
+
{
|
|
435
|
+
displayName: 'Message ID',
|
|
436
|
+
name: 'callbackMessageId',
|
|
437
|
+
type: 'number',
|
|
438
|
+
required: true,
|
|
439
|
+
default: 0,
|
|
440
|
+
displayOptions: {
|
|
441
|
+
show: {
|
|
442
|
+
resource: ['message'],
|
|
443
|
+
operation: ['buttonCallback'],
|
|
444
|
+
},
|
|
445
|
+
},
|
|
446
|
+
routing: {
|
|
447
|
+
send: {
|
|
448
|
+
type: 'body',
|
|
449
|
+
property: 'messageId',
|
|
450
|
+
},
|
|
451
|
+
},
|
|
452
|
+
description: 'The ID of the message containing the button',
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
displayName: 'Option ID',
|
|
456
|
+
name: 'optionId',
|
|
457
|
+
type: 'number',
|
|
458
|
+
required: true,
|
|
459
|
+
default: 0,
|
|
460
|
+
displayOptions: {
|
|
461
|
+
show: {
|
|
462
|
+
resource: ['message'],
|
|
463
|
+
operation: ['buttonCallback'],
|
|
464
|
+
},
|
|
465
|
+
},
|
|
466
|
+
routing: {
|
|
467
|
+
send: {
|
|
468
|
+
type: 'body',
|
|
469
|
+
property: 'optionId',
|
|
470
|
+
},
|
|
471
|
+
},
|
|
472
|
+
description: 'The message option (button) ID that was clicked',
|
|
473
|
+
},
|
|
434
474
|
{
|
|
435
475
|
displayName: 'User ID',
|
|
436
476
|
name: 'userId',
|
|
@@ -452,11 +492,11 @@ exports.messageFields = [
|
|
|
452
492
|
description: 'The user ID',
|
|
453
493
|
},
|
|
454
494
|
{
|
|
455
|
-
displayName: '
|
|
456
|
-
name: '
|
|
457
|
-
type: '
|
|
495
|
+
displayName: 'Success',
|
|
496
|
+
name: 'callbackSuccess',
|
|
497
|
+
type: 'boolean',
|
|
458
498
|
required: true,
|
|
459
|
-
default:
|
|
499
|
+
default: true,
|
|
460
500
|
displayOptions: {
|
|
461
501
|
show: {
|
|
462
502
|
resource: ['message'],
|
|
@@ -466,10 +506,10 @@ exports.messageFields = [
|
|
|
466
506
|
routing: {
|
|
467
507
|
send: {
|
|
468
508
|
type: 'body',
|
|
469
|
-
property: '
|
|
509
|
+
property: 'success',
|
|
470
510
|
},
|
|
471
511
|
},
|
|
472
|
-
description: '
|
|
512
|
+
description: 'Whether the callback was processed successfully',
|
|
473
513
|
},
|
|
474
514
|
// =====================================================================
|
|
475
515
|
// sendWebhookMessage fields
|
|
@@ -67,6 +67,40 @@ class BgosTrigger {
|
|
|
67
67
|
required: true,
|
|
68
68
|
description: 'Which events to listen for',
|
|
69
69
|
},
|
|
70
|
+
{
|
|
71
|
+
displayName: 'Additional Filters',
|
|
72
|
+
name: 'additionalFilters',
|
|
73
|
+
type: 'collection',
|
|
74
|
+
placeholder: 'Add Filter',
|
|
75
|
+
default: {},
|
|
76
|
+
description: 'Restrict which events trigger this workflow',
|
|
77
|
+
options: [
|
|
78
|
+
{
|
|
79
|
+
displayName: 'Restrict to User IDs',
|
|
80
|
+
name: 'restrictToUserIds',
|
|
81
|
+
type: 'string',
|
|
82
|
+
default: '',
|
|
83
|
+
description: 'Comma-separated user IDs. Only events from these users will trigger the workflow.',
|
|
84
|
+
placeholder: 'user_abc,user_def',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
displayName: 'Restrict to Assistant IDs',
|
|
88
|
+
name: 'restrictToAssistantIds',
|
|
89
|
+
type: 'string',
|
|
90
|
+
default: '',
|
|
91
|
+
description: 'Comma-separated assistant IDs. Only events for these assistants will trigger.',
|
|
92
|
+
placeholder: '1,2,3',
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
displayName: 'Restrict to Chat IDs',
|
|
96
|
+
name: 'restrictToChatIds',
|
|
97
|
+
type: 'string',
|
|
98
|
+
default: '',
|
|
99
|
+
description: 'Comma-separated chat IDs. Only events in these chats will trigger.',
|
|
100
|
+
placeholder: '10,20,30',
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
},
|
|
70
104
|
],
|
|
71
105
|
};
|
|
72
106
|
async webhook() {
|
|
@@ -82,6 +116,29 @@ class BgosTrigger {
|
|
|
82
116
|
const eventType = String(eventData.event_type || '');
|
|
83
117
|
if (!updates.includes('*') && !updates.includes(eventType))
|
|
84
118
|
return { workflowData: [] };
|
|
119
|
+
// Apply additional filters (restrictToUserIds, restrictToAssistantIds, restrictToChatIds)
|
|
120
|
+
const filters = this.getNodeParameter('additionalFilters', 0, {});
|
|
121
|
+
const body = rawBody;
|
|
122
|
+
if (filters.restrictToUserIds?.trim()) {
|
|
123
|
+
const allowed = filters.restrictToUserIds.split(',').map((s) => s.trim()).filter(Boolean);
|
|
124
|
+
const userId = String(body.user_id ?? body.userId ?? '');
|
|
125
|
+
if (allowed.length && !allowed.includes(userId))
|
|
126
|
+
return { workflowData: [] };
|
|
127
|
+
}
|
|
128
|
+
if (filters.restrictToAssistantIds?.trim()) {
|
|
129
|
+
const allowed = filters.restrictToAssistantIds.split(',').map((s) => s.trim()).filter(Boolean);
|
|
130
|
+
const assistant = body.assistant;
|
|
131
|
+
const assistantId = String(body.assistant_id ?? assistant?.id ?? '');
|
|
132
|
+
if (allowed.length && !allowed.includes(assistantId))
|
|
133
|
+
return { workflowData: [] };
|
|
134
|
+
}
|
|
135
|
+
if (filters.restrictToChatIds?.trim()) {
|
|
136
|
+
const allowed = filters.restrictToChatIds.split(',').map((s) => s.trim()).filter(Boolean);
|
|
137
|
+
const chat = body.chat;
|
|
138
|
+
const chatId = String(body.chat_id ?? chat?.id ?? '');
|
|
139
|
+
if (allowed.length && !allowed.includes(chatId))
|
|
140
|
+
return { workflowData: [] };
|
|
141
|
+
}
|
|
85
142
|
return {
|
|
86
143
|
workflowData: [this.helpers.returnJsonArray([eventData])],
|
|
87
144
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-bgos",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "n8n community nodes for BGOS (Brand Growth OS) - AI assistant chat platform",
|
|
5
5
|
"keywords": ["n8n-community-node-package", "n8n", "bgos", "chat", "assistant", "ai"],
|
|
6
6
|
"license": "MIT",
|