n8n-nodes-wassenger 1.2.2 → 1.2.3

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.
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executeCampaignOperations = exports.campaignProperties = void 0;
3
+ exports.campaignProperties = void 0;
4
+ exports.executeCampaignOperations = executeCampaignOperations;
4
5
  const request_1 = require("../request");
5
6
  exports.campaignProperties = [
6
7
  {
@@ -19,6 +20,11 @@ exports.campaignProperties = [
19
20
  value: 'getCampaigns',
20
21
  description: 'Get a list of campaigns',
21
22
  },
23
+ {
24
+ name: 'Create Campaign',
25
+ value: 'createCampaign',
26
+ description: 'Create a new campaign',
27
+ },
22
28
  {
23
29
  name: 'Get Campaign',
24
30
  value: 'getCampaign',
@@ -42,6 +48,167 @@ exports.campaignProperties = [
42
48
  ],
43
49
  default: 'getCampaigns',
44
50
  },
51
+ // ----------------------------------
52
+ // createCampaign
53
+ // ----------------------------------
54
+ {
55
+ displayName: 'Name',
56
+ name: 'name',
57
+ type: 'string',
58
+ required: true,
59
+ displayOptions: {
60
+ show: {
61
+ resource: ['campaigns'],
62
+ operation: ['createCampaign'],
63
+ },
64
+ },
65
+ default: '',
66
+ description: 'Campaign name',
67
+ },
68
+ {
69
+ displayName: 'Device Name or ID',
70
+ name: 'device',
71
+ type: 'options',
72
+ required: true,
73
+ default: '',
74
+ typeOptions: {
75
+ loadOptionsMethod: 'getDevices',
76
+ },
77
+ displayOptions: {
78
+ show: {
79
+ resource: ['campaigns'],
80
+ operation: ['createCampaign'],
81
+ },
82
+ },
83
+ description: 'WhatsApp device to use for sending messages',
84
+ },
85
+ {
86
+ displayName: 'Message Type',
87
+ name: 'messageType',
88
+ type: 'options',
89
+ options: [
90
+ { name: 'Text', value: 'text' },
91
+ { name: 'Template', value: 'template' },
92
+ ],
93
+ required: true,
94
+ default: 'text',
95
+ displayOptions: {
96
+ show: {
97
+ resource: ['campaigns'],
98
+ operation: ['createCampaign'],
99
+ },
100
+ },
101
+ description: 'Type of message to send',
102
+ },
103
+ {
104
+ displayName: 'Message',
105
+ name: 'message',
106
+ type: 'string',
107
+ required: true,
108
+ displayOptions: {
109
+ show: {
110
+ resource: ['campaigns'],
111
+ operation: ['createCampaign'],
112
+ messageType: ['text'],
113
+ },
114
+ },
115
+ default: '',
116
+ typeOptions: {
117
+ rows: 5,
118
+ },
119
+ description: 'Text message to send',
120
+ },
121
+ {
122
+ displayName: 'Template Name',
123
+ name: 'templateName',
124
+ type: 'options',
125
+ required: true,
126
+ default: '',
127
+ typeOptions: {
128
+ loadOptionsMethod: 'getTemplates',
129
+ loadOptionsDependsOn: ['device'],
130
+ },
131
+ displayOptions: {
132
+ show: {
133
+ resource: ['campaigns'],
134
+ operation: ['createCampaign'],
135
+ messageType: ['template'],
136
+ },
137
+ },
138
+ description: 'Select a WABA template',
139
+ },
140
+ {
141
+ displayName: 'Language',
142
+ name: 'language',
143
+ type: 'string',
144
+ required: true,
145
+ displayOptions: {
146
+ show: {
147
+ resource: ['campaigns'],
148
+ operation: ['createCampaign'],
149
+ messageType: ['template'],
150
+ },
151
+ },
152
+ default: 'en',
153
+ description: 'Template language code',
154
+ },
155
+ {
156
+ displayName: 'Components (JSON)',
157
+ name: 'components',
158
+ type: 'json',
159
+ displayOptions: {
160
+ show: {
161
+ resource: ['campaigns'],
162
+ operation: ['createCampaign'],
163
+ messageType: ['template'],
164
+ },
165
+ },
166
+ default: '[]',
167
+ description: 'Template variable components',
168
+ },
169
+ {
170
+ displayName: 'Scheduled At',
171
+ name: 'scheduledAt',
172
+ type: 'dateTime',
173
+ displayOptions: {
174
+ show: {
175
+ resource: ['campaigns'],
176
+ operation: ['createCampaign'],
177
+ },
178
+ },
179
+ default: '',
180
+ description: 'Schedule campaign for a future date',
181
+ },
182
+ {
183
+ displayName: 'Group ID',
184
+ name: 'group',
185
+ type: 'options',
186
+ typeOptions: {
187
+ loadOptionsMethod: 'getGroups',
188
+ loadOptionsDependsOn: ['device'],
189
+ },
190
+ displayOptions: {
191
+ show: {
192
+ resource: ['campaigns'],
193
+ operation: ['createCampaign'],
194
+ },
195
+ },
196
+ default: '',
197
+ description: 'Target contact group',
198
+ },
199
+ {
200
+ displayName: 'Phone Numbers',
201
+ name: 'numbers',
202
+ type: 'string',
203
+ displayOptions: {
204
+ show: {
205
+ resource: ['campaigns'],
206
+ operation: ['createCampaign'],
207
+ },
208
+ },
209
+ default: '',
210
+ description: 'Comma-separated list of phone numbers',
211
+ },
45
212
  // GET CAMPAIGNS OPTIONS
46
213
  {
47
214
  displayName: 'Filters',
@@ -321,6 +488,55 @@ async function executeCampaignOperations(index) {
321
488
  }
322
489
  return (0, request_1.request)(this, 'GET', '/campaigns', undefined, queryParameters);
323
490
  }
491
+ // CREATE CAMPAIGN
492
+ if (operation === 'createCampaign') {
493
+ const name = this.getNodeParameter('name', index);
494
+ const device = this.getNodeParameter('device', index);
495
+ const messageType = this.getNodeParameter('messageType', index);
496
+ const scheduledAt = this.getNodeParameter('scheduledAt', index);
497
+ const group = this.getNodeParameter('group', index);
498
+ const numbersStr = this.getNodeParameter('numbers', index);
499
+ const body = {
500
+ name,
501
+ device,
502
+ };
503
+ if (scheduledAt) {
504
+ body.scheduledAt = scheduledAt;
505
+ }
506
+ if (numbersStr) {
507
+ body.numbers = numbersStr.split(',').map((n) => n.trim()).filter((n) => n);
508
+ }
509
+ if (group) {
510
+ body.group = group;
511
+ }
512
+ if (messageType === 'template') {
513
+ const templateName = this.getNodeParameter('templateName', index);
514
+ const language = this.getNodeParameter('language', index);
515
+ const componentsJson = this.getNodeParameter('components', index);
516
+ let components = [];
517
+ if (typeof componentsJson === 'string') {
518
+ try {
519
+ components = JSON.parse(componentsJson);
520
+ }
521
+ catch (e) {
522
+ throw new Error('Invalid JSON for components');
523
+ }
524
+ }
525
+ else {
526
+ components = componentsJson;
527
+ }
528
+ body.template = {
529
+ name: templateName,
530
+ language: { code: language },
531
+ components,
532
+ };
533
+ }
534
+ else {
535
+ const message = this.getNodeParameter('message', index);
536
+ body.message = message;
537
+ }
538
+ return (0, request_1.request)(this, 'POST', '/campaigns', body);
539
+ }
324
540
  // GET CAMPAIGN
325
541
  if (operation === 'getCampaign') {
326
542
  const campaignId = this.getNodeParameter('campaignId', index);
@@ -353,4 +569,3 @@ async function executeCampaignOperations(index) {
353
569
  }
354
570
  throw new Error(`The operation "${operation}" is not supported for campaigns!`);
355
571
  }
356
- exports.executeCampaignOperations = executeCampaignOperations;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executeCatalogOperations = exports.catalogProperties = void 0;
3
+ exports.catalogProperties = void 0;
4
+ exports.executeCatalogOperations = executeCatalogOperations;
4
5
  const request_1 = require("../request");
5
6
  exports.catalogProperties = [
6
7
  {
@@ -143,4 +144,3 @@ async function executeCatalogOperations(index) {
143
144
  }
144
145
  throw new Error(`The operation "${operation}" is not supported for catalog!`);
145
146
  }
146
- exports.executeCatalogOperations = executeCatalogOperations;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executeChannelOperations = exports.channelProperties = void 0;
3
+ exports.channelProperties = void 0;
4
+ exports.executeChannelOperations = executeChannelOperations;
4
5
  const request_1 = require("../request");
5
6
  const countries_1 = require("../constants/countries");
6
7
  exports.channelProperties = [
@@ -584,4 +585,3 @@ async function executeChannelOperations(index) {
584
585
  }
585
586
  throw new Error(`The operation "${operation}" is not supported for channels!`);
586
587
  }
587
- exports.executeChannelOperations = executeChannelOperations;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executeChatContactOperations = exports.chatContactProperties = void 0;
3
+ exports.chatContactProperties = void 0;
4
+ exports.executeChatContactOperations = executeChatContactOperations;
4
5
  const request_1 = require("../request");
5
6
  const countries_1 = require("../constants/countries");
6
7
  exports.chatContactProperties = [
@@ -932,4 +933,3 @@ async function executeChatContactOperations(index) {
932
933
  }
933
934
  throw new Error(`The operation "${operation}" is not supported for chat contacts!`);
934
935
  }
935
- exports.executeChatContactOperations = executeChatContactOperations;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executeChatFileOperations = exports.chatFileProperties = void 0;
3
+ exports.chatFileProperties = void 0;
4
+ exports.executeChatFileOperations = executeChatFileOperations;
4
5
  const request_1 = require("../request");
5
6
  exports.chatFileProperties = [
6
7
  {
@@ -221,4 +222,3 @@ async function executeChatFileOperations(index) {
221
222
  }
222
223
  throw new Error(`The operation "${operation}" is not supported for chat files!`);
223
224
  }
224
- exports.executeChatFileOperations = executeChatFileOperations;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executeChatMessageOperations = exports.chatMessageProperties = void 0;
3
+ exports.chatMessageProperties = void 0;
4
+ exports.executeChatMessageOperations = executeChatMessageOperations;
4
5
  const request_1 = require("../request");
5
6
  exports.chatMessageProperties = [
6
7
  {
@@ -379,4 +380,3 @@ async function executeChatMessageOperations(index) {
379
380
  }
380
381
  throw new Error(`The operation "${operation}" is not supported for chat messages!`);
381
382
  }
382
- exports.executeChatMessageOperations = executeChatMessageOperations;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executeChatOperations = exports.chatProperties = void 0;
3
+ exports.chatProperties = void 0;
4
+ exports.executeChatOperations = executeChatOperations;
4
5
  const request_1 = require("../request");
5
6
  exports.chatProperties = [
6
7
  {
@@ -1189,4 +1190,3 @@ async function executeChatOperations(index) {
1189
1190
  }
1190
1191
  throw new Error(`The operation "${operation}" is not supported for chats!`);
1191
1192
  }
1192
- exports.executeChatOperations = executeChatOperations;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executeDepartmentOperations = exports.departmentProperties = void 0;
3
+ exports.departmentProperties = void 0;
4
+ exports.executeDepartmentOperations = executeDepartmentOperations;
4
5
  const request_1 = require("../request");
5
6
  exports.departmentProperties = [
6
7
  {
@@ -441,4 +442,3 @@ async function executeDepartmentOperations(index) {
441
442
  }
442
443
  throw new Error(`The operation "${operation}" is not supported for departments!`);
443
444
  }
444
- exports.executeDepartmentOperations = executeDepartmentOperations;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executeGroupOperations = exports.groupProperties = void 0;
3
+ exports.groupProperties = void 0;
4
+ exports.executeGroupOperations = executeGroupOperations;
4
5
  const request_1 = require("../request");
5
6
  exports.groupProperties = [
6
7
  {
@@ -774,4 +775,3 @@ async function executeGroupOperations(index) {
774
775
  }
775
776
  throw new Error(`The operation "${operation}" is not supported for groups!`);
776
777
  }
777
- exports.executeGroupOperations = executeGroupOperations;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executeLabelOperations = exports.labelProperties = void 0;
3
+ exports.labelProperties = void 0;
4
+ exports.executeLabelOperations = executeLabelOperations;
4
5
  const request_1 = require("../request");
5
6
  exports.labelProperties = [
6
7
  {
@@ -163,4 +164,3 @@ async function executeLabelOperations(index) {
163
164
  }
164
165
  throw new Error(`The operation "${operation}" is not supported for labels!`);
165
166
  }
166
- exports.executeLabelOperations = executeLabelOperations;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executeMeetingLinkOperations = exports.meetingLinkProperties = void 0;
3
+ exports.meetingLinkProperties = void 0;
4
+ exports.executeMeetingLinkOperations = executeMeetingLinkOperations;
4
5
  const request_1 = require("../request");
5
6
  exports.meetingLinkProperties = [
6
7
  {
@@ -387,4 +388,3 @@ async function executeMeetingLinkOperations(index) {
387
388
  }
388
389
  throw new Error(`The operation "${operation}" is not supported for meeting links!`);
389
390
  }
390
- exports.executeMeetingLinkOperations = executeMeetingLinkOperations;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executeNumberOperations = exports.numberProperties = void 0;
3
+ exports.numberProperties = void 0;
4
+ exports.executeNumberOperations = executeNumberOperations;
4
5
  const request_1 = require("../request");
5
6
  exports.numberProperties = [
6
7
  {
@@ -536,4 +537,3 @@ async function executeNumberOperations(index) {
536
537
  }
537
538
  throw new Error(`The operation "${operation}" is not supported for WhatsApp numbers!`);
538
539
  }
539
- exports.executeNumberOperations = executeNumberOperations;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executeOtherOperations = exports.otherProperties = void 0;
3
+ exports.otherProperties = void 0;
4
+ exports.executeOtherOperations = executeOtherOperations;
4
5
  const request_1 = require("../request");
5
6
  const countries_1 = require("../constants/countries");
6
7
  exports.otherProperties = [
@@ -304,4 +305,3 @@ async function executeOtherOperations(itemIndex) {
304
305
  }
305
306
  throw new Error(`Unsupported operation: ${operation}`);
306
307
  }
307
- exports.executeOtherOperations = executeOtherOperations;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executeOutboundFileOperations = exports.outboundFileProperties = void 0;
3
+ exports.outboundFileProperties = void 0;
4
+ exports.executeOutboundFileOperations = executeOutboundFileOperations;
4
5
  const request_1 = require("../request");
5
6
  exports.outboundFileProperties = [
6
7
  {
@@ -777,4 +778,3 @@ async function executeOutboundFileOperations(index) {
777
778
  }
778
779
  throw new Error(`The operation "${operation}" is not supported for outbound files!`);
779
780
  }
780
- exports.executeOutboundFileOperations = executeOutboundFileOperations;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executeOutboundMessageOperations = exports.outboundMessageProperties = void 0;
3
+ exports.outboundMessageProperties = void 0;
4
+ exports.executeOutboundMessageOperations = executeOutboundMessageOperations;
4
5
  const request_1 = require("../request");
5
6
  exports.outboundMessageProperties = [
6
7
  {
@@ -548,4 +549,3 @@ async function executeOutboundMessageOperations(index) {
548
549
  }
549
550
  throw new Error(`The operation "${operation}" is not supported for outbound messages!`);
550
551
  }
551
- exports.executeOutboundMessageOperations = executeOutboundMessageOperations;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executeProfileOperations = exports.profileProperties = void 0;
3
+ exports.profileProperties = void 0;
4
+ exports.executeProfileOperations = executeProfileOperations;
4
5
  const request_1 = require("../request");
5
6
  exports.profileProperties = [
6
7
  {
@@ -342,4 +343,3 @@ async function executeProfileOperations(index) {
342
343
  }
343
344
  throw new Error(`The operation "${operation}" is not supported for profile!`);
344
345
  }
345
- exports.executeProfileOperations = executeProfileOperations;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executeQueueOperations = exports.queueProperties = void 0;
3
+ exports.queueProperties = void 0;
4
+ exports.executeQueueOperations = executeQueueOperations;
4
5
  const request_1 = require("../request");
5
6
  exports.queueProperties = [
6
7
  {
@@ -300,4 +301,3 @@ async function executeQueueOperations(index) {
300
301
  }
301
302
  throw new Error(`The operation "${operation}" is not supported for queue!`);
302
303
  }
303
- exports.executeQueueOperations = executeQueueOperations;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executeQuickReplyOperations = exports.quickReplyProperties = void 0;
3
+ exports.quickReplyProperties = void 0;
4
+ exports.executeQuickReplyOperations = executeQuickReplyOperations;
4
5
  const request_1 = require("../request");
5
6
  exports.quickReplyProperties = [
6
7
  {
@@ -422,4 +423,3 @@ async function executeQuickReplyOperations(index) {
422
423
  }
423
424
  throw new Error(`The operation "${operation}" is not supported for quick replies!`);
424
425
  }
425
- exports.executeQuickReplyOperations = executeQuickReplyOperations;