n8n-nodes-pilot-status 2.7.0 → 2.9.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,41 @@
2
2
 
3
3
  All notable changes to `n8n-nodes-pilot-status`.
4
4
 
5
+ ## 2.9.0 - 2026-10-25
6
+
7
+ ### Added
8
+
9
+ - **Message → Send → Additional Fields → Idempotency Key** (string, optional). Sent as the
10
+ `Idempotency-Key` header, never in the body; blank or left out, the request is unchanged.
11
+ Within 24 hours (per workspace + number + key) the same key with the same body returns the
12
+ stored response of the first accepted (2xx) call and sends nothing again
13
+ (`Idempotent-Replayed: true`); same key + different body → `409 IDEMPOTENCY_KEY_REUSED`;
14
+ first call still running → `409 IDEMPOTENCY_KEY_IN_USE`; invalid key (>255 chars or
15
+ control characters) → `400 IDEMPOTENCY_KEY_INVALID`. Only 2xx responses are remembered,
16
+ so after an error the same key can be retried with corrected input. Map it from your own
17
+ data (e.g. an order id) so that n8n's Retry On Fail reuses it.
18
+
19
+ ## 2.8.0 - 2026-10-20
20
+
21
+ ### Added
22
+
23
+ - **Referral** resource — **Get Many** (`GET /v1/referrals`: Source ID, Source Type,
24
+ Start/End Date, Page, Page Size) and **Summary** (`GET /v1/referrals/summary`: Start/End
25
+ Date). Click-to-WhatsApp ad attribution; acts on one number (`chat:read`).
26
+ - **Ads Summary** resource — **Get** (`GET /v1/ads/summary`: WhatsApp Number ID,
27
+ Start/End Date). Ads volume with names and `leadCount`; `analytics:read`, workspace-wide
28
+ on a workspace key without a number. A resource of its own, not a Referral operation,
29
+ because permission and scope differ.
30
+ - **Ad Account** resource — **Get Many**, **Link** (`act_<digits>`), **Unlink** (soft).
31
+ Workspace key only, `integrations:manage`.
32
+ - **Lead Page** resource — **Get Many**, **Link**, **Update** (move to another number;
33
+ `autoSendDisabled`), **Unlink**, **Resync**. ⚠️ **Unlink is destructive**: it erases
34
+ every lead captured through the Page and its form configurations.
35
+ - **Lead Form** resource — **Get Many** and **Update** (PUT, replaces the whole config;
36
+ empty Consent Checkbox Key / Template ID / Free Text go out as `null`, Variable Map must
37
+ be a JSON object).
38
+ - Empty filters are omitted and dates are sent as ISO 8601 everywhere above.
39
+
5
40
  ## 2.7.0 - 2026-10-19
6
41
 
7
42
  ### Added
package/README.md CHANGED
@@ -90,7 +90,7 @@ Webhook payload notes:
90
90
  The **Pilot Status** node provides several resources and operations to manage your account and send messages.
91
91
 
92
92
  ### 1. Message
93
- - **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). Add **Mark Read** (switched off) under Additional Fields to reply without marking the conversation read — e.g. an AI agent answering while a human should still see it unread; leave it out to follow the number's **Mark Read On Send** setting. Meta Cloud API numbers only (no "typing" indicator either); on Evolution numbers turn off **Read Messages** instead. Note that **Send Typing Indicator** on a Meta number also marks read.
93
+ - **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). Add **Mark Read** (switched off) under Additional Fields to reply without marking the conversation read — e.g. an AI agent answering while a human should still see it unread; leave it out to follow the number's **Mark Read On Send** setting. Meta Cloud API numbers only (no "typing" indicator either); on Evolution numbers turn off **Read Messages** instead. Note that **Send Typing Indicator** on a Meta number also marks read. Add **Idempotency Key** under Additional Fields to make retries safe: it is sent as the `Idempotency-Key` header (never in the body), and within 24 hours the same key with the same body returns the first accepted response instead of sending again (`Idempotent-Replayed: true`). Map it from your own data (e.g. an order id) so a retry reuses it. Same key + different body → `409 IDEMPOTENCY_KEY_REUSED`; first call still running → `409 IDEMPOTENCY_KEY_IN_USE`; invalid key → `400 IDEMPOTENCY_KEY_INVALID`. Only 2xx responses are remembered, so after an error you can fix the input and retry with the same key.
94
94
  - **Get Status:** Retrieve the current status of a specific message using either its Pilot Status message id or WhatsApp provider id.
95
95
  - **Get History:** Read the conversation history of the number, newest first — both directions, every provider, including messages imported from the device on connect. Filters by **Start Date** / **End Date** over the *provider* timestamp (when the message happened, not when it was ingested). This is how you fetch old messages: the webhook does not replay history by default. Requires a number-scoped API key.
96
96
  - **Get Many:** The message **log** — sent and received, with delivery status, newest first. Different from Get History: this is the operational trail (`status`, `errorCode`, `origin`, whether the 24h window was open at send), not the chat thread. Filters: Direction, Status (comma-separated), Page, Page Size. For date/search/template filters use the HTTP Request node.
@@ -149,6 +149,39 @@ Read-only, and requires a **number-scoped API key**: a lead belongs to the numbe
149
149
 
150
150
  Each lead: `{ id, leadgenId, whatsappNumberId, pageId, pageName, formId, formName, adId, adName, adsetName, campaignName, platform, isOrganic, createdAt, fullName, email, phone, fields, consentGiven, conversationId, autoSendStatus, autoSendReason, source, redacted }`, with `fields` as `{ key, label, values }`. ⚠️ `consentGiven: null` means **unknown** (no consent checkbox configured, or not answered) — never read it as a refusal. On a **RELAY_ONLY** number a lead keeps its ids, attribution and status but comes back with `redacted: true` and no name, e-mail, phone or answers, and the response carries `notice: "PII_RELAY_ONLY"`.
151
151
 
152
+ ### 9. Referral (Click-to-WhatsApp ad attribution)
153
+
154
+ Read-only. Acts on **one number**: a number-scoped API key, or a workspace key with **WhatsApp Number ID** set in the credential (sent as `x-whatsapp-number-id`) — without it a workspace key gets `403 TENANT_SCOPE_NOT_ALLOWED`. Needs `chat:read`. In practice only official (Meta Cloud API) numbers have referrals.
155
+
156
+ - **Get Many:** `GET /v1/referrals` — inbound messages that arrived from a Meta ad or post, newest first. Meta attaches the referral to the **first** message of a conversation only, so each row amounts to one conversation started by that ad. Filters: **Source ID** (one ad/post id), **Source Type** (`ad` / `post`), **Start Date** / **End Date** (when the message happened), **Page**, **Page Size** (max 100). Answers `{ referrals, total, page, pageSize, totalPages, notice? }`; each row is a chat message with a `referral` block `{ sourceId, sourceType, sourceUrl, headline, body, mediaType, imageUrl, videoUrl, thumbnailUrl, ctwaClid, adName, adsetId, adsetName, campaignId, campaignName, namesResolvedAt }`.
157
+ - **Summary:** `GET /v1/referrals/summary` — traffic grouped by ad, ordered by conversations. Filters: **Start Date** / **End Date**. Answers `{ ads, total, limit, truncated, notice?, piiNotice? }`, each ad `{ sourceId, sourceType, conversations, messages, firstAt, lastAt, lastSourceUrl, lastHeadline, adName, adsetId, adsetName, campaignId, campaignName, namesResolvedAt }`. ⚠️ `conversations` counts **distinct** conversations (the lead count); `messages` counts messages. Capped at 200 ads: `truncated: true` means a **partial** answer — narrow the dates.
158
+
159
+ `sourceId` is Meta's ad id and the **stable** identity: names are editable in Meta, so never key on them. The campaign / ad set / ad names are filled only when the advertiser has shared the ad account with the Pilot Status business portfolio as a partner; `namesResolvedAt: null` = never resolved, set with names = snapshot at that time, set without names = Meta returned nothing (ad deleted or access missing). On a **RELAY_ONLY** number the ad id and names stay, while `ctwaClid`, the ad copy and the message content come back null with `redacted: true` (Summary: `lastSourceUrl` / `lastHeadline` null, `piiNotice: "PII_RELAY_ONLY"`).
160
+
161
+ ### 10. Ads Summary
162
+
163
+ - **Get:** `GET /v1/ads/summary` — Click-to-WhatsApp volume per ad with the resolved campaign / ad set / ad names and `leadCount` (Meta Lead Ads leads of that ad). Filters: **WhatsApp Number ID**, **Start Date** / **End Date**. Answers `{ ads, total, limit, truncated }`. Needs `analytics:read` (not `chat:read`). A number-scoped key, or a credential with **WhatsApp Number ID**, reports that number; a workspace key without it reports the whole workspace. It is a resource of its own, not an operation of **Referral**, because both the permission and the scope differ.
164
+
165
+ ### 11. Ad Account
166
+
167
+ Workspace (tenant-scoped) API key only, `integrations:manage`. Access to an ad account comes from the advertiser adding the Pilot Status portfolio (`partnerBusinessId`) as a **partner** with `ads_read` in Meta Business Manager — there is no token to enter.
168
+
169
+ - **Get Many:** `GET /v1/ads/accounts` — `{ linked, candidates, partnerBusinessId, sharingLookup }`. `linked[].sharingActive: null` means Meta could not be asked, not "revoked".
170
+ - **Link:** `POST /v1/ads/accounts` with **Ad Account ID** (`act_<digits>`) → `201 { link }`. Refusals: `409 AD_ACCOUNT_NOT_PROVEN`, `409 AD_ACCOUNT_NOT_SHARED`, `502 ADS_LOOKUP_UNAVAILABLE`, `503 ADS_NOT_CONFIGURED`.
171
+ - **Unlink:** `DELETE /v1/ads/accounts/{adAccountId}` → `{ unlinked, adAccountId }`. Soft: names already resolved stay.
172
+
173
+ ### 12. Lead Page and Lead Form (Meta Lead Ads configuration)
174
+
175
+ `integrations:manage`. A credential bound to one number acts on that number's links only (`403 NUMBER_NOT_IN_GRANT` otherwise); a workspace key without one sees them all. Unknown body fields are refused with `400 UNKNOWN_FIELDS`.
176
+
177
+ - **Lead Page → Get Many:** `GET /v1/lead-pages` — `{ linked, candidates, configured, partnerBusinessId, candidatesLookup, eligibilityBlocker }`.
178
+ - **Lead Page → Link:** `POST /v1/lead-pages` with **Facebook Page ID** and **WhatsApp Number ID** (optional only when the credential reaches exactly one number) → `201 { link }`; the last 90 days of leads are backfilled.
179
+ - **Lead Page → Update:** `PATCH /v1/lead-pages/{pageLinkId}` with **New WhatsApp Number ID** → `{ link, autoSendDisabled }`. `autoSendDisabled: true` = every auto-send of the Page's forms was switched off.
180
+ - **Lead Page → Unlink:** `DELETE /v1/lead-pages/{pageLinkId}` → `{ unlinked, pageLinkId, deletedLeads }`. ⚠️ **Destructive:** it erases every lead captured through the Page and deletes its form configurations. There is no undo.
181
+ - **Lead Page → Resync:** `POST /v1/lead-pages/{pageLinkId}/resync` → `202 { started, pageLinkId, subscribedAt?, subscriptionError? }`. Within the cooldown: `429 RESYNC_COOLDOWN` with `retryAfterSeconds`.
182
+ - **Lead Form → Get Many:** `GET /v1/lead-pages/{pageLinkId}/forms` — `{ forms, formsTruncated, numberIsOfficial, templates }`, each form with questions, consent checkboxes and its stored `config` (`null` = never configured).
183
+ - **Lead Form → Update:** `PUT /v1/lead-pages/{pageLinkId}/forms/{formId}` — creates or **replaces** the whole config: **Auto-Send Enabled**, **Consent Checkbox Key**, **Template ID** (official numbers), **Free Text** (other numbers), **Variable Map (JSON)**, **Form Name**. Empty Consent Checkbox Key / Template ID / Free Text go out as `null`. ⚠️ With Auto-Send Enabled, new leads get a WhatsApp message without a human.
184
+
152
185
  ### 7. Phone Line (identity verification + activation audio)
153
186
 
154
187
  Requires a **workspace (tenant-scoped) API key** — a number-scoped key is refused. The verification operations need the **OWNER** role (`phone_lines:purchase`); the audio needs `phone_lines:read`. Errors come back as `{ error, code }`.
@@ -44,6 +44,17 @@ export declare function resolvePhoneLineDocument(ctx: IExecuteSingleFunctions):
44
44
  export declare function phoneLineStartVerificationPreSend(this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions>;
45
45
  /** Submit Document: the body is exactly `{ document }`. No Idempotency-Key on this route. */
46
46
  export declare function phoneLineSubmitDocumentPreSend(this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions>;
47
+ /**
48
+ * Lead Form → Update: builds the WHOLE `PUT /v1/lead-pages/{id}/forms/{formId}` body.
49
+ *
50
+ * A preSend rather than per-field routing because the API takes `consentDisclaimerKey`,
51
+ * `templateId` and `freeText` as REQUIRED-but-nullable: an empty field has to go out as
52
+ * `null` (the PUT replaces the config, and an omitted required field is a 400), while
53
+ * the optional `variableMap` / `formName` are left out when empty so the server applies
54
+ * its own defaults. Unknown fields are refused by the API (400 UNKNOWN_FIELDS), so the
55
+ * body carries exactly these six names and nothing else.
56
+ */
57
+ export declare function leadFormConfigPreSend(this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions>;
47
58
  /**
48
59
  * The file name from a `Content-Disposition` header: RFC 5987 `filename*=` first (it is the
49
60
  * one that can carry non-ASCII), then the plain `filename=` (quoted or not).
@@ -5,6 +5,7 @@ exports.apiBaseUrl = apiBaseUrl;
5
5
  exports.resolvePhoneLineDocument = resolvePhoneLineDocument;
6
6
  exports.phoneLineStartVerificationPreSend = phoneLineStartVerificationPreSend;
7
7
  exports.phoneLineSubmitDocumentPreSend = phoneLineSubmitDocumentPreSend;
8
+ exports.leadFormConfigPreSend = leadFormConfigPreSend;
8
9
  exports.parseContentDispositionFileName = parseContentDispositionFileName;
9
10
  exports.phoneLineAudioToBinary = phoneLineAudioToBinary;
10
11
  /**
@@ -109,6 +110,46 @@ async function phoneLineSubmitDocumentPreSend(requestOptions) {
109
110
  ensureObjectBody(requestOptions).document = await resolvePhoneLineDocument(this);
110
111
  return requestOptions;
111
112
  }
113
+ /**
114
+ * Lead Form → Update: builds the WHOLE `PUT /v1/lead-pages/{id}/forms/{formId}` body.
115
+ *
116
+ * A preSend rather than per-field routing because the API takes `consentDisclaimerKey`,
117
+ * `templateId` and `freeText` as REQUIRED-but-nullable: an empty field has to go out as
118
+ * `null` (the PUT replaces the config, and an omitted required field is a 400), while
119
+ * the optional `variableMap` / `formName` are left out when empty so the server applies
120
+ * its own defaults. Unknown fields are refused by the API (400 UNKNOWN_FIELDS), so the
121
+ * body carries exactly these six names and nothing else.
122
+ */
123
+ async function leadFormConfigPreSend(requestOptions) {
124
+ const text = (name) => { var _a; return String((_a = this.getNodeParameter(name, '')) !== null && _a !== void 0 ? _a : '').trim(); };
125
+ const body = {
126
+ consentDisclaimerKey: text('leadFormConsentDisclaimerKey') || null,
127
+ autoSendEnabled: this.getNodeParameter('leadFormAutoSendEnabled', false) === true,
128
+ templateId: text('leadFormTemplateId') || null,
129
+ freeText: text('leadFormFreeText') || null,
130
+ };
131
+ const rawMap = this.getNodeParameter('leadFormVariableMap', '');
132
+ if (typeof rawMap === 'string' ? rawMap.trim() !== '' : rawMap != null) {
133
+ let map = rawMap;
134
+ if (typeof rawMap === 'string') {
135
+ try {
136
+ map = JSON.parse(rawMap);
137
+ }
138
+ catch {
139
+ map = undefined;
140
+ }
141
+ }
142
+ if (!map || typeof map !== 'object' || Array.isArray(map)) {
143
+ throw new Error('Pilot Status: "Variable Map (JSON)" must be a JSON object like {"1": {"source": "field", "key": "full_name"}}.');
144
+ }
145
+ body.variableMap = map;
146
+ }
147
+ const formName = text('leadFormName');
148
+ if (formName)
149
+ body.formName = formName;
150
+ requestOptions.body = body;
151
+ return requestOptions;
152
+ }
112
153
  /**
113
154
  * The file name from a `Content-Disposition` header: RFC 5987 `filename*=` first (it is the
114
155
  * one that can carry non-ASCII), then the plain `filename=` (quoted or not).
@@ -298,6 +339,11 @@ class PilotStatus {
298
339
  { name: 'Analytics', value: 'analytics' },
299
340
  { name: 'Service Window', value: 'serviceWindow' },
300
341
  { name: 'Lead', value: 'lead' },
342
+ { name: 'Referral', value: 'referral' },
343
+ { name: 'Ads Summary', value: 'adsSummary' },
344
+ { name: 'Ad Account', value: 'adAccount' },
345
+ { name: 'Lead Page', value: 'leadPage' },
346
+ { name: 'Lead Form', value: 'leadForm' },
301
347
  { name: 'Remote Pairing', value: 'remotePairing' },
302
348
  { name: 'Call', value: 'call' },
303
349
  { name: 'Phone Line', value: 'phoneLine' },
@@ -324,7 +370,7 @@ class PilotStatus {
324
370
  send: {
325
371
  preSend: [
326
372
  async function (requestOptions) {
327
- var _a, _b;
373
+ var _a, _b, _c;
328
374
  const destinationType = this.getNodeParameter('sendDestinationType') || 'phone';
329
375
  if (!requestOptions.body || typeof requestOptions.body !== 'object') {
330
376
  requestOptions.body = {};
@@ -411,6 +457,18 @@ class PilotStatus {
411
457
  requestOptions.body[campo] = valor;
412
458
  }
413
459
  }
460
+ // Optional Idempotency-Key: a HEADER, never a body field. Blank or
461
+ // absent leaves the request exactly as before (no deduplication).
462
+ const additional = this.getNodeParameter('additionalFields', {});
463
+ const idempotencyKey = typeof (additional === null || additional === void 0 ? void 0 : additional.idempotencyKey) === 'string'
464
+ ? additional.idempotencyKey.trim()
465
+ : '';
466
+ if (idempotencyKey) {
467
+ requestOptions.headers = {
468
+ ...((_c = requestOptions.headers) !== null && _c !== void 0 ? _c : {}),
469
+ 'Idempotency-Key': idempotencyKey,
470
+ };
471
+ }
414
472
  return requestOptions;
415
473
  },
416
474
  ],
@@ -636,6 +694,13 @@ class PilotStatus {
636
694
  default: '',
637
695
  description: 'Optional expiration limit for the message delivery (ISO8601)',
638
696
  },
697
+ {
698
+ displayName: 'Idempotency Key',
699
+ name: 'idempotencyKey',
700
+ type: 'string',
701
+ default: '',
702
+ description: 'Optional. Sent as the Idempotency-Key header (max 255 characters, no control characters), never in the body. REUSE THE SAME KEY when retrying the same message: within 24 hours (per workspace + number + key) the API returns the first accepted response instead of sending again (Idempotent-Replayed: true). Map it from your own data (e.g. an order id) — a key that changes on every run makes retries unsafe. Same key with a DIFFERENT body → 409 IDEMPOTENCY_KEY_REUSED; first call still running → 409 IDEMPOTENCY_KEY_IN_USE; invalid key → 400 IDEMPOTENCY_KEY_INVALID. Only successful (2xx) responses are remembered, so after an error you can fix the input and retry with the same key.',
703
+ },
639
704
  {
640
705
  displayName: 'Labels',
641
706
  name: 'labels',
@@ -1972,6 +2037,453 @@ class PilotStatus {
1972
2037
  routing: { send: { type: 'query', property: 'endDate' } },
1973
2038
  },
1974
2039
  // ----------------------------------
2040
+ // Referral Operations (Click-to-WhatsApp ad attribution)
2041
+ // ----------------------------------
2042
+ // Read-only. Acts on ONE number: a number-scoped key, or a workspace key whose credential
2043
+ // names the number (x-whatsapp-number-id) — otherwise 403 TENANT_SCOPE_NOT_ALLOWED.
2044
+ {
2045
+ displayName: 'Operation',
2046
+ name: 'operation',
2047
+ type: 'options',
2048
+ noDataExpression: true,
2049
+ displayOptions: { show: { resource: ['referral'] } },
2050
+ options: [
2051
+ {
2052
+ name: 'Get Many',
2053
+ value: 'getAll',
2054
+ description: 'List the inbound messages that arrived from a Click-to-WhatsApp ad or post, newest first. Meta attaches the referral to the FIRST message of a conversation only, so each row amounts to one conversation started by that ad. Answers {referrals, total, page, pageSize, totalPages, notice?}; each row carries referral {sourceId, sourceType, sourceUrl, headline, body, ctwaClid, adName, adsetName, campaignName, namesResolvedAt, ...}. sourceId is the STABLE ad id — names are editable in Meta and filled only when the advertiser shared the ad account with Pilot Status. On a RELAY_ONLY number the ad id and names stay, while ctwaClid, ad copy and content come back null with redacted=true. Acts on one number (needs chat:read).',
2055
+ action: 'Get many referrals',
2056
+ routing: { request: { method: 'GET', url: '/referrals' } },
2057
+ },
2058
+ {
2059
+ name: 'Summary',
2060
+ value: 'summary',
2061
+ description: 'Click-to-WhatsApp traffic grouped by ad, ordered by conversations. Answers {ads, total, limit, truncated, notice?, piiNotice?}; each ad {sourceId, sourceType, conversations, messages, firstAt, lastAt, lastSourceUrl, lastHeadline, adName, adsetId, adsetName, campaignId, campaignName, namesResolvedAt}. ⚠️ conversations counts DISTINCT conversations (the lead count); messages counts messages. Capped at 200 ads: truncated=true means a PARTIAL answer — narrow the dates. Acts on one number (needs chat:read).',
2062
+ action: 'Get referral summary',
2063
+ routing: { request: { method: 'GET', url: '/referrals/summary' } },
2064
+ },
2065
+ ],
2066
+ default: 'getAll',
2067
+ },
2068
+ {
2069
+ displayName: 'Source ID',
2070
+ name: 'referralSourceId',
2071
+ type: 'string',
2072
+ displayOptions: { show: { resource: ['referral'], operation: ['getAll'] } },
2073
+ default: '',
2074
+ description: 'Only messages from this Meta ad or post ID (e.g. 120249828053880703)',
2075
+ },
2076
+ {
2077
+ displayName: 'Source Type',
2078
+ name: 'referralSourceType',
2079
+ type: 'options',
2080
+ displayOptions: { show: { resource: ['referral'], operation: ['getAll'] } },
2081
+ options: [
2082
+ { name: 'Any', value: '' },
2083
+ { name: 'Ad', value: 'ad' },
2084
+ { name: 'Post', value: 'post' },
2085
+ ],
2086
+ default: '',
2087
+ description: 'Only paid ads or only organic posts',
2088
+ },
2089
+ {
2090
+ displayName: 'Start Date',
2091
+ name: 'referralStartDate',
2092
+ type: 'dateTime',
2093
+ displayOptions: { show: { resource: ['referral'], operation: ['getAll', 'summary'] } },
2094
+ default: '',
2095
+ description: 'Only messages that happened at or after this instant',
2096
+ },
2097
+ {
2098
+ displayName: 'End Date',
2099
+ name: 'referralEndDate',
2100
+ type: 'dateTime',
2101
+ displayOptions: { show: { resource: ['referral'], operation: ['getAll', 'summary'] } },
2102
+ default: '',
2103
+ description: 'Only messages that happened at or before this instant. Must not precede Start Date.',
2104
+ },
2105
+ {
2106
+ displayName: 'Page',
2107
+ name: 'referralPage',
2108
+ type: 'number',
2109
+ typeOptions: { minValue: 1 },
2110
+ displayOptions: { show: { resource: ['referral'], operation: ['getAll'] } },
2111
+ default: 1,
2112
+ routing: { send: { type: 'query', property: 'page' } },
2113
+ },
2114
+ {
2115
+ displayName: 'Page Size',
2116
+ name: 'referralPageSize',
2117
+ type: 'number',
2118
+ typeOptions: { minValue: 1, maxValue: 100 },
2119
+ displayOptions: { show: { resource: ['referral'], operation: ['getAll'] } },
2120
+ default: 30,
2121
+ description: 'Items per page (max 100)',
2122
+ routing: { send: { type: 'query', property: 'pageSize' } },
2123
+ },
2124
+ // Empty filters are omitted rather than sent as `?sourceId=` (an empty sourceType would
2125
+ // answer 400 INVALID_SOURCE_TYPE), and the dates are converted to ISO 8601 — the n8n
2126
+ // date picker hands over another format.
2127
+ {
2128
+ displayName: 'Source ID',
2129
+ name: 'referralSourceIdNormalized',
2130
+ type: 'hidden',
2131
+ displayOptions: { show: { resource: ['referral'], operation: ['getAll'] } },
2132
+ default: '={{ $parameter.referralSourceId || undefined }}',
2133
+ routing: { send: { type: 'query', property: 'sourceId' } },
2134
+ },
2135
+ {
2136
+ displayName: 'Source Type',
2137
+ name: 'referralSourceTypeNormalized',
2138
+ type: 'hidden',
2139
+ displayOptions: { show: { resource: ['referral'], operation: ['getAll'] } },
2140
+ default: '={{ $parameter.referralSourceType || undefined }}',
2141
+ routing: { send: { type: 'query', property: 'sourceType' } },
2142
+ },
2143
+ {
2144
+ displayName: 'Start Date',
2145
+ name: 'referralStartDateNormalized',
2146
+ type: 'hidden',
2147
+ displayOptions: { show: { resource: ['referral'], operation: ['getAll', 'summary'] } },
2148
+ default: '={{ $parameter.referralStartDate ? new Date($parameter.referralStartDate).toISOString() : undefined }}',
2149
+ routing: { send: { type: 'query', property: 'startDate' } },
2150
+ },
2151
+ {
2152
+ displayName: 'End Date',
2153
+ name: 'referralEndDateNormalized',
2154
+ type: 'hidden',
2155
+ displayOptions: { show: { resource: ['referral'], operation: ['getAll', 'summary'] } },
2156
+ default: '={{ $parameter.referralEndDate ? new Date($parameter.referralEndDate).toISOString() : undefined }}',
2157
+ routing: { send: { type: 'query', property: 'endDate' } },
2158
+ },
2159
+ // ----------------------------------
2160
+ // Ads Summary (GET /v1/ads/summary)
2161
+ // ----------------------------------
2162
+ // Its own resource rather than an operation under Referral: same aggregate, different
2163
+ // AUTHORITY and SCOPE. Referral → Summary is `chat:read` on ONE number; this is
2164
+ // `analytics:read` (ANALYST included) and, on a workspace key without a number, covers
2165
+ // the whole workspace — plus `leadCount`. Filing it under Referral would suggest the
2166
+ // same permission and the same per-number scope, and neither holds.
2167
+ {
2168
+ displayName: 'Operation',
2169
+ name: 'operation',
2170
+ type: 'options',
2171
+ noDataExpression: true,
2172
+ displayOptions: { show: { resource: ['adsSummary'] } },
2173
+ options: [
2174
+ {
2175
+ name: 'Get',
2176
+ value: 'get',
2177
+ description: 'Click-to-WhatsApp volume per ad with resolved campaign / ad set / ad names and leadCount (Meta Lead Ads leads of that ad). Answers {ads, total, limit, truncated}. ⚠️ conversations counts DISTINCT conversations; messages counts messages. Capped at 200 ads: truncated=true means a PARTIAL answer — narrow the dates. Needs analytics:read. A number-scoped key (or a credential with WhatsApp Number ID) reports that number; a workspace key without it reports the whole workspace.',
2178
+ action: 'Get the ads summary',
2179
+ routing: { request: { method: 'GET', url: '/ads/summary' } },
2180
+ },
2181
+ ],
2182
+ default: 'get',
2183
+ },
2184
+ {
2185
+ displayName: 'WhatsApp Number ID',
2186
+ name: 'adsSummaryWhatsappNumberId',
2187
+ type: 'string',
2188
+ displayOptions: { show: { resource: ['adsSummary'], operation: ['get'] } },
2189
+ default: '',
2190
+ description: 'Only this number. Must be within the credential\'s reach, else 403 NUMBER_NOT_IN_GRANT. Leave empty for every number the credential reaches.',
2191
+ },
2192
+ {
2193
+ displayName: 'Start Date',
2194
+ name: 'adsSummaryStartDate',
2195
+ type: 'dateTime',
2196
+ displayOptions: { show: { resource: ['adsSummary'], operation: ['get'] } },
2197
+ default: '',
2198
+ description: 'Only messages (and leads) at or after this instant',
2199
+ },
2200
+ {
2201
+ displayName: 'End Date',
2202
+ name: 'adsSummaryEndDate',
2203
+ type: 'dateTime',
2204
+ displayOptions: { show: { resource: ['adsSummary'], operation: ['get'] } },
2205
+ default: '',
2206
+ description: 'Only messages (and leads) at or before this instant. Must not precede Start Date.',
2207
+ },
2208
+ {
2209
+ displayName: 'WhatsApp Number ID',
2210
+ name: 'adsSummaryWhatsappNumberIdNormalized',
2211
+ type: 'hidden',
2212
+ displayOptions: { show: { resource: ['adsSummary'], operation: ['get'] } },
2213
+ default: '={{ $parameter.adsSummaryWhatsappNumberId || undefined }}',
2214
+ routing: { send: { type: 'query', property: 'whatsappNumberId' } },
2215
+ },
2216
+ {
2217
+ displayName: 'Start Date',
2218
+ name: 'adsSummaryStartDateNormalized',
2219
+ type: 'hidden',
2220
+ displayOptions: { show: { resource: ['adsSummary'], operation: ['get'] } },
2221
+ default: '={{ $parameter.adsSummaryStartDate ? new Date($parameter.adsSummaryStartDate).toISOString() : undefined }}',
2222
+ routing: { send: { type: 'query', property: 'startDate' } },
2223
+ },
2224
+ {
2225
+ displayName: 'End Date',
2226
+ name: 'adsSummaryEndDateNormalized',
2227
+ type: 'hidden',
2228
+ displayOptions: { show: { resource: ['adsSummary'], operation: ['get'] } },
2229
+ default: '={{ $parameter.adsSummaryEndDate ? new Date($parameter.adsSummaryEndDate).toISOString() : undefined }}',
2230
+ routing: { send: { type: 'query', property: 'endDate' } },
2231
+ },
2232
+ // ----------------------------------
2233
+ // Ad Account Operations (/v1/ads/accounts)
2234
+ // ----------------------------------
2235
+ // Workspace (tenant-scoped) key only, `integrations:manage` on every verb. Access to an
2236
+ // ad account comes from the advertiser adding the Pilot Status portfolio as a PARTNER in
2237
+ // Meta Business Manager — there is no token to send.
2238
+ {
2239
+ displayName: 'Operation',
2240
+ name: 'operation',
2241
+ type: 'options',
2242
+ noDataExpression: true,
2243
+ displayOptions: { show: { resource: ['adAccount'] } },
2244
+ options: [
2245
+ {
2246
+ name: 'Get Many',
2247
+ value: 'getAll',
2248
+ description: 'The ad accounts connected to the workspace (so campaign / ad set / ad names can be resolved) and the ones that may be connected. Answers {linked, candidates, partnerBusinessId, sharingLookup}; partnerBusinessId is the Pilot Status portfolio the advertiser adds as a PARTNER (ads_read) of the ad account in Meta Business Manager. linked[].sharingActive null means Meta could not be asked, NOT revoked. Requires a workspace (tenant-scoped) API key.',
2249
+ action: 'Get many ad accounts',
2250
+ routing: { request: { method: 'GET', url: '/ads/accounts' } },
2251
+ },
2252
+ {
2253
+ name: 'Link',
2254
+ value: 'link',
2255
+ description: 'Connect one ad account (act_<digits>). Answers 201 {link}. Refused with 409 AD_ACCOUNT_NOT_PROVEN (no ad of that account in this workspace\'s conversations), 409 AD_ACCOUNT_NOT_SHARED (partner grant not there yet), 502 ADS_LOOKUP_UNAVAILABLE or 503 ADS_NOT_CONFIGURED. Requires a workspace API key.',
2256
+ action: 'Link an ad account',
2257
+ routing: { request: { method: 'POST', url: '/ads/accounts' } },
2258
+ },
2259
+ {
2260
+ name: 'Unlink',
2261
+ value: 'unlink',
2262
+ description: 'Disconnect one ad account. Soft: names already resolved stay. Answers {unlinked, adAccountId}; 404 NOT_FOUND when it is not linked to this workspace. Requires a workspace API key.',
2263
+ action: 'Unlink an ad account',
2264
+ routing: { request: { method: 'DELETE', url: '=/ads/accounts/{{$parameter.adAccountId}}' } },
2265
+ },
2266
+ ],
2267
+ default: 'getAll',
2268
+ },
2269
+ {
2270
+ displayName: 'Ad Account ID',
2271
+ name: 'adAccountId',
2272
+ type: 'string',
2273
+ displayOptions: { show: { resource: ['adAccount'], operation: ['link', 'unlink'] } },
2274
+ default: '',
2275
+ required: true,
2276
+ placeholder: 'act_1234567890',
2277
+ description: 'Meta ad account id, act_ followed by digits',
2278
+ },
2279
+ // The id travels in the BODY on Link and in the PATH on Unlink: the body field is a
2280
+ // hidden mirror shown on Link only, so the DELETE never carries a body.
2281
+ {
2282
+ displayName: 'Ad Account ID',
2283
+ name: 'adAccountIdBody',
2284
+ type: 'hidden',
2285
+ displayOptions: { show: { resource: ['adAccount'], operation: ['link'] } },
2286
+ default: '={{ $parameter.adAccountId }}',
2287
+ routing: { send: { type: 'body', property: 'adAccountId' } },
2288
+ },
2289
+ // ----------------------------------
2290
+ // Lead Page Operations (/v1/lead-pages)
2291
+ // ----------------------------------
2292
+ // `integrations:manage`. A credential bound to one number acts on that number's links
2293
+ // only (403 NUMBER_NOT_IN_GRANT otherwise); a workspace key without one sees them all.
2294
+ {
2295
+ displayName: 'Operation',
2296
+ name: 'operation',
2297
+ type: 'options',
2298
+ noDataExpression: true,
2299
+ displayOptions: { show: { resource: ['leadPage'] } },
2300
+ options: [
2301
+ {
2302
+ name: 'Get Many',
2303
+ value: 'getAll',
2304
+ description: 'The Facebook Pages linked for Meta Lead Ads capture and the Pages this workspace may link. Answers {linked, candidates, configured, partnerBusinessId, candidatesLookup, eligibilityBlocker}. linked[].subscribedAt null means Meta is NOT pushing leads (subscriptionError says why); candidates[].missingTasks empty = ready to link. eligibilityBlocker NO_OFFICIAL_NUMBER = the workspace needs an official number first.',
2305
+ action: 'Get many lead pages',
2306
+ routing: { request: { method: 'GET', url: '/lead-pages' } },
2307
+ },
2308
+ {
2309
+ name: 'Link',
2310
+ value: 'link',
2311
+ description: 'Link one Facebook Page to one WhatsApp number so its Lead Ads leads arrive there. Answers 201 {link}; the last 90 days of leads are backfilled on their own.',
2312
+ action: 'Link a lead page',
2313
+ routing: { request: { method: 'POST', url: '/lead-pages' } },
2314
+ },
2315
+ {
2316
+ name: 'Update',
2317
+ value: 'update',
2318
+ description: 'Move a Page link to another WhatsApp number. Answers {link, autoSendDisabled}; autoSendDisabled=true means every auto-send of the Page\'s forms was switched OFF (the new number sends a different kind of message) and must be reviewed.',
2319
+ action: 'Move a lead page to another number',
2320
+ routing: { request: { method: 'PATCH', url: '=/lead-pages/{{$parameter.pageLinkId}}' } },
2321
+ },
2322
+ {
2323
+ name: 'Unlink',
2324
+ value: 'unlink',
2325
+ description: '⚠️ DESTRUCTIVE — unlinking a Page ERASES every lead captured through it and deletes its form configurations. There is no undo. Answers {unlinked, pageLinkId, deletedLeads}.',
2326
+ action: 'Unlink a lead page and delete its leads',
2327
+ routing: { request: { method: 'DELETE', url: '=/lead-pages/{{$parameter.pageLinkId}}' } },
2328
+ },
2329
+ {
2330
+ name: 'Resync',
2331
+ value: 'resync',
2332
+ description: 'Re-pull the Page\'s last 90 days of leads (idempotent) and retry the subscription when it is down. Answers 202 {started, pageLinkId, subscribedAt?, subscriptionError?}; the backfill runs in the background. Inside the per-Page cooldown it fails with 429 RESYNC_COOLDOWN, whose body carries retryAfterSeconds.',
2333
+ action: 'Resync a lead page',
2334
+ routing: { request: { method: 'POST', url: '=/lead-pages/{{$parameter.pageLinkId}}/resync' } },
2335
+ },
2336
+ ],
2337
+ default: 'getAll',
2338
+ },
2339
+ {
2340
+ displayName: 'Page Link ID',
2341
+ name: 'pageLinkId',
2342
+ type: 'string',
2343
+ displayOptions: { show: { resource: ['leadPage'], operation: ['update', 'unlink', 'resync'] } },
2344
+ default: '',
2345
+ required: true,
2346
+ description: 'Pilot Status id of the Page link — linked[].pageLinkId from Get Many. Not the Facebook Page ID.',
2347
+ },
2348
+ {
2349
+ displayName: 'Facebook Page ID',
2350
+ name: 'leadPagePageId',
2351
+ type: 'string',
2352
+ displayOptions: { show: { resource: ['leadPage'], operation: ['link'] } },
2353
+ default: '',
2354
+ required: true,
2355
+ description: 'Numeric Facebook Page id (candidates[].pageId from Get Many)',
2356
+ routing: { send: { type: 'body', property: 'pageId' } },
2357
+ },
2358
+ {
2359
+ displayName: 'WhatsApp Number ID',
2360
+ name: 'leadPageWhatsappNumberId',
2361
+ type: 'string',
2362
+ displayOptions: { show: { resource: ['leadPage'], operation: ['link'] } },
2363
+ default: '',
2364
+ description: 'Number that receives the Page\'s leads. May be left empty only when the credential reaches exactly one number (number-scoped key, or WhatsApp Number ID set in the credential).',
2365
+ },
2366
+ {
2367
+ displayName: 'WhatsApp Number ID',
2368
+ name: 'leadPageWhatsappNumberIdNormalized',
2369
+ type: 'hidden',
2370
+ displayOptions: { show: { resource: ['leadPage'], operation: ['link'] } },
2371
+ default: '={{ $parameter.leadPageWhatsappNumberId || undefined }}',
2372
+ routing: { send: { type: 'body', property: 'whatsappNumberId' } },
2373
+ },
2374
+ {
2375
+ displayName: 'New WhatsApp Number ID',
2376
+ name: 'leadPageMoveWhatsappNumberId',
2377
+ type: 'string',
2378
+ displayOptions: { show: { resource: ['leadPage'], operation: ['update'] } },
2379
+ default: '',
2380
+ required: true,
2381
+ description: 'Number the Page\'s leads should go to from now on',
2382
+ routing: { send: { type: 'body', property: 'whatsappNumberId' } },
2383
+ },
2384
+ // ----------------------------------
2385
+ // Lead Form Operations (/v1/lead-pages/{pageLinkId}/forms)
2386
+ // ----------------------------------
2387
+ {
2388
+ displayName: 'Operation',
2389
+ name: 'operation',
2390
+ type: 'options',
2391
+ noDataExpression: true,
2392
+ displayOptions: { show: { resource: ['leadForm'] } },
2393
+ options: [
2394
+ {
2395
+ name: 'Get Many',
2396
+ value: 'getAll',
2397
+ description: 'The linked Page\'s Instant Forms, live from Meta, with their questions, consent checkboxes and stored config (null = never configured), plus the APPROVED templates the link\'s number can auto-send. Answers {forms, formsTruncated, numberIsOfficial, templates}. consentAvailable=false means the checkbox list is UNKNOWN, not empty.',
2398
+ action: 'Get many lead forms',
2399
+ routing: {
2400
+ request: { method: 'GET', url: '=/lead-pages/{{$parameter.leadFormPageLinkId}}/forms' },
2401
+ },
2402
+ },
2403
+ {
2404
+ name: 'Update',
2405
+ value: 'update',
2406
+ description: 'Create or REPLACE one form\'s config (every field is rewritten). ⚠️ With Auto-Send Enabled, new leads get a WhatsApp message WITHOUT a human: an official number sends the Template ID (APPROVED template), the others send the Free Text. Answers {config}.',
2407
+ action: 'Update a lead form configuration',
2408
+ routing: {
2409
+ request: {
2410
+ method: 'PUT',
2411
+ url: '=/lead-pages/{{$parameter.leadFormPageLinkId}}/forms/{{$parameter.leadFormFormId}}',
2412
+ },
2413
+ send: { preSend: [leadFormConfigPreSend] },
2414
+ },
2415
+ },
2416
+ ],
2417
+ default: 'getAll',
2418
+ },
2419
+ {
2420
+ displayName: 'Page Link ID',
2421
+ name: 'leadFormPageLinkId',
2422
+ type: 'string',
2423
+ displayOptions: { show: { resource: ['leadForm'] } },
2424
+ default: '',
2425
+ required: true,
2426
+ description: 'Pilot Status id of the Page link — linked[].pageLinkId from Lead Page → Get Many',
2427
+ },
2428
+ {
2429
+ displayName: 'Form ID',
2430
+ name: 'leadFormFormId',
2431
+ type: 'string',
2432
+ displayOptions: { show: { resource: ['leadForm'], operation: ['update'] } },
2433
+ default: '',
2434
+ required: true,
2435
+ description: 'Numeric Meta Instant Form id (forms[].formId from Get Many)',
2436
+ },
2437
+ {
2438
+ displayName: 'Auto-Send Enabled',
2439
+ name: 'leadFormAutoSendEnabled',
2440
+ type: 'boolean',
2441
+ displayOptions: { show: { resource: ['leadForm'], operation: ['update'] } },
2442
+ default: false,
2443
+ description: 'Whether new leads of this form get an automatic WhatsApp message',
2444
+ },
2445
+ {
2446
+ displayName: 'Consent Checkbox Key',
2447
+ name: 'leadFormConsentDisclaimerKey',
2448
+ type: 'string',
2449
+ displayOptions: { show: { resource: ['leadForm'], operation: ['update'] } },
2450
+ default: '',
2451
+ description: 'Key of the consent checkbox (forms[].consentCheckboxes[].key) whose answer gates the auto-send. Empty sends null.',
2452
+ },
2453
+ {
2454
+ displayName: 'Template ID',
2455
+ name: 'leadFormTemplateId',
2456
+ type: 'string',
2457
+ displayOptions: { show: { resource: ['leadForm'], operation: ['update'] } },
2458
+ default: '',
2459
+ description: 'APPROVED template to auto-send (official numbers only; templates[] from Get Many). Empty sends null.',
2460
+ },
2461
+ {
2462
+ displayName: 'Free Text',
2463
+ name: 'leadFormFreeText',
2464
+ type: 'string',
2465
+ typeOptions: { rows: 4 },
2466
+ displayOptions: { show: { resource: ['leadForm'], operation: ['update'] } },
2467
+ default: '',
2468
+ description: 'Message to auto-send on a non-official number, with {{placeholders}} (max 4096). Empty sends null.',
2469
+ },
2470
+ {
2471
+ displayName: 'Variable Map (JSON)',
2472
+ name: 'leadFormVariableMap',
2473
+ type: 'json',
2474
+ displayOptions: { show: { resource: ['leadForm'], operation: ['update'] } },
2475
+ default: '',
2476
+ description: 'Value of each template / free-text variable: {"1": {"source": "field", "key": "full_name"}, "2": {"source": "static", "value": "Acme"}}. Empty leaves it out (the API stores {}).',
2477
+ },
2478
+ {
2479
+ displayName: 'Form Name',
2480
+ name: 'leadFormName',
2481
+ type: 'string',
2482
+ displayOptions: { show: { resource: ['leadForm'], operation: ['update'] } },
2483
+ default: '',
2484
+ description: 'Optional display label (max 255)',
2485
+ },
2486
+ // ----------------------------------
1975
2487
  // Remote Pairing Operations
1976
2488
  // ----------------------------------
1977
2489
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-pilot-status",
3
- "version": "2.7.0",
3
+ "version": "2.9.0",
4
4
  "description": "n8n node for Pilot Status API",
5
5
  "keywords": [
6
6
  "n8ncommunity",