n8n-nodes-pilot-status 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/README.md
CHANGED
|
@@ -68,7 +68,7 @@ Webhook payload notes:
|
|
|
68
68
|
The **Pilot Status** node provides several resources and operations to manage your account and send messages.
|
|
69
69
|
|
|
70
70
|
### 1. Message
|
|
71
|
-
- **Send:** Send a template message (OTP, Utility, or Marketing).
|
|
71
|
+
- **Send:** Send a template message (OTP, Utility, or Marketing). Choose **Phone Number** or **WhatsApp Group**; for groups use `groupId` (JID ending in `@g.us`) instead of `destinationNumber`. Optional dropdown loads groups from `GET /v1/groups` when the WhatsApp session is connected. Variables can be provided via JSON or the UI collection (including placeholders used in button labels).
|
|
72
72
|
- **Get Status:** Retrieve the current status of a specific message using either its Pilot Status message id or WhatsApp provider id.
|
|
73
73
|
- **Check Opt-In:** Check if a specific destination number has opted in to receive messages from your project (required for LIVE environments when using the Pilot Status shared number).
|
|
74
74
|
|
|
@@ -4,6 +4,8 @@ export declare class PilotStatus implements INodeType {
|
|
|
4
4
|
loadOptions: {
|
|
5
5
|
getTemplates(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
6
6
|
getTemplateVariables(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
7
|
+
getGroups(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
8
|
+
getNewsletters(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
7
9
|
};
|
|
8
10
|
};
|
|
9
11
|
description: INodeTypeDescription;
|
|
@@ -37,6 +37,42 @@ class PilotStatus {
|
|
|
37
37
|
const vars = (_b = (_a = response === null || response === void 0 ? void 0 : response.latestVersion) === null || _a === void 0 ? void 0 : _a.variables) !== null && _b !== void 0 ? _b : [];
|
|
38
38
|
return Array.isArray(vars) ? vars.map((v) => ({ name: v, value: v })) : [];
|
|
39
39
|
},
|
|
40
|
+
async getGroups() {
|
|
41
|
+
try {
|
|
42
|
+
const response = (await this.helpers.requestWithAuthentication.call(this, 'pilotStatusApi', {
|
|
43
|
+
method: 'GET',
|
|
44
|
+
baseURL: 'https://pilotstatus.online/v1',
|
|
45
|
+
url: '/groups',
|
|
46
|
+
json: true,
|
|
47
|
+
}));
|
|
48
|
+
const groups = Array.isArray(response === null || response === void 0 ? void 0 : response.groups) ? response.groups : [];
|
|
49
|
+
return groups.map((g) => ({
|
|
50
|
+
name: g.name ? `${g.name} (${g.id})` : g.id,
|
|
51
|
+
value: g.id,
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
async getNewsletters() {
|
|
59
|
+
try {
|
|
60
|
+
const response = (await this.helpers.requestWithAuthentication.call(this, 'pilotStatusApi', {
|
|
61
|
+
method: 'GET',
|
|
62
|
+
baseURL: 'https://pilotstatus.online/v1',
|
|
63
|
+
url: '/newsletters',
|
|
64
|
+
json: true,
|
|
65
|
+
}));
|
|
66
|
+
const newsletters = Array.isArray(response === null || response === void 0 ? void 0 : response.newsletters) ? response.newsletters : [];
|
|
67
|
+
return newsletters.map((n) => ({
|
|
68
|
+
name: n.name ? `${n.name} (${n.id})` : n.id,
|
|
69
|
+
value: n.id,
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
},
|
|
40
76
|
},
|
|
41
77
|
};
|
|
42
78
|
this.description = {
|
|
@@ -102,6 +138,38 @@ class PilotStatus {
|
|
|
102
138
|
preSend: [
|
|
103
139
|
async function (requestOptions) {
|
|
104
140
|
var _a, _b;
|
|
141
|
+
const destinationType = this.getNodeParameter('sendDestinationType') || 'phone';
|
|
142
|
+
if (!requestOptions.body || typeof requestOptions.body !== 'object') {
|
|
143
|
+
requestOptions.body = {};
|
|
144
|
+
}
|
|
145
|
+
const body = requestOptions.body;
|
|
146
|
+
if (destinationType === 'group') {
|
|
147
|
+
delete body.destinationNumber;
|
|
148
|
+
delete body.newsletterId;
|
|
149
|
+
const gid = body.groupId;
|
|
150
|
+
const gidStr = typeof gid === 'string' ? gid.trim() : '';
|
|
151
|
+
if (!gidStr || !gidStr.endsWith('@g.us')) {
|
|
152
|
+
throw new Error('Pilot Status: informe um Group ID válido (JID terminando em @g.us) ao enviar para grupo.');
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
else if (destinationType === 'newsletter') {
|
|
156
|
+
delete body.destinationNumber;
|
|
157
|
+
delete body.groupId;
|
|
158
|
+
const nid = body.newsletterId;
|
|
159
|
+
const nidStr = typeof nid === 'string' ? nid.trim() : '';
|
|
160
|
+
if (!nidStr || !nidStr.toLowerCase().endsWith('@newsletter')) {
|
|
161
|
+
throw new Error('Pilot Status: informe um Newsletter ID válido (JID terminando em @newsletter) ao enviar para canal.');
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
delete body.groupId;
|
|
166
|
+
delete body.newsletterId;
|
|
167
|
+
const dest = body.destinationNumber;
|
|
168
|
+
const destStr = typeof dest === 'string' ? dest.trim() : '';
|
|
169
|
+
if (!destStr) {
|
|
170
|
+
throw new Error('Pilot Status: informe destinationNumber (E.164) ao enviar para telefone.');
|
|
171
|
+
}
|
|
172
|
+
}
|
|
105
173
|
const mode = this.getNodeParameter('variablesMode');
|
|
106
174
|
let variables = {};
|
|
107
175
|
if (mode === 'json') {
|
|
@@ -173,16 +241,61 @@ class PilotStatus {
|
|
|
173
241
|
required: true,
|
|
174
242
|
routing: { send: { type: 'body', property: 'templateId' } },
|
|
175
243
|
},
|
|
244
|
+
{
|
|
245
|
+
displayName: 'Send To',
|
|
246
|
+
name: 'sendDestinationType',
|
|
247
|
+
type: 'options',
|
|
248
|
+
noDataExpression: true,
|
|
249
|
+
options: [
|
|
250
|
+
{ name: 'Phone Number (E.164)', value: 'phone' },
|
|
251
|
+
{ name: 'WhatsApp Group', value: 'group' },
|
|
252
|
+
{ name: 'Newsletter (channel)', value: 'newsletter' },
|
|
253
|
+
],
|
|
254
|
+
default: 'phone',
|
|
255
|
+
displayOptions: { show: { resource: ['message'], operation: ['send'] } },
|
|
256
|
+
},
|
|
176
257
|
{
|
|
177
258
|
displayName: 'Destination Number',
|
|
178
259
|
name: 'destinationNumber',
|
|
179
260
|
type: 'string',
|
|
180
261
|
description: 'E.164 format (e.g. +5511999999999)',
|
|
181
|
-
displayOptions: {
|
|
262
|
+
displayOptions: {
|
|
263
|
+
show: { resource: ['message'], operation: ['send', 'checkOptIn'] },
|
|
264
|
+
hide: {
|
|
265
|
+
operation: ['send'],
|
|
266
|
+
sendDestinationType: ['group', 'newsletter'],
|
|
267
|
+
},
|
|
268
|
+
},
|
|
182
269
|
default: '',
|
|
183
270
|
required: true,
|
|
184
271
|
routing: { send: { type: 'body', property: 'destinationNumber' } },
|
|
185
272
|
},
|
|
273
|
+
{
|
|
274
|
+
displayName: 'Group ID',
|
|
275
|
+
name: 'groupId',
|
|
276
|
+
type: 'options',
|
|
277
|
+
typeOptions: { loadOptionsMethod: 'getGroups' },
|
|
278
|
+
displayOptions: {
|
|
279
|
+
show: { resource: ['message'], operation: ['send'], sendDestinationType: ['group'] },
|
|
280
|
+
},
|
|
281
|
+
default: '',
|
|
282
|
+
required: true,
|
|
283
|
+
description: 'JID do grupo (@g.us). Lista via GET /v1/groups; também pode usar expressão n8n.',
|
|
284
|
+
routing: { send: { type: 'body', property: 'groupId' } },
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
displayName: 'Newsletter ID',
|
|
288
|
+
name: 'newsletterId',
|
|
289
|
+
type: 'options',
|
|
290
|
+
typeOptions: { loadOptionsMethod: 'getNewsletters' },
|
|
291
|
+
displayOptions: {
|
|
292
|
+
show: { resource: ['message'], operation: ['send'], sendDestinationType: ['newsletter'] },
|
|
293
|
+
},
|
|
294
|
+
default: '',
|
|
295
|
+
required: true,
|
|
296
|
+
description: 'JID do canal (@newsletter). Lista via GET /v1/newsletters; também pode usar expressão n8n.',
|
|
297
|
+
routing: { send: { type: 'body', property: 'newsletterId' } },
|
|
298
|
+
},
|
|
186
299
|
{
|
|
187
300
|
displayName: 'Variables Mode',
|
|
188
301
|
name: 'variablesMode',
|