@alex_rexby/n8n-nodes-max 0.3.0 → 0.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.
- package/README.md +157 -159
- package/dist/nodes/Max/Max.node.js +401 -312
- package/dist/nodes/Max/Max.node.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ class Max {
|
|
|
10
10
|
group: ['transform'],
|
|
11
11
|
version: 1,
|
|
12
12
|
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
13
|
-
description: 'Send messages
|
|
13
|
+
description: 'Send messages and interact with MAX messenger API',
|
|
14
14
|
defaults: {
|
|
15
15
|
name: 'MAX',
|
|
16
16
|
},
|
|
@@ -40,10 +40,6 @@ class Max {
|
|
|
40
40
|
name: 'Message',
|
|
41
41
|
value: 'message',
|
|
42
42
|
},
|
|
43
|
-
{
|
|
44
|
-
name: 'File',
|
|
45
|
-
value: 'file',
|
|
46
|
-
},
|
|
47
43
|
{
|
|
48
44
|
name: 'Bot',
|
|
49
45
|
value: 'bot',
|
|
@@ -56,10 +52,6 @@ class Max {
|
|
|
56
52
|
name: 'Callback',
|
|
57
53
|
value: 'callback',
|
|
58
54
|
},
|
|
59
|
-
{
|
|
60
|
-
name: 'Subscription',
|
|
61
|
-
value: 'subscription',
|
|
62
|
-
},
|
|
63
55
|
],
|
|
64
56
|
default: 'message',
|
|
65
57
|
},
|
|
@@ -75,28 +67,34 @@ class Max {
|
|
|
75
67
|
},
|
|
76
68
|
options: [
|
|
77
69
|
{
|
|
78
|
-
name: 'Send',
|
|
70
|
+
name: 'Send Text',
|
|
79
71
|
value: 'send',
|
|
80
|
-
description: 'Send a message',
|
|
81
|
-
action: 'Send
|
|
72
|
+
description: 'Send a text message',
|
|
73
|
+
action: 'Send text message',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: 'Send with Media',
|
|
77
|
+
value: 'sendMedia',
|
|
78
|
+
description: 'Send message with file (image, video, audio, document)',
|
|
79
|
+
action: 'Send message with media',
|
|
82
80
|
},
|
|
83
81
|
{
|
|
84
82
|
name: 'Get',
|
|
85
83
|
value: 'get',
|
|
86
84
|
description: 'Get a message by ID',
|
|
87
|
-
action: 'Get
|
|
85
|
+
action: 'Get message',
|
|
88
86
|
},
|
|
89
87
|
{
|
|
90
88
|
name: 'Edit',
|
|
91
89
|
value: 'edit',
|
|
92
90
|
description: 'Edit a message',
|
|
93
|
-
action: 'Edit
|
|
91
|
+
action: 'Edit message',
|
|
94
92
|
},
|
|
95
93
|
{
|
|
96
94
|
name: 'Delete',
|
|
97
95
|
value: 'delete',
|
|
98
96
|
description: 'Delete a message',
|
|
99
|
-
action: 'Delete
|
|
97
|
+
action: 'Delete message',
|
|
100
98
|
},
|
|
101
99
|
],
|
|
102
100
|
default: 'send',
|
|
@@ -109,11 +107,12 @@ class Max {
|
|
|
109
107
|
displayOptions: {
|
|
110
108
|
show: {
|
|
111
109
|
resource: ['message'],
|
|
112
|
-
operation: ['send'],
|
|
110
|
+
operation: ['send', 'sendMedia'],
|
|
113
111
|
},
|
|
114
112
|
},
|
|
115
113
|
default: '',
|
|
116
114
|
description: 'The ID of the user to send the message to',
|
|
115
|
+
placeholder: '12345',
|
|
117
116
|
},
|
|
118
117
|
{
|
|
119
118
|
displayName: 'Text',
|
|
@@ -133,14 +132,187 @@ class Max {
|
|
|
133
132
|
description: 'The text of the message to send',
|
|
134
133
|
},
|
|
135
134
|
{
|
|
136
|
-
displayName: '
|
|
137
|
-
name: '
|
|
135
|
+
displayName: 'Binary Property',
|
|
136
|
+
name: 'binaryPropertyName',
|
|
137
|
+
type: 'string',
|
|
138
|
+
required: true,
|
|
139
|
+
displayOptions: {
|
|
140
|
+
show: {
|
|
141
|
+
resource: ['message'],
|
|
142
|
+
operation: ['sendMedia'],
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
default: 'data',
|
|
146
|
+
description: 'Name of the binary property containing the file',
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
displayName: 'Caption (Text)',
|
|
150
|
+
name: 'caption',
|
|
151
|
+
type: 'string',
|
|
152
|
+
typeOptions: {
|
|
153
|
+
rows: 4,
|
|
154
|
+
},
|
|
155
|
+
displayOptions: {
|
|
156
|
+
show: {
|
|
157
|
+
resource: ['message'],
|
|
158
|
+
operation: ['sendMedia'],
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
default: '',
|
|
162
|
+
description: 'Text caption for the media file',
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
displayName: 'Add Buttons',
|
|
166
|
+
name: 'addButtons',
|
|
167
|
+
type: 'boolean',
|
|
168
|
+
displayOptions: {
|
|
169
|
+
show: {
|
|
170
|
+
resource: ['message'],
|
|
171
|
+
operation: ['send', 'sendMedia'],
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
default: false,
|
|
175
|
+
description: 'Whether to add inline keyboard buttons',
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
displayName: 'Button Mode',
|
|
179
|
+
name: 'buttonMode',
|
|
180
|
+
type: 'options',
|
|
181
|
+
displayOptions: {
|
|
182
|
+
show: {
|
|
183
|
+
resource: ['message'],
|
|
184
|
+
operation: ['send', 'sendMedia'],
|
|
185
|
+
addButtons: [true],
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
options: [
|
|
189
|
+
{
|
|
190
|
+
name: 'Simple (Visual)',
|
|
191
|
+
value: 'simple',
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
name: 'Advanced (JSON)',
|
|
195
|
+
value: 'json',
|
|
196
|
+
},
|
|
197
|
+
],
|
|
198
|
+
default: 'simple',
|
|
199
|
+
description: 'How to configure buttons',
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
displayName: 'Buttons',
|
|
203
|
+
name: 'buttons',
|
|
204
|
+
type: 'fixedCollection',
|
|
205
|
+
typeOptions: {
|
|
206
|
+
multipleValues: true,
|
|
207
|
+
},
|
|
208
|
+
displayOptions: {
|
|
209
|
+
show: {
|
|
210
|
+
resource: ['message'],
|
|
211
|
+
operation: ['send', 'sendMedia'],
|
|
212
|
+
addButtons: [true],
|
|
213
|
+
buttonMode: ['simple'],
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
default: {},
|
|
217
|
+
placeholder: 'Add Button Row',
|
|
218
|
+
options: [
|
|
219
|
+
{
|
|
220
|
+
name: 'row',
|
|
221
|
+
displayName: 'Button Row',
|
|
222
|
+
values: [
|
|
223
|
+
{
|
|
224
|
+
displayName: 'Buttons in Row',
|
|
225
|
+
name: 'buttonsInRow',
|
|
226
|
+
type: 'fixedCollection',
|
|
227
|
+
typeOptions: {
|
|
228
|
+
multipleValues: true,
|
|
229
|
+
},
|
|
230
|
+
default: {},
|
|
231
|
+
options: [
|
|
232
|
+
{
|
|
233
|
+
name: 'button',
|
|
234
|
+
displayName: 'Button',
|
|
235
|
+
values: [
|
|
236
|
+
{
|
|
237
|
+
displayName: 'Button Text',
|
|
238
|
+
name: 'text',
|
|
239
|
+
type: 'string',
|
|
240
|
+
default: '',
|
|
241
|
+
description: 'Text on the button',
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
displayName: 'Button Type',
|
|
245
|
+
name: 'type',
|
|
246
|
+
type: 'options',
|
|
247
|
+
options: [
|
|
248
|
+
{
|
|
249
|
+
name: 'Callback (Action)',
|
|
250
|
+
value: 'callback',
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
name: 'Link (URL)',
|
|
254
|
+
value: 'link',
|
|
255
|
+
},
|
|
256
|
+
],
|
|
257
|
+
default: 'callback',
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
displayName: 'Callback Data',
|
|
261
|
+
name: 'callback',
|
|
262
|
+
type: 'string',
|
|
263
|
+
displayOptions: {
|
|
264
|
+
show: {
|
|
265
|
+
type: ['callback'],
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
default: '',
|
|
269
|
+
description: 'Data to receive when button clicked',
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
displayName: 'URL',
|
|
273
|
+
name: 'link',
|
|
274
|
+
type: 'string',
|
|
275
|
+
displayOptions: {
|
|
276
|
+
show: {
|
|
277
|
+
type: ['link'],
|
|
278
|
+
},
|
|
279
|
+
},
|
|
280
|
+
default: '',
|
|
281
|
+
description: 'URL to open',
|
|
282
|
+
},
|
|
283
|
+
],
|
|
284
|
+
},
|
|
285
|
+
],
|
|
286
|
+
},
|
|
287
|
+
],
|
|
288
|
+
},
|
|
289
|
+
],
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
displayName: 'Inline Keyboard (JSON)',
|
|
293
|
+
name: 'inlineKeyboard',
|
|
294
|
+
type: 'json',
|
|
295
|
+
displayOptions: {
|
|
296
|
+
show: {
|
|
297
|
+
resource: ['message'],
|
|
298
|
+
operation: ['send', 'sendMedia'],
|
|
299
|
+
addButtons: [true],
|
|
300
|
+
buttonMode: ['json'],
|
|
301
|
+
},
|
|
302
|
+
},
|
|
303
|
+
default: '[[{"text": "Button 1", "callback": "btn1"}]]',
|
|
304
|
+
description: 'Inline keyboard buttons as JSON array',
|
|
305
|
+
placeholder: '[[{"text": "Button", "callback": "data"}]]',
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
displayName: 'Additional Options',
|
|
309
|
+
name: 'additionalOptions',
|
|
138
310
|
type: 'collection',
|
|
139
|
-
placeholder: 'Add
|
|
311
|
+
placeholder: 'Add Option',
|
|
140
312
|
displayOptions: {
|
|
141
313
|
show: {
|
|
142
314
|
resource: ['message'],
|
|
143
|
-
operation: ['send'],
|
|
315
|
+
operation: ['send', 'sendMedia'],
|
|
144
316
|
},
|
|
145
317
|
},
|
|
146
318
|
default: {},
|
|
@@ -162,14 +334,6 @@ class Max {
|
|
|
162
334
|
default: 'markdown',
|
|
163
335
|
description: 'Text formatting style',
|
|
164
336
|
},
|
|
165
|
-
{
|
|
166
|
-
displayName: 'Inline Keyboard (JSON)',
|
|
167
|
-
name: 'inlineKeyboard',
|
|
168
|
-
type: 'json',
|
|
169
|
-
default: '[[{"text": "Button 1", "callback": "btn1"}]]',
|
|
170
|
-
description: 'Inline keyboard buttons as JSON array',
|
|
171
|
-
placeholder: '[[{"text": "Button", "callback": "data"}]]',
|
|
172
|
-
},
|
|
173
337
|
{
|
|
174
338
|
displayName: 'Reply To Message ID',
|
|
175
339
|
name: 'replyToMessageId',
|
|
@@ -185,19 +349,11 @@ class Max {
|
|
|
185
349
|
description: 'Whether to disable link previews',
|
|
186
350
|
},
|
|
187
351
|
{
|
|
188
|
-
displayName: '
|
|
189
|
-
name: '
|
|
352
|
+
displayName: 'Silent Message',
|
|
353
|
+
name: 'silentMessage',
|
|
190
354
|
type: 'boolean',
|
|
191
|
-
default:
|
|
192
|
-
description: '
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
displayName: 'Attachments (JSON)',
|
|
196
|
-
name: 'attachments',
|
|
197
|
-
type: 'json',
|
|
198
|
-
default: '',
|
|
199
|
-
description: 'Attachments as JSON array (from uploaded files)',
|
|
200
|
-
placeholder: '[{"type": "image", "file_id": "xyz"}]',
|
|
355
|
+
default: false,
|
|
356
|
+
description: 'Send message without notification',
|
|
201
357
|
},
|
|
202
358
|
],
|
|
203
359
|
},
|
|
@@ -246,45 +402,6 @@ class Max {
|
|
|
246
402
|
default: '',
|
|
247
403
|
description: 'New text for the message',
|
|
248
404
|
},
|
|
249
|
-
{
|
|
250
|
-
displayName: 'Additional Fields',
|
|
251
|
-
name: 'editFields',
|
|
252
|
-
type: 'collection',
|
|
253
|
-
placeholder: 'Add Field',
|
|
254
|
-
displayOptions: {
|
|
255
|
-
show: {
|
|
256
|
-
resource: ['message'],
|
|
257
|
-
operation: ['edit'],
|
|
258
|
-
},
|
|
259
|
-
},
|
|
260
|
-
default: {},
|
|
261
|
-
options: [
|
|
262
|
-
{
|
|
263
|
-
displayName: 'Format',
|
|
264
|
-
name: 'format',
|
|
265
|
-
type: 'options',
|
|
266
|
-
options: [
|
|
267
|
-
{
|
|
268
|
-
name: 'Markdown',
|
|
269
|
-
value: 'markdown',
|
|
270
|
-
},
|
|
271
|
-
{
|
|
272
|
-
name: 'HTML',
|
|
273
|
-
value: 'html',
|
|
274
|
-
},
|
|
275
|
-
],
|
|
276
|
-
default: 'markdown',
|
|
277
|
-
description: 'Text formatting style',
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
displayName: 'Inline Keyboard (JSON)',
|
|
281
|
-
name: 'inlineKeyboard',
|
|
282
|
-
type: 'json',
|
|
283
|
-
default: '',
|
|
284
|
-
description: 'Updated inline keyboard',
|
|
285
|
-
},
|
|
286
|
-
],
|
|
287
|
-
},
|
|
288
405
|
{
|
|
289
406
|
displayName: 'Delete For All',
|
|
290
407
|
name: 'deleteForAll',
|
|
@@ -298,72 +415,6 @@ class Max {
|
|
|
298
415
|
default: false,
|
|
299
416
|
description: 'Whether to delete for all users (requires admin rights)',
|
|
300
417
|
},
|
|
301
|
-
{
|
|
302
|
-
displayName: 'Operation',
|
|
303
|
-
name: 'operation',
|
|
304
|
-
type: 'options',
|
|
305
|
-
noDataExpression: true,
|
|
306
|
-
displayOptions: {
|
|
307
|
-
show: {
|
|
308
|
-
resource: ['file'],
|
|
309
|
-
},
|
|
310
|
-
},
|
|
311
|
-
options: [
|
|
312
|
-
{
|
|
313
|
-
name: 'Upload',
|
|
314
|
-
value: 'upload',
|
|
315
|
-
description: 'Upload a file to MAX',
|
|
316
|
-
action: 'Upload a file',
|
|
317
|
-
},
|
|
318
|
-
],
|
|
319
|
-
default: 'upload',
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
displayName: 'File Type',
|
|
323
|
-
name: 'fileType',
|
|
324
|
-
type: 'options',
|
|
325
|
-
required: true,
|
|
326
|
-
displayOptions: {
|
|
327
|
-
show: {
|
|
328
|
-
resource: ['file'],
|
|
329
|
-
operation: ['upload'],
|
|
330
|
-
},
|
|
331
|
-
},
|
|
332
|
-
options: [
|
|
333
|
-
{
|
|
334
|
-
name: 'Image',
|
|
335
|
-
value: 'image',
|
|
336
|
-
},
|
|
337
|
-
{
|
|
338
|
-
name: 'Video',
|
|
339
|
-
value: 'video',
|
|
340
|
-
},
|
|
341
|
-
{
|
|
342
|
-
name: 'Audio',
|
|
343
|
-
value: 'audio',
|
|
344
|
-
},
|
|
345
|
-
{
|
|
346
|
-
name: 'File',
|
|
347
|
-
value: 'file',
|
|
348
|
-
},
|
|
349
|
-
],
|
|
350
|
-
default: 'image',
|
|
351
|
-
description: 'Type of file to upload',
|
|
352
|
-
},
|
|
353
|
-
{
|
|
354
|
-
displayName: 'Input Data Field Name',
|
|
355
|
-
name: 'binaryPropertyName',
|
|
356
|
-
type: 'string',
|
|
357
|
-
required: true,
|
|
358
|
-
displayOptions: {
|
|
359
|
-
show: {
|
|
360
|
-
resource: ['file'],
|
|
361
|
-
operation: ['upload'],
|
|
362
|
-
},
|
|
363
|
-
},
|
|
364
|
-
default: 'data',
|
|
365
|
-
description: 'The name of the input field containing the file to upload',
|
|
366
|
-
},
|
|
367
418
|
{
|
|
368
419
|
displayName: 'Operation',
|
|
369
420
|
name: 'operation',
|
|
@@ -419,36 +470,33 @@ class Max {
|
|
|
419
470
|
description: 'The ID of the chat to update',
|
|
420
471
|
},
|
|
421
472
|
{
|
|
422
|
-
displayName: '
|
|
423
|
-
name: '
|
|
424
|
-
type: '
|
|
425
|
-
placeholder: 'Add Field',
|
|
473
|
+
displayName: 'Title',
|
|
474
|
+
name: 'chatTitle',
|
|
475
|
+
type: 'string',
|
|
426
476
|
displayOptions: {
|
|
427
477
|
show: {
|
|
428
478
|
resource: ['chat'],
|
|
429
479
|
operation: ['update'],
|
|
430
480
|
},
|
|
431
481
|
},
|
|
432
|
-
default:
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
rows: 3,
|
|
447
|
-
},
|
|
448
|
-
default: '',
|
|
449
|
-
description: 'New chat description',
|
|
482
|
+
default: '',
|
|
483
|
+
description: 'New chat title',
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
displayName: 'Description',
|
|
487
|
+
name: 'chatDescription',
|
|
488
|
+
type: 'string',
|
|
489
|
+
typeOptions: {
|
|
490
|
+
rows: 3,
|
|
491
|
+
},
|
|
492
|
+
displayOptions: {
|
|
493
|
+
show: {
|
|
494
|
+
resource: ['chat'],
|
|
495
|
+
operation: ['update'],
|
|
450
496
|
},
|
|
451
|
-
|
|
497
|
+
},
|
|
498
|
+
default: '',
|
|
499
|
+
description: 'New chat description',
|
|
452
500
|
},
|
|
453
501
|
{
|
|
454
502
|
displayName: 'Operation',
|
|
@@ -464,8 +512,14 @@ class Max {
|
|
|
464
512
|
{
|
|
465
513
|
name: 'Answer',
|
|
466
514
|
value: 'answer',
|
|
467
|
-
description: 'Answer callback query
|
|
468
|
-
action: 'Answer callback
|
|
515
|
+
description: 'Answer callback query (notification only)',
|
|
516
|
+
action: 'Answer callback',
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
name: 'Answer and Send Message',
|
|
520
|
+
value: 'answerAndSend',
|
|
521
|
+
description: 'Answer callback and send a new message',
|
|
522
|
+
action: 'Answer and send message',
|
|
469
523
|
},
|
|
470
524
|
],
|
|
471
525
|
default: 'answer',
|
|
@@ -478,20 +532,20 @@ class Max {
|
|
|
478
532
|
displayOptions: {
|
|
479
533
|
show: {
|
|
480
534
|
resource: ['callback'],
|
|
481
|
-
operation: ['answer'],
|
|
535
|
+
operation: ['answer', 'answerAndSend'],
|
|
482
536
|
},
|
|
483
537
|
},
|
|
484
538
|
default: '={{ $json.event.callback_query_id }}',
|
|
485
539
|
description: 'ID of the callback query',
|
|
486
540
|
},
|
|
487
541
|
{
|
|
488
|
-
displayName: 'Text',
|
|
542
|
+
displayName: 'Notification Text',
|
|
489
543
|
name: 'callbackText',
|
|
490
544
|
type: 'string',
|
|
491
545
|
displayOptions: {
|
|
492
546
|
show: {
|
|
493
547
|
resource: ['callback'],
|
|
494
|
-
operation: ['answer'],
|
|
548
|
+
operation: ['answer', 'answerAndSend'],
|
|
495
549
|
},
|
|
496
550
|
},
|
|
497
551
|
default: '',
|
|
@@ -504,87 +558,42 @@ class Max {
|
|
|
504
558
|
displayOptions: {
|
|
505
559
|
show: {
|
|
506
560
|
resource: ['callback'],
|
|
507
|
-
operation: ['answer'],
|
|
561
|
+
operation: ['answer', 'answerAndSend'],
|
|
508
562
|
},
|
|
509
563
|
},
|
|
510
564
|
default: false,
|
|
511
565
|
description: 'Whether to show alert instead of notification',
|
|
512
566
|
},
|
|
513
567
|
{
|
|
514
|
-
displayName: '
|
|
515
|
-
name: '
|
|
516
|
-
type: 'options',
|
|
517
|
-
noDataExpression: true,
|
|
518
|
-
displayOptions: {
|
|
519
|
-
show: {
|
|
520
|
-
resource: ['subscription'],
|
|
521
|
-
},
|
|
522
|
-
},
|
|
523
|
-
options: [
|
|
524
|
-
{
|
|
525
|
-
name: 'Create',
|
|
526
|
-
value: 'create',
|
|
527
|
-
description: 'Create webhook subscription',
|
|
528
|
-
action: 'Create webhook subscription',
|
|
529
|
-
},
|
|
530
|
-
],
|
|
531
|
-
default: 'create',
|
|
532
|
-
},
|
|
533
|
-
{
|
|
534
|
-
displayName: 'Webhook URL',
|
|
535
|
-
name: 'webhookUrl',
|
|
568
|
+
displayName: 'User ID',
|
|
569
|
+
name: 'callbackUserId',
|
|
536
570
|
type: 'string',
|
|
537
571
|
required: true,
|
|
538
572
|
displayOptions: {
|
|
539
573
|
show: {
|
|
540
|
-
resource: ['
|
|
541
|
-
operation: ['
|
|
574
|
+
resource: ['callback'],
|
|
575
|
+
operation: ['answerAndSend'],
|
|
542
576
|
},
|
|
543
577
|
},
|
|
544
|
-
default: '',
|
|
545
|
-
description: '
|
|
546
|
-
placeholder: 'https://your-domain.com/webhook',
|
|
578
|
+
default: '={{ $json.event.user_id }}',
|
|
579
|
+
description: 'User ID to send message to',
|
|
547
580
|
},
|
|
548
581
|
{
|
|
549
|
-
displayName: '
|
|
550
|
-
name: '
|
|
551
|
-
type: '
|
|
582
|
+
displayName: 'Message Text',
|
|
583
|
+
name: 'callbackMessageText',
|
|
584
|
+
type: 'string',
|
|
552
585
|
required: true,
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
resource: ['subscription'],
|
|
556
|
-
operation: ['create'],
|
|
557
|
-
},
|
|
586
|
+
typeOptions: {
|
|
587
|
+
rows: 4,
|
|
558
588
|
},
|
|
559
|
-
options: [
|
|
560
|
-
{
|
|
561
|
-
name: 'Message Created',
|
|
562
|
-
value: 'message_created',
|
|
563
|
-
},
|
|
564
|
-
{
|
|
565
|
-
name: 'Message Callback',
|
|
566
|
-
value: 'message_callback',
|
|
567
|
-
},
|
|
568
|
-
{
|
|
569
|
-
name: 'Bot Started',
|
|
570
|
-
value: 'bot_started',
|
|
571
|
-
},
|
|
572
|
-
],
|
|
573
|
-
default: ['message_created'],
|
|
574
|
-
description: 'Types of updates to receive',
|
|
575
|
-
},
|
|
576
|
-
{
|
|
577
|
-
displayName: 'Secret',
|
|
578
|
-
name: 'secret',
|
|
579
|
-
type: 'string',
|
|
580
589
|
displayOptions: {
|
|
581
590
|
show: {
|
|
582
|
-
resource: ['
|
|
583
|
-
operation: ['
|
|
591
|
+
resource: ['callback'],
|
|
592
|
+
operation: ['answerAndSend'],
|
|
584
593
|
},
|
|
585
594
|
},
|
|
586
595
|
default: '',
|
|
587
|
-
description: '
|
|
596
|
+
description: 'Text of the message to send',
|
|
588
597
|
},
|
|
589
598
|
],
|
|
590
599
|
};
|
|
@@ -597,28 +606,111 @@ class Max {
|
|
|
597
606
|
for (let i = 0; i < items.length; i++) {
|
|
598
607
|
try {
|
|
599
608
|
if (resource === 'message') {
|
|
600
|
-
if (operation === 'send') {
|
|
609
|
+
if (operation === 'send' || operation === 'sendMedia') {
|
|
601
610
|
const userId = this.getNodeParameter('userId', i);
|
|
602
|
-
const
|
|
603
|
-
const
|
|
604
|
-
const body = {
|
|
605
|
-
if (
|
|
606
|
-
body.
|
|
611
|
+
const addButtons = this.getNodeParameter('addButtons', i);
|
|
612
|
+
const additionalOptions = this.getNodeParameter('additionalOptions', i);
|
|
613
|
+
const body = {};
|
|
614
|
+
if (operation === 'send') {
|
|
615
|
+
body.text = this.getNodeParameter('text', i);
|
|
616
|
+
}
|
|
617
|
+
else {
|
|
618
|
+
body.text = this.getNodeParameter('caption', i) || '';
|
|
607
619
|
}
|
|
608
|
-
if (
|
|
609
|
-
|
|
620
|
+
if (operation === 'sendMedia') {
|
|
621
|
+
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
|
|
622
|
+
const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
|
|
623
|
+
const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
|
624
|
+
let fileType = 'file';
|
|
625
|
+
if (binaryData.mimeType) {
|
|
626
|
+
if (binaryData.mimeType.startsWith('image/'))
|
|
627
|
+
fileType = 'image';
|
|
628
|
+
else if (binaryData.mimeType.startsWith('video/'))
|
|
629
|
+
fileType = 'video';
|
|
630
|
+
else if (binaryData.mimeType.startsWith('audio/'))
|
|
631
|
+
fileType = 'audio';
|
|
632
|
+
}
|
|
633
|
+
const uploadUrlResponse = await this.helpers.httpRequestWithAuthentication.call(this, 'maxApi', {
|
|
634
|
+
method: 'POST',
|
|
635
|
+
url: `https://platform-api.max.ru/uploads?type=${fileType}`,
|
|
636
|
+
body: {},
|
|
637
|
+
json: true,
|
|
638
|
+
});
|
|
639
|
+
const uploadUrl = uploadUrlResponse.url;
|
|
640
|
+
let fileId = uploadUrlResponse.token;
|
|
641
|
+
if (uploadUrl) {
|
|
642
|
+
const uploadResponse = await this.helpers.request({
|
|
643
|
+
method: 'POST',
|
|
644
|
+
url: uploadUrl,
|
|
645
|
+
body: buffer,
|
|
646
|
+
headers: {
|
|
647
|
+
'Content-Type': binaryData.mimeType || 'application/octet-stream',
|
|
648
|
+
},
|
|
649
|
+
json: false,
|
|
650
|
+
});
|
|
651
|
+
if (fileType === 'video' || fileType === 'audio') {
|
|
652
|
+
try {
|
|
653
|
+
const uploadData = typeof uploadResponse === 'string' ? JSON.parse(uploadResponse) : uploadResponse;
|
|
654
|
+
if (uploadData.token) {
|
|
655
|
+
fileId = uploadData.token;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
catch (e) {
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
body.attachments = [{
|
|
663
|
+
type: fileType,
|
|
664
|
+
file_id: fileId,
|
|
665
|
+
}];
|
|
610
666
|
}
|
|
611
|
-
if (
|
|
612
|
-
body.
|
|
667
|
+
if (additionalOptions.format) {
|
|
668
|
+
body.format = additionalOptions.format;
|
|
613
669
|
}
|
|
614
|
-
if (
|
|
615
|
-
body.
|
|
670
|
+
if (additionalOptions.replyToMessageId) {
|
|
671
|
+
body.reply_to_message_id = additionalOptions.replyToMessageId;
|
|
616
672
|
}
|
|
617
|
-
if (
|
|
618
|
-
body.
|
|
673
|
+
if (additionalOptions.disableLinkPreview !== undefined) {
|
|
674
|
+
body.disable_link_preview = additionalOptions.disableLinkPreview;
|
|
619
675
|
}
|
|
620
|
-
if (
|
|
621
|
-
body.
|
|
676
|
+
if (additionalOptions.silentMessage !== undefined) {
|
|
677
|
+
body.notify = !additionalOptions.silentMessage;
|
|
678
|
+
}
|
|
679
|
+
if (addButtons) {
|
|
680
|
+
const buttonMode = this.getNodeParameter('buttonMode', i);
|
|
681
|
+
if (buttonMode === 'simple') {
|
|
682
|
+
const buttons = this.getNodeParameter('buttons', i);
|
|
683
|
+
const keyboard = [];
|
|
684
|
+
if (buttons.row && buttons.row.length > 0) {
|
|
685
|
+
for (const row of buttons.row) {
|
|
686
|
+
const buttonRow = [];
|
|
687
|
+
if (row.buttonsInRow && row.buttonsInRow.button) {
|
|
688
|
+
for (const btn of row.buttonsInRow.button) {
|
|
689
|
+
const button = { text: btn.text };
|
|
690
|
+
if (btn.type === 'callback') {
|
|
691
|
+
button.callback = btn.callback;
|
|
692
|
+
}
|
|
693
|
+
else if (btn.type === 'link') {
|
|
694
|
+
button.link = btn.link;
|
|
695
|
+
}
|
|
696
|
+
buttonRow.push(button);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
if (buttonRow.length > 0) {
|
|
700
|
+
keyboard.push(buttonRow);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
if (keyboard.length > 0) {
|
|
705
|
+
body.inline_keyboard = keyboard;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
else {
|
|
709
|
+
const inlineKeyboard = this.getNodeParameter('inlineKeyboard', i);
|
|
710
|
+
if (inlineKeyboard) {
|
|
711
|
+
body.inline_keyboard = JSON.parse(inlineKeyboard);
|
|
712
|
+
}
|
|
713
|
+
}
|
|
622
714
|
}
|
|
623
715
|
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'maxApi', {
|
|
624
716
|
method: 'POST',
|
|
@@ -640,17 +732,10 @@ class Max {
|
|
|
640
732
|
if (operation === 'edit') {
|
|
641
733
|
const messageId = this.getNodeParameter('messageIdEdit', i);
|
|
642
734
|
const newText = this.getNodeParameter('newText', i);
|
|
643
|
-
const editFields = this.getNodeParameter('editFields', i);
|
|
644
735
|
const body = {
|
|
645
736
|
message_id: messageId,
|
|
646
737
|
text: newText,
|
|
647
738
|
};
|
|
648
|
-
if (editFields.format) {
|
|
649
|
-
body.format = editFields.format;
|
|
650
|
-
}
|
|
651
|
-
if (editFields.inlineKeyboard) {
|
|
652
|
-
body.inline_keyboard = editFields.inlineKeyboard;
|
|
653
|
-
}
|
|
654
739
|
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'maxApi', {
|
|
655
740
|
method: 'PUT',
|
|
656
741
|
url: 'https://platform-api.max.ru/messages',
|
|
@@ -677,23 +762,6 @@ class Max {
|
|
|
677
762
|
returnData.push({ json: responseData });
|
|
678
763
|
}
|
|
679
764
|
}
|
|
680
|
-
if (resource === 'file' && operation === 'upload') {
|
|
681
|
-
const fileType = this.getNodeParameter('fileType', i);
|
|
682
|
-
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
|
|
683
|
-
const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
|
|
684
|
-
const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
|
685
|
-
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'maxApi', {
|
|
686
|
-
method: 'POST',
|
|
687
|
-
url: `https://platform-api.max.ru/uploads?type=${fileType}`,
|
|
688
|
-
body: buffer,
|
|
689
|
-
headers: {
|
|
690
|
-
'Content-Type': binaryData.mimeType || 'application/octet-stream',
|
|
691
|
-
},
|
|
692
|
-
json: false,
|
|
693
|
-
returnFullResponse: false,
|
|
694
|
-
});
|
|
695
|
-
returnData.push({ json: typeof responseData === 'string' ? JSON.parse(responseData) : responseData });
|
|
696
|
-
}
|
|
697
765
|
if (resource === 'bot' && operation === 'getInfo') {
|
|
698
766
|
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'maxApi', {
|
|
699
767
|
method: 'GET',
|
|
@@ -704,54 +772,75 @@ class Max {
|
|
|
704
772
|
}
|
|
705
773
|
if (resource === 'chat' && operation === 'update') {
|
|
706
774
|
const chatId = this.getNodeParameter('chatId', i);
|
|
707
|
-
const
|
|
775
|
+
const chatTitle = this.getNodeParameter('chatTitle', i);
|
|
776
|
+
const chatDescription = this.getNodeParameter('chatDescription', i);
|
|
777
|
+
const body = {};
|
|
778
|
+
if (chatTitle)
|
|
779
|
+
body.title = chatTitle;
|
|
780
|
+
if (chatDescription)
|
|
781
|
+
body.description = chatDescription;
|
|
708
782
|
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'maxApi', {
|
|
709
783
|
method: 'PATCH',
|
|
710
784
|
url: `https://platform-api.max.ru/chats/${chatId}`,
|
|
711
|
-
body: updateFields,
|
|
712
|
-
json: true,
|
|
713
|
-
});
|
|
714
|
-
returnData.push({ json: responseData });
|
|
715
|
-
}
|
|
716
|
-
if (resource === 'callback' && operation === 'answer') {
|
|
717
|
-
const callbackQueryId = this.getNodeParameter('callbackQueryId', i);
|
|
718
|
-
const callbackText = this.getNodeParameter('callbackText', i);
|
|
719
|
-
const showAlert = this.getNodeParameter('showAlert', i);
|
|
720
|
-
const body = {
|
|
721
|
-
callback_query_id: callbackQueryId,
|
|
722
|
-
};
|
|
723
|
-
if (callbackText) {
|
|
724
|
-
body.text = callbackText;
|
|
725
|
-
}
|
|
726
|
-
if (showAlert) {
|
|
727
|
-
body.show_alert = true;
|
|
728
|
-
}
|
|
729
|
-
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'maxApi', {
|
|
730
|
-
method: 'POST',
|
|
731
|
-
url: 'https://platform-api.max.ru/answers',
|
|
732
785
|
body,
|
|
733
786
|
json: true,
|
|
734
787
|
});
|
|
735
788
|
returnData.push({ json: responseData });
|
|
736
789
|
}
|
|
737
|
-
if (resource === '
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
790
|
+
if (resource === 'callback') {
|
|
791
|
+
if (operation === 'answer') {
|
|
792
|
+
const callbackQueryId = this.getNodeParameter('callbackQueryId', i);
|
|
793
|
+
const callbackText = this.getNodeParameter('callbackText', i);
|
|
794
|
+
const showAlert = this.getNodeParameter('showAlert', i);
|
|
795
|
+
const body = {
|
|
796
|
+
callback_query_id: callbackQueryId,
|
|
797
|
+
};
|
|
798
|
+
if (callbackText) {
|
|
799
|
+
body.text = callbackText;
|
|
800
|
+
}
|
|
801
|
+
if (showAlert) {
|
|
802
|
+
body.show_alert = true;
|
|
803
|
+
}
|
|
804
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'maxApi', {
|
|
805
|
+
method: 'POST',
|
|
806
|
+
url: 'https://platform-api.max.ru/answers',
|
|
807
|
+
body,
|
|
808
|
+
json: true,
|
|
809
|
+
});
|
|
810
|
+
returnData.push({ json: responseData });
|
|
811
|
+
}
|
|
812
|
+
if (operation === 'answerAndSend') {
|
|
813
|
+
const callbackQueryId = this.getNodeParameter('callbackQueryId', i);
|
|
814
|
+
const callbackText = this.getNodeParameter('callbackText', i);
|
|
815
|
+
const showAlert = this.getNodeParameter('showAlert', i);
|
|
816
|
+
const userId = this.getNodeParameter('callbackUserId', i);
|
|
817
|
+
const messageText = this.getNodeParameter('callbackMessageText', i);
|
|
818
|
+
const answerBody = {
|
|
819
|
+
callback_query_id: callbackQueryId,
|
|
820
|
+
};
|
|
821
|
+
if (callbackText) {
|
|
822
|
+
answerBody.text = callbackText;
|
|
823
|
+
}
|
|
824
|
+
if (showAlert) {
|
|
825
|
+
answerBody.show_alert = true;
|
|
826
|
+
}
|
|
827
|
+
await this.helpers.httpRequestWithAuthentication.call(this, 'maxApi', {
|
|
828
|
+
method: 'POST',
|
|
829
|
+
url: 'https://platform-api.max.ru/answers',
|
|
830
|
+
body: answerBody,
|
|
831
|
+
json: true,
|
|
832
|
+
});
|
|
833
|
+
const messageBody = {
|
|
834
|
+
text: messageText,
|
|
835
|
+
};
|
|
836
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'maxApi', {
|
|
837
|
+
method: 'POST',
|
|
838
|
+
url: `https://platform-api.max.ru/messages?user_id=${userId}`,
|
|
839
|
+
body: messageBody,
|
|
840
|
+
json: true,
|
|
841
|
+
});
|
|
842
|
+
returnData.push({ json: responseData });
|
|
747
843
|
}
|
|
748
|
-
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'maxApi', {
|
|
749
|
-
method: 'POST',
|
|
750
|
-
url: 'https://platform-api.max.ru/subscriptions',
|
|
751
|
-
body,
|
|
752
|
-
json: true,
|
|
753
|
-
});
|
|
754
|
-
returnData.push({ json: responseData });
|
|
755
844
|
}
|
|
756
845
|
}
|
|
757
846
|
catch (error) {
|