n8n-nodes-pilot-status 1.0.1 → 1.0.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 CHANGED
@@ -52,6 +52,13 @@ To use it:
52
52
  - **Message Failed:** Triggered if the message fails to send (includes error details).
53
53
  - **Message Reply:** Triggered when a user replies specifically to an automated message.
54
54
  - **Message Received:** Triggered when a general inbound message is received on your connected WhatsApp number.
55
+ - **Group Message:** Triggered when an inbound group message is received (group subject is included when available).
56
+ - **Opt-in Created:** Triggered when an opt-in is recorded (consent message received by the Pilot Status number).
57
+
58
+ Webhook payload notes:
59
+ - Customer webhook payloads do not include: `projectSlug`, `lastMessageId`, `correlationId`.
60
+ - `message.received` includes `fromMe` (boolean).
61
+ - For outbound status events (`message.sent`, `message.delivered`, `message.read`, `message.failed`): `messageId` is the WhatsApp provider id (may be `null`) and `internalMessageId` is the Pilot Status message id.
55
62
 
56
63
  ---
57
64
 
@@ -61,7 +68,7 @@ The **Pilot Status** node provides several resources and operations to manage yo
61
68
 
62
69
  ### 1. Message
63
70
  - **Send:** Send a template message (OTP, Utility, or Marketing). You can provide variables dynamically via JSON and even schedule the message (`deliverAt`).
64
- - **Get Status:** Retrieve the current status of a specific message using its `messageId`.
71
+ - **Get Status:** Retrieve the current status of a specific message using either its Pilot Status message id or WhatsApp provider id.
65
72
  - **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).
66
73
 
67
74
  ### 2. Number
@@ -1,4 +1,10 @@
1
- import { INodeType, INodeTypeDescription } from 'n8n-workflow';
1
+ import { ILoadOptionsFunctions, INodePropertyOptions, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
2
  export declare class PilotStatus implements INodeType {
3
+ methods: {
4
+ loadOptions: {
5
+ getTemplates(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
6
+ getTemplateVariables(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
7
+ };
8
+ };
3
9
  description: INodeTypeDescription;
4
10
  }
@@ -3,6 +3,42 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PilotStatus = void 0;
4
4
  class PilotStatus {
5
5
  constructor() {
6
+ this.methods = {
7
+ loadOptions: {
8
+ async getTemplates() {
9
+ const response = (await this.helpers.requestWithAuthentication.call(this, 'pilotStatusApi', {
10
+ method: 'GET',
11
+ baseURL: 'https://api.pilotstatus.online/v1',
12
+ url: '/templates',
13
+ json: true,
14
+ }));
15
+ return (response || []).map((t) => {
16
+ var _a;
17
+ return ({
18
+ name: t.name,
19
+ value: t.id,
20
+ description: Array.isArray((_a = t.latestVersion) === null || _a === void 0 ? void 0 : _a.variables)
21
+ ? `Variáveis: ${t.latestVersion.variables.join(', ')}`
22
+ : undefined,
23
+ });
24
+ });
25
+ },
26
+ async getTemplateVariables() {
27
+ var _a, _b;
28
+ const templateId = this.getNodeParameter('templateId', 0);
29
+ if (!templateId)
30
+ return [];
31
+ const response = (await this.helpers.requestWithAuthentication.call(this, 'pilotStatusApi', {
32
+ method: 'GET',
33
+ baseURL: 'https://api.pilotstatus.online/v1',
34
+ url: `/templates/${templateId}`,
35
+ json: true,
36
+ }));
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
+ return Array.isArray(vars) ? vars.map((v) => ({ name: v, value: v })) : [];
39
+ },
40
+ },
41
+ };
6
42
  this.description = {
7
43
  displayName: 'Pilot Status',
8
44
  name: 'pilotStatus',
@@ -119,7 +155,10 @@ class PilotStatus {
119
155
  {
120
156
  displayName: 'Template ID',
121
157
  name: 'templateId',
122
- type: 'string',
158
+ type: 'options',
159
+ typeOptions: {
160
+ loadOptionsMethod: 'getTemplates',
161
+ },
123
162
  displayOptions: {
124
163
  show: {
125
164
  resource: ['message'],
@@ -155,18 +194,59 @@ class PilotStatus {
155
194
  },
156
195
  },
157
196
  },
197
+ {
198
+ displayName: 'Variables',
199
+ name: 'variablesUi',
200
+ type: 'fixedCollection',
201
+ typeOptions: {
202
+ multipleValues: true,
203
+ },
204
+ displayOptions: {
205
+ show: {
206
+ resource: ['message'],
207
+ operation: ['send'],
208
+ },
209
+ },
210
+ default: {},
211
+ description: 'Preencha as variáveis do template selecionado',
212
+ options: [
213
+ {
214
+ name: 'values',
215
+ displayName: 'Variable',
216
+ values: [
217
+ {
218
+ displayName: 'Name',
219
+ name: 'name',
220
+ type: 'options',
221
+ typeOptions: {
222
+ loadOptionsMethod: 'getTemplateVariables',
223
+ loadOptionsDependsOn: ['templateId'],
224
+ },
225
+ default: '',
226
+ required: true,
227
+ },
228
+ {
229
+ displayName: 'Value',
230
+ name: 'value',
231
+ type: 'string',
232
+ default: '',
233
+ required: true,
234
+ },
235
+ ],
236
+ },
237
+ ],
238
+ },
158
239
  {
159
240
  displayName: 'Variables',
160
241
  name: 'variables',
161
- type: 'json',
242
+ type: 'hidden',
162
243
  displayOptions: {
163
244
  show: {
164
245
  resource: ['message'],
165
246
  operation: ['send'],
166
247
  },
167
248
  },
168
- default: '{}',
169
- description: 'Variables for the template as JSON object',
249
+ default: '={{ ($parameter.variablesUi?.values || []).reduce((acc, cur) => { acc[cur.name] = cur.value; return acc; }, {}) }}',
170
250
  routing: {
171
251
  send: {
172
252
  type: 'body',
@@ -193,11 +273,31 @@ class PilotStatus {
193
273
  },
194
274
  },
195
275
  },
276
+ {
277
+ displayName: 'Deliver Until',
278
+ name: 'deliverUntil',
279
+ type: 'dateTime',
280
+ displayOptions: {
281
+ show: {
282
+ resource: ['message'],
283
+ operation: ['send'],
284
+ },
285
+ },
286
+ default: '',
287
+ description: 'Optional expiration limit for the message delivery (ISO8601)',
288
+ routing: {
289
+ send: {
290
+ type: 'body',
291
+ property: 'deliverUntil',
292
+ },
293
+ },
294
+ },
196
295
  // Message: Get Status
197
296
  {
198
297
  displayName: 'Message ID',
199
298
  name: 'messageId',
200
299
  type: 'string',
300
+ description: 'Pilot Status message id or WhatsApp provider id (from customer webhooks messageId)',
201
301
  displayOptions: {
202
302
  show: {
203
303
  resource: ['message'],
@@ -57,6 +57,14 @@ class PilotStatusTrigger {
57
57
  name: 'Message Received',
58
58
  value: 'message.received',
59
59
  },
60
+ {
61
+ name: 'Group Message',
62
+ value: 'message.group',
63
+ },
64
+ {
65
+ name: 'Opt-in Created',
66
+ value: 'optin.created',
67
+ },
60
68
  ],
61
69
  default: '*',
62
70
  description: 'The event to listen to',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-pilot-status",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "n8n node for Pilot Status API",
5
5
  "keywords": [
6
6
  "n8ncommunity",