n8n-nodes-pilot-status 2.16.0 → 2.18.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,38 @@
2
2
 
3
3
  All notable changes to `n8n-nodes-pilot-status`.
4
4
 
5
+ ## 2.18.0 - 2026-11-23
6
+
7
+ ### Fixed
8
+
9
+ - **Trigger on official (Meta Cloud API) numbers.** Those numbers forward Meta's native
10
+ envelope `{ object, entry }`, which has no `event` field, so a Trigger set to any
11
+ specific event answered `200 Ignored event` to every delivery and never ran. The
12
+ Trigger now matches the selected event against `entry[0].changes[0].field` too.
13
+ - **Automatic registration no longer creates a silent webhook.** The API filters
14
+ `events` down to what the number can emit, so `message.reply` on an official number
15
+ was stored as `[]` and delivered nothing. Activation now fails with an explanation and
16
+ deletes that empty webhook.
17
+
18
+ ### Added
19
+
20
+ - Trigger event **Meta: Messages (Official Numbers)** (`messages`).
21
+
22
+ ### Changed
23
+
24
+ - Credential field descriptions name the three key kinds (number `ps_number_`, workspace
25
+ `ps_workspace_`, account `ps_account_`) and which fields each one needs.
26
+
27
+ ## 2.17.0 - 2026-11-11
28
+
29
+ ### Added
30
+
31
+ - **Story → Create: "Deliver At"** (dateTime, optional) — schedules the story; sent as
32
+ `deliverAt` (normalized to ISO-8601 UTC). Past/now sends immediately; the Media URL is
33
+ downloaded at send time; billed only when it goes out.
34
+ - Story → Delete documents cancelling a scheduled story → `{ id, canceledAt }` (status
35
+ `CANCELED`, never billed). Story → Get documents `deliverAt`.
36
+
5
37
  ## 2.16.0 - 2026-11-10
6
38
 
7
39
  ### Added
package/README.md CHANGED
@@ -72,6 +72,7 @@ The secret is returned in clear **once**: in the `201` of the create (`POST /v1/
72
72
  - **Message Failed** (`message.failed`): Triggered if the message fails to send (includes error details).
73
73
  - **Message Reply** (`message.reply`): Triggered when a user replies specifically to an automated message.
74
74
  - **Message Received** (`message.received`): Triggered when a general inbound message is received on your connected WhatsApp number.
75
+ - **Meta: Messages (Official Numbers)** (`messages`): Meta Cloud API numbers only. Official numbers never send the canonical message events: they forward Meta's native envelope `{ object, entry }`, named by the webhook field in `entry[0].changes[0].field`. This event fires on that envelope (inbound messages, button taps and delivery statuses). Since 2.18.0 a specific event is matched against that field too, and Automatic registration fails at activation (deleting the webhook) when the API stores an event list without the selected event.
75
76
  - **Group Message** (`message.group`): Triggered when an inbound group message is received (group subject is included when available).
76
77
  - **Newsletter Message** (`message.newsletter`): Triggered when an inbound WhatsApp channel / newsletter message is received.
77
78
  - **Number Created / Connected / Disconnected / Removed / Restored** (`number.created`, `number.connected`, `number.disconnected`, `number.removed`, `number.restored`): Lifecycle of a WhatsApp number in your account. `number.restored` means a deleted number was brought back within its 30-day window — it returns disconnected and must be reconnected. Every `number.*` body carries a top-level `id` (UUID), the same on every retry or replay of that event — deduplicate on it; `number.connected` also carries `data.connectedAt` (ISO 8601, when the connection was established).
@@ -7,7 +7,7 @@ export declare const DEFAULT_BASE_URL = "https://pilotstatus.com.br";
7
7
  * `/v1` callers by User-Agent and recognises this node only when the header STARTS
8
8
  * with `pilot-status-n8n/<version>`; without it n8n would send its generic `n8n`.
9
9
  */
10
- export declare const USER_AGENT = "pilot-status-n8n/2.16.0";
10
+ export declare const USER_AGENT = "pilot-status-n8n/2.18.0";
11
11
  export declare class PilotStatusApi implements ICredentialType {
12
12
  name: string;
13
13
  displayName: string;
@@ -26,7 +26,7 @@ class PilotStatusApi {
26
26
  },
27
27
  default: '',
28
28
  required: true,
29
- description: 'API Key can be found in Pilot Status Dashboard -> API Keys',
29
+ description: 'A number key (ps_number_…, dashboard → API Keys), a workspace key (ps_workspace_…, dashboard → Workspace keys) or an account key (ps_account_…, Profile → API). Number key: leave the two fields below empty. Workspace key: fill WhatsApp Number ID. Account key: fill both.',
30
30
  },
31
31
  {
32
32
  displayName: 'Base URL',
@@ -42,7 +42,7 @@ class PilotStatusApi {
42
42
  type: 'string',
43
43
  default: '',
44
44
  required: false,
45
- description: 'Sent as x-whatsapp-number-id on every request. Required when the key is tenant-scoped and the operation is per-number (Chatwoot, webhook logs); leave empty for a number-scoped key, which already carries its number.',
45
+ description: 'Sent as x-whatsapp-number-id on every request. Required with a WORKSPACE or ACCOUNT key for anything that acts on one number (sending, logs, templates, webhooks, Trigger Automatic registration) — without it those calls answer 403 TENANT_SCOPE_NOT_ALLOWED or 400 NUMBER_REQUIRED. Leave empty for a number key (ps_number_…), which already carries its number. The id comes from Number → Get Many.',
46
46
  },
47
47
  {
48
48
  displayName: 'Workspace ID',
@@ -1 +1 @@
1
- export declare const PACKAGE_VERSION = "2.16.0";
1
+ export declare const PACKAGE_VERSION = "2.18.0";
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PACKAGE_VERSION = void 0;
4
4
  // GENERATED by scripts/write-version.cjs from package.json — do not edit by hand.
5
- exports.PACKAGE_VERSION = "2.16.0";
5
+ exports.PACKAGE_VERSION = "2.18.0";
@@ -103,7 +103,9 @@ export declare const STORY_FONT_OPTIONS: INodePropertyOptions[];
103
103
  * Story → Create: builds the WHOLE `POST /v1/stories` body. The route refuses unknown
104
104
  * fields (400), so only the fields of the chosen type are sent, and blanks are dropped
105
105
  * (the API then applies its defaults). Recipients: a comma-separated string or an array,
106
- * trimmed, `+` stripped, deduped; empty = the device privacy settings decide. The optional
106
+ * trimmed, `+` stripped, deduped; empty = the device privacy settings decide. "Deliver At"
107
+ * (optional) goes out as `deliverAt`, normalized with `new Date(...).toISOString()` like the
108
+ * message send; an unparseable value is sent as typed so the API answers 400. The optional
107
109
  * Idempotency Key goes out as the `Idempotency-Key` HEADER; blank = not sent.
108
110
  */
109
111
  export declare function storyCreatePreSend(this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions>;
@@ -320,7 +320,9 @@ exports.STORY_FONT_OPTIONS = [
320
320
  * Story → Create: builds the WHOLE `POST /v1/stories` body. The route refuses unknown
321
321
  * fields (400), so only the fields of the chosen type are sent, and blanks are dropped
322
322
  * (the API then applies its defaults). Recipients: a comma-separated string or an array,
323
- * trimmed, `+` stripped, deduped; empty = the device privacy settings decide. The optional
323
+ * trimmed, `+` stripped, deduped; empty = the device privacy settings decide. "Deliver At"
324
+ * (optional) goes out as `deliverAt`, normalized with `new Date(...).toISOString()` like the
325
+ * message send; an unparseable value is sent as typed so the API answers 400. The optional
324
326
  * Idempotency Key goes out as the `Idempotency-Key` HEADER; blank = not sent.
325
327
  */
326
328
  async function storyCreatePreSend(requestOptions) {
@@ -359,6 +361,11 @@ async function storyCreatePreSend(requestOptions) {
359
361
  ];
360
362
  if (recipients.length)
361
363
  body.recipients = recipients;
364
+ const deliverAt = str('storyDeliverAt');
365
+ if (deliverAt) {
366
+ const parsed = new Date(deliverAt);
367
+ body.deliverAt = Number.isNaN(parsed.getTime()) ? deliverAt : parsed.toISOString();
368
+ }
362
369
  requestOptions.body = body;
363
370
  const key = str('storyIdempotencyKey');
364
371
  if (key)
@@ -4455,7 +4462,7 @@ class PilotStatus {
4455
4462
  {
4456
4463
  name: 'Create',
4457
4464
  value: 'create',
4458
- description: 'Post a story (WhatsApp status) from the credential\'s number: text, image or video. Answers 202 { id, status: "QUEUED", type, recipients: "explicit" | "privacy" }. Evolution Go numbers only (400 NOT_SUPPORTED_FOR_META / NOT_SUPPORTED_FOR_PROVIDER); disconnected instance → 409 WHATSAPP_INSTANCE_NOT_CONNECTED.',
4465
+ description: 'Post a story (WhatsApp status) from the credential\'s number: text, image or video. Answers 202 { id, status: "QUEUED", type, recipients: "explicit" | "privacy", deliverAt (ISO or null) }. Set Deliver At to schedule it. Evolution Go numbers only (400 NOT_SUPPORTED_FOR_META / NOT_SUPPORTED_FOR_PROVIDER); disconnected instance → 409 WHATSAPP_INSTANCE_NOT_CONNECTED.',
4459
4466
  action: 'Create a story',
4460
4467
  routing: {
4461
4468
  request: { method: 'POST', url: '/stories' },
@@ -4465,7 +4472,7 @@ class PilotStatus {
4465
4472
  {
4466
4473
  name: 'Get',
4467
4474
  value: 'get',
4468
- description: 'Get a story: { id, type, status, caption, recipientsMode, recipientCount, recipients (null while QUEUED or outside retention, then redacted: true), createdAt, sentAt, revokedAt }. An id that is not a story → 404.',
4475
+ description: 'Get a story: { id, type, status, caption, recipientsMode, recipientCount, recipients (null while QUEUED or outside retention, then redacted: true), createdAt, deliverAt (null when immediate), sentAt, revokedAt }. A scheduled story canceled with Delete has status CANCELED. An id that is not a story → 404.',
4469
4476
  action: 'Get a story',
4470
4477
  routing: {
4471
4478
  request: { method: 'GET', url: '=/stories/{{encodeURIComponent($parameter.storyId)}}' },
@@ -4474,7 +4481,7 @@ class PilotStatus {
4474
4481
  {
4475
4482
  name: 'Delete',
4476
4483
  value: 'delete',
4477
- description: 'Revoke a sent (also delivered/read/played) story from the recipients\' devices → { id, revokedAt }. Not sent or already revoked → 409 STORY_NOT_REVOCABLE; more than 24 h after sentAt → 410 STORY_EXPIRED. Not billed.',
4484
+ description: 'Cancel a scheduled story (QUEUED with a future Deliver At) → { id, canceledAt }, status CANCELED, never billed. Revoke a sent (also delivered/read/played) story from the recipients\' devices → { id, revokedAt }. QUEUED and already due (retry once SENT) or already revoked → 409 STORY_NOT_REVOCABLE; more than 24 h after sentAt → 410 STORY_EXPIRED. Not billed.',
4478
4485
  action: 'Delete a story',
4479
4486
  routing: {
4480
4487
  request: { method: 'DELETE', url: '=/stories/{{encodeURIComponent($parameter.storyId)}}' },
@@ -4569,6 +4576,14 @@ class PilotStatus {
4569
4576
  displayOptions: { show: { resource: ['story'], operation: ['create'] } },
4570
4577
  default: '',
4571
4578
  },
4579
+ {
4580
+ displayName: 'Deliver At',
4581
+ name: 'storyDeliverAt',
4582
+ type: 'dateTime',
4583
+ description: 'Optional. Schedule the story (sent as deliverAt, ISO-8601 in UTC). Past/now = sent immediately; no maximum ahead. The Media URL is downloaded at SEND time, so it must still be reachable then. Billed only when it goes out; Delete before then cancels it. Blank = sent now.',
4584
+ displayOptions: { show: { resource: ['story'], operation: ['create'] } },
4585
+ default: '',
4586
+ },
4572
4587
  {
4573
4588
  displayName: 'Idempotency Key',
4574
4589
  name: 'storyIdempotencyKey',
@@ -13,6 +13,16 @@ export declare const DEFAULT_BASE_URL = "https://pilotstatus.com.br";
13
13
  * rejection).
14
14
  */
15
15
  export declare function isValidSignature(rawBody: Buffer, signature: string, secret: string): boolean;
16
+ /**
17
+ * The event name a delivery stands for.
18
+ *
19
+ * A Meta Cloud API (official) number does not send `{ event, data }`: it forwards
20
+ * Meta's native envelope `{ object, entry }`, whose only name is the webhook FIELD
21
+ * in `entry[0].changes[0].field` (`messages`, `message_template_status_update`, ...).
22
+ * Reading `body.event` alone made every Meta delivery look nameless, so a Trigger
23
+ * set to any specific event answered `Ignored event` to all of them and never ran.
24
+ */
25
+ export declare function deliveredEventName(body: unknown): string | undefined;
16
26
  export declare class PilotStatusTrigger implements INodeType {
17
27
  description: INodeTypeDescription;
18
28
  webhookMethods: {
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PilotStatusTrigger = exports.DEFAULT_BASE_URL = exports.SIGNATURE_HEADER = void 0;
4
4
  exports.isValidSignature = isValidSignature;
5
+ exports.deliveredEventName = deliveredEventName;
5
6
  const crypto_1 = require("crypto");
6
7
  /** Header the dispatcher uses to sign every delivery (HMAC-SHA256 hex of the raw body). */
7
8
  exports.SIGNATURE_HEADER = 'x-pilot-status-signature';
@@ -23,6 +24,25 @@ function isValidSignature(rawBody, signature, secret) {
23
24
  return false;
24
25
  return (0, crypto_1.timingSafeEqual)(received, expected);
25
26
  }
27
+ /**
28
+ * The event name a delivery stands for.
29
+ *
30
+ * A Meta Cloud API (official) number does not send `{ event, data }`: it forwards
31
+ * Meta's native envelope `{ object, entry }`, whose only name is the webhook FIELD
32
+ * in `entry[0].changes[0].field` (`messages`, `message_template_status_update`, ...).
33
+ * Reading `body.event` alone made every Meta delivery look nameless, so a Trigger
34
+ * set to any specific event answered `Ignored event` to all of them and never ran.
35
+ */
36
+ function deliveredEventName(body) {
37
+ var _a, _b, _c, _d;
38
+ if (!body || typeof body !== 'object')
39
+ return undefined;
40
+ const b = body;
41
+ if (typeof b.event === 'string')
42
+ return b.event;
43
+ const field = (_d = (_c = (_b = (_a = b.entry) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.changes) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.field;
44
+ return typeof field === 'string' ? field : undefined;
45
+ }
26
46
  /** The credential's `/v1` root, for the auto-registration calls. */
27
47
  async function apiBaseUrl(ctx) {
28
48
  const credentials = (await ctx.getCredentials('pilotStatusApi'));
@@ -112,6 +132,11 @@ class PilotStatusTrigger {
112
132
  name: 'Message Received',
113
133
  value: 'message.received',
114
134
  },
135
+ {
136
+ name: 'Meta: Messages (Official Numbers)',
137
+ value: 'messages',
138
+ description: "Meta Cloud API numbers only: Meta's native envelope { object, entry } for the 'messages' field — inbound messages, button taps and delivery statuses (value.statuses). Official numbers never send message.received / message.reply.",
139
+ },
115
140
  {
116
141
  name: 'Group Message',
117
142
  value: 'message.group',
@@ -251,6 +276,25 @@ class PilotStatusTrigger {
251
276
  }));
252
277
  if (!(created === null || created === void 0 ? void 0 : created.id))
253
278
  return false;
279
+ // The API FILTERS `events` down to what the number's provider can emit
280
+ // instead of rejecting the list: `message.reply` on a Meta number comes
281
+ // back 201 with `events: []`, a subscription that never delivers. Fail
282
+ // the activation loudly and remove the empty webhook instead.
283
+ if (Array.isArray(created.events) && !created.events.includes(event)) {
284
+ try {
285
+ await this.helpers.requestWithAuthentication.call(this, 'pilotStatusApi', {
286
+ method: 'DELETE',
287
+ baseURL: await apiBaseUrl(this),
288
+ url: `/webhooks/${created.id}`,
289
+ json: true,
290
+ });
291
+ }
292
+ catch {
293
+ // Best effort: the error below is what the author must see.
294
+ }
295
+ throw new Error(`Pilot Status: this number cannot emit "${event}", so the webhook would never fire. ` +
296
+ 'Official (Meta Cloud API) numbers send Meta\'s native envelope: pick "Meta: Messages (Official Numbers)" or "All Events".');
297
+ }
254
298
  this.getWorkflowStaticData('node').webhookId = created.id;
255
299
  return true;
256
300
  },
@@ -303,7 +347,7 @@ class PilotStatusTrigger {
303
347
  };
304
348
  }
305
349
  }
306
- if (event !== '*' && bodyData.event !== event) {
350
+ if (event !== '*' && deliveredEventName(bodyData) !== event) {
307
351
  return {
308
352
  webhookResponse: {
309
353
  status: 200,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-pilot-status",
3
- "version": "2.16.0",
3
+ "version": "2.18.0",
4
4
  "description": "n8n node for Pilot Status API",
5
5
  "keywords": [
6
6
  "n8ncommunity",