n8n-nodes-pilot-status 1.2.0 → 1.3.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Pilot Status - n8n Integration
2
2
 
3
- This is the official [n8n](https://n8n.io/) node for [Pilot Status](https://pilotstatuss.com) — a WhatsApp transactional, marketing, and bulk messaging platform.
3
+ This is the official [n8n](https://n8n.io/) node for [Pilot Status](https://pilotstatus.com.br) — a WhatsApp transactional, marketing, and bulk messaging platform.
4
4
 
5
5
  With this integration, you can seamlessly connect your n8n workflows to Pilot Status to send messages, manage projects, connect WhatsApp numbers, and react to incoming messages or status changes in real time.
6
6
 
@@ -27,7 +27,7 @@ npm install n8n-nodes-pilot-status
27
27
 
28
28
  To use the Pilot Status node, you need an **API Key**.
29
29
 
30
- 1. Go to your [Pilot Status Dashboard](https://pilotstatuss.com/api-keys).
30
+ 1. Go to your [Pilot Status Dashboard](https://pilotstatus.com.br/api-keys).
31
31
  2. Create a new API Key.
32
32
  3. In n8n, add a new **Pilot Status API** credential and paste your API Key.
33
33
 
@@ -53,6 +53,7 @@ To use it:
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
55
  - **Group Message:** Triggered when an inbound group message is received (group subject is included when available).
56
+ - **Call Ringing / Call Connected / Call Ended / Call Missed / Call Permission Updated:** WhatsApp Business Calling events (`call.*`) — Meta Cloud API **and web (Pilot Status) numbers** (`call.permission_updated` is Meta-only). Payloads are **flat** (fields next to `event`, no `data` wrapper): `{ event, callId, externalCallId?, direction, status, from, to, timestamp, duration? }`; `duration` (seconds) appears on `call.ended` only when the call was answered. `externalCallId` is the provider call id (Meta `wacid...` or Evolution GO CallID).
56
57
 
57
58
  Webhook payload notes:
58
59
  - Customer webhook payloads do not include: `projectSlug`, `lastMessageId`. Optional `correlationId` (same as HTTP 202 when present) may appear on outbound status events and on `message.reply` / `message.received` when correlated to a prior send.
@@ -69,23 +70,36 @@ The **Pilot Status** node provides several resources and operations to manage yo
69
70
  ### 1. Message
70
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).
71
72
  - **Get Status:** Retrieve the current status of a specific message using either its Pilot Status message id or WhatsApp provider id.
73
+ - **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.
72
74
 
73
75
  ### 2. Number
74
76
  - **Create:** Provision a new WhatsApp number instance. It returns a base64 QR Code and optional `pairingCode` (letter code) for WhatsApp “link a device”. By default, the number is linked to the API Key used in the request.
75
77
  - **Connect (QR + pairing code):** Regenerate QR and pairing code for an existing instance (only when not `OPEN`).
76
78
  - **Get Status:** Check the connection status of a WhatsApp instance (e.g., `CONNECTING`, `OPEN`).
79
+ - **Get:** Full detail of one number, including the `settings` block and — for official Meta numbers — the nested `meta` block.
80
+ - **Update Settings:** Per-number settings. This is the only settings endpoint: there is no `POST /numbers/{id}/settings`, and Evolution's `syncFullHistory` does not exist here. Partial — only the fields you add to the collection change.
81
+ - **History Import Enabled** / **Webhook Historical Messages** apply to every provider. The second is off by default: each reconnect replays up to 30 days of conversation, and your integration cannot tell it apart from new traffic (on the FREE plan it also consumes inbound quota). To *read* history, use Message → Get History.
82
+ - **Always Online**, **Reject Call**, **Reject Call Message**, **Read Messages**, **Ignore Groups**, **Ignore Status** are the Evolution GO advanced settings, in the GO dialect (`ignoreGroups`, not the v2 `groupsIgnore`). They are tri-state: *Inherit From Provider* leaves the field untouched, *Reset to Provider Default* clears the stored value. On a Meta number they are stored but never applied.
77
83
 
78
84
  ### 3. Project
79
85
  - **Create:** Programmatically create a new project in your workspace.
80
86
  - **Get Many:** List all projects associated with your account.
81
87
 
82
88
  ### 4. API Key
83
- - **Create:** Generate new API Keys. This is highly useful for SaaS platforms that want to generate a specific API Key for each of their clients dynamically.
84
- - **Get Many:** List existing API Keys.
89
+ - **Regenerate:** Regenerate the default API Key of a single WhatsApp number (tenant-scoped), identified by its `whatsappNumberId`. The previous key for that number is rotated and the new key is returned.
90
+ - **Get Many:** List API Keys. With a tenant key, this reveals every number's real API key.
85
91
 
86
92
  ### 5. Analytics
87
93
  - **Get Dashboard:** Retrieve your messaging statistics (Total Sent, Total Failed, Failure Rate, and Daily charts) based on your timezone.
88
94
 
95
+ ### 6. Call (WhatsApp Business Calling — Meta Cloud API + web/Pilot Status numbers)
96
+ - **Initiate:** Start a business-initiated voice call (BIC) — provide the destination phone. On **Meta** numbers also provide the SDP offer (RFC 8866) from your WebRTC client and a prior user call permission; BIC minutes are billed by **Meta directly on your WABA** (per minute, 6-second pulses, only when answered). On **web (Pilot Status) numbers** leave the SDP empty — media is handled server-side, no permission step and no Meta billing. Pilot Status does not charge for calls.
97
+ - **Terminate:** Hang up an active call by its Pilot Status id (`call_...`) or provider call id (Meta wacid / Evolution GO CallID).
98
+ - **Play** *(web numbers only)*: Play an audio file into an active call by public URL (`.mp3`/`.wav`/`.opus`). Queued and played on connect when the call is not active yet. Meta numbers return `400 FEATURE_NOT_SUPPORTED`.
99
+ - **Realtime Session** *(web numbers only)*: Open a short-lived full-duplex realtime media session — returns `{ wsUrl, token, expiresInSeconds }`. Connect a WebSocket to `wsUrl` and exchange **raw binary PCM16 LE audio frames** (plain WebSocket transport, NOT WebRTC; single-use token, ~2 minutes). `talk` sends and receives audio; `listen` only receives.
100
+ - **Get Settings / Update Settings** *(Meta only)*: Read the number's `calling` settings object or enable/disable calling.
101
+ - **Get Permission / Request Permission** *(Meta only)*: Check whether the business may call a user, and send the interactive call-permission request (inside the 24h service window). The user's reply arrives as the `call.permission_updated` webhook.
102
+
89
103
  ---
90
104
 
91
105
  ## 💡 Use Case Examples
@@ -101,7 +115,7 @@ Here are some ideas of what you can build with this integration:
101
115
 
102
116
  ## 📚 Documentation & Support
103
117
 
104
- - **API Documentation:** [https://pilotstatuss.com/docs](https://pilotstatuss.com/docs)
105
- - **Official Website:** [https://pilotstatuss.com](https://pilotstatuss.com)
118
+ - **API Documentation:** [https://pilotstatus.com.br/docs](https://pilotstatus.com.br/docs)
119
+ - **Official Website:** [https://pilotstatus.com.br](https://pilotstatus.com.br)
106
120
 
107
121
  If you have any questions or need help, feel free to reach out to our support via the dashboard!
@@ -5,7 +5,7 @@ class PilotStatusApi {
5
5
  constructor() {
6
6
  this.name = 'pilotStatusApi';
7
7
  this.displayName = 'Pilot Status API';
8
- this.documentationUrl = 'https://pilotstatuss.com/docs';
8
+ this.documentationUrl = 'https://pilotstatus.com.br/docs';
9
9
  this.properties = [
10
10
  {
11
11
  displayName: 'API Key',
@@ -29,7 +29,7 @@ class PilotStatusApi {
29
29
  };
30
30
  this.test = {
31
31
  request: {
32
- baseURL: 'https://pilotstatuss.com/v1',
32
+ baseURL: 'https://pilotstatus.com.br/v1',
33
33
  url: '/templates',
34
34
  },
35
35
  };
@@ -1,4 +1,10 @@
1
1
  import { ILoadOptionsFunctions, INodePropertyOptions, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
+ /**
3
+ * Tri-estado dos `advancedSettings` do Evolution GO. A API distingue `true`,
4
+ * `false` e `null` (= volta ao default do provider), e o `type: 'boolean'` do
5
+ * n8n só produz dois valores — daí strings + tradução no hidden normalizado.
6
+ */
7
+ export declare const GO_TRISTATE: INodePropertyOptions[];
2
8
  export declare class PilotStatus implements INodeType {
3
9
  methods: {
4
10
  loadOptions: {
@@ -1,6 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PilotStatus = void 0;
3
+ exports.PilotStatus = exports.GO_TRISTATE = void 0;
4
+ /**
5
+ * Tri-estado dos `advancedSettings` do Evolution GO. A API distingue `true`,
6
+ * `false` e `null` (= volta ao default do provider), e o `type: 'boolean'` do
7
+ * n8n só produz dois valores — daí strings + tradução no hidden normalizado.
8
+ */
9
+ exports.GO_TRISTATE = [
10
+ { name: 'Inherit From Provider', value: 'inherit', description: 'Leave this setting untouched' },
11
+ { name: 'On', value: 'on' },
12
+ { name: 'Off', value: 'off' },
13
+ { name: 'Reset to Provider Default', value: 'default', description: 'Clear the stored value (sends null)' },
14
+ ];
4
15
  class PilotStatus {
5
16
  constructor() {
6
17
  this.methods = {
@@ -8,7 +19,7 @@ class PilotStatus {
8
19
  async getTemplates() {
9
20
  const response = (await this.helpers.requestWithAuthentication.call(this, 'pilotStatusApi', {
10
21
  method: 'GET',
11
- baseURL: 'https://pilotstatuss.com/v1',
22
+ baseURL: 'https://pilotstatus.com.br/v1',
12
23
  url: '/templates',
13
24
  json: true,
14
25
  }));
@@ -30,7 +41,7 @@ class PilotStatus {
30
41
  return [];
31
42
  const response = (await this.helpers.requestWithAuthentication.call(this, 'pilotStatusApi', {
32
43
  method: 'GET',
33
- baseURL: 'https://pilotstatuss.com/v1',
44
+ baseURL: 'https://pilotstatus.com.br/v1',
34
45
  url: `/templates/${templateId}`,
35
46
  json: true,
36
47
  }));
@@ -40,7 +51,7 @@ class PilotStatus {
40
51
  async getGroups() {
41
52
  const response = (await this.helpers.requestWithAuthentication.call(this, 'pilotStatusApi', {
42
53
  method: 'GET',
43
- baseURL: 'https://pilotstatuss.com/v1',
54
+ baseURL: 'https://pilotstatus.com.br/v1',
44
55
  url: '/groups',
45
56
  json: true,
46
57
  }));
@@ -52,7 +63,7 @@ class PilotStatus {
52
63
  async getNewsletters() {
53
64
  const response = (await this.helpers.requestWithAuthentication.call(this, 'pilotStatusApi', {
54
65
  method: 'GET',
55
- baseURL: 'https://pilotstatuss.com/v1',
66
+ baseURL: 'https://pilotstatus.com.br/v1',
56
67
  url: '/newsletters',
57
68
  json: true,
58
69
  }));
@@ -83,7 +94,7 @@ class PilotStatus {
83
94
  },
84
95
  ],
85
96
  requestDefaults: {
86
- baseURL: 'https://pilotstatuss.com/v1',
97
+ baseURL: 'https://pilotstatus.com.br/v1',
87
98
  headers: {
88
99
  Accept: 'application/json',
89
100
  'Content-Type': 'application/json',
@@ -106,6 +117,7 @@ class PilotStatus {
106
117
  { name: 'Newsletter', value: 'newsletter' },
107
118
  { name: 'Analytics', value: 'analytics' },
108
119
  { name: 'Remote Pairing', value: 'remotePairing' },
120
+ { name: 'Call', value: 'call' },
109
121
  ],
110
122
  default: 'message',
111
123
  },
@@ -206,6 +218,15 @@ class PilotStatus {
206
218
  request: { method: 'GET', url: '=/messages/{{$parameter.messageId}}' },
207
219
  },
208
220
  },
221
+ {
222
+ name: 'Get History',
223
+ value: 'getHistory',
224
+ description: 'Read the conversation history of the number, newest first — both directions, every provider, including messages imported from the device on connect. This is how you fetch old messages: the webhook does not replay history by default. Filters by the PROVIDER timestamp (when the message happened), not by ingestion time. Requires a number-scoped API key.',
225
+ action: 'Get message history',
226
+ routing: {
227
+ request: { method: 'GET', url: '/messages/history' },
228
+ },
229
+ },
209
230
  {
210
231
  name: 'Cancel',
211
232
  value: 'cancel',
@@ -283,7 +304,7 @@ class PilotStatus {
283
304
  },
284
305
  default: '',
285
306
  required: true,
286
- description: 'ID do grupo (@g.us)',
307
+ description: 'ID do grupo (JID terminando em @g.us). Funciona para números não oficiais e para números Meta Cloud API (Official Business Account aprovado) — para Meta o JID é o pseudo-JID <META_GROUP_ID>@g.us.',
287
308
  routing: { send: { type: 'body', property: 'groupId' } },
288
309
  },
289
310
  {
@@ -455,6 +476,59 @@ class PilotStatus {
455
476
  },
456
477
  ],
457
478
  },
479
+ // Message: Get History — filtros (query string, não body)
480
+ {
481
+ displayName: 'Start Date',
482
+ name: 'historyStartDate',
483
+ type: 'dateTime',
484
+ displayOptions: { show: { resource: ['message'], operation: ['getHistory'] } },
485
+ default: '',
486
+ description: 'Only messages at or after this instant. Compared against the provider timestamp — when the message happened, not when it was ingested.',
487
+ },
488
+ {
489
+ displayName: 'End Date',
490
+ name: 'historyEndDate',
491
+ type: 'dateTime',
492
+ displayOptions: { show: { resource: ['message'], operation: ['getHistory'] } },
493
+ default: '',
494
+ description: 'Only messages at or before this instant. Must not precede Start Date.',
495
+ },
496
+ {
497
+ displayName: 'Page',
498
+ name: 'historyPage',
499
+ type: 'number',
500
+ typeOptions: { minValue: 1 },
501
+ displayOptions: { show: { resource: ['message'], operation: ['getHistory'] } },
502
+ default: 1,
503
+ routing: { send: { type: 'query', property: 'page' } },
504
+ },
505
+ {
506
+ displayName: 'Page Size',
507
+ name: 'historyPageSize',
508
+ type: 'number',
509
+ typeOptions: { minValue: 1, maxValue: 100 },
510
+ displayOptions: { show: { resource: ['message'], operation: ['getHistory'] } },
511
+ default: 30,
512
+ description: 'Items per page (max 100)',
513
+ routing: { send: { type: 'query', property: 'pageSize' } },
514
+ },
515
+ // A API espera ISO 8601; o picker do n8n entrega outro formato.
516
+ {
517
+ displayName: 'Start Date',
518
+ name: 'historyStartDateNormalized',
519
+ type: 'hidden',
520
+ displayOptions: { show: { resource: ['message'], operation: ['getHistory'] } },
521
+ default: '={{ $parameter.historyStartDate ? new Date($parameter.historyStartDate).toISOString() : undefined }}',
522
+ routing: { send: { type: 'query', property: 'startDate' } },
523
+ },
524
+ {
525
+ displayName: 'End Date',
526
+ name: 'historyEndDateNormalized',
527
+ type: 'hidden',
528
+ displayOptions: { show: { resource: ['message'], operation: ['getHistory'] } },
529
+ default: '={{ $parameter.historyEndDate ? new Date($parameter.historyEndDate).toISOString() : undefined }}',
530
+ routing: { send: { type: 'query', property: 'endDate' } },
531
+ },
458
532
  // Hidden fields para deliverAt / deliverUntil normalizados
459
533
  {
460
534
  displayName: 'Deliver At',
@@ -662,46 +736,30 @@ class PilotStatus {
662
736
  displayOptions: { show: { resource: ['apiKey'] } },
663
737
  options: [
664
738
  {
665
- name: 'Create',
666
- value: 'create',
667
- description: 'Create a new API Key',
668
- action: 'Create an api key',
739
+ name: 'Regenerate',
740
+ value: 'regenerate',
741
+ description: "Regenerate a number's default API key (tenant-scoped)",
742
+ action: 'Regenerate an api key',
669
743
  routing: { request: { method: 'POST', url: '/api-keys' } },
670
744
  },
671
745
  {
672
746
  name: 'Get Many',
673
747
  value: 'getAll',
674
- description: 'Get many API Keys',
748
+ description: "Get many API Keys — one entry per number (the most recently created key), with the real key revealed when the credential is tenant-scoped. Older keys of the same number are not listed, but they keep working.",
675
749
  action: 'Get many api keys',
676
750
  routing: { request: { method: 'GET', url: '/api-keys' } },
677
751
  },
678
752
  ],
679
753
  default: 'getAll',
680
754
  },
681
- {
682
- displayName: 'Name',
683
- name: 'name',
684
- type: 'string',
685
- displayOptions: { show: { resource: ['apiKey'], operation: ['create'] } },
686
- default: '',
687
- required: true,
688
- routing: { send: { type: 'body', property: 'name' } },
689
- },
690
- {
691
- displayName: 'Retention Days',
692
- name: 'retentionDays',
693
- type: 'number',
694
- displayOptions: { show: { resource: ['apiKey'], operation: ['create'] } },
695
- default: 3650,
696
- routing: { send: { type: 'body', property: 'retentionDays' } },
697
- },
698
755
  {
699
756
  displayName: 'WhatsApp Number ID',
700
757
  name: 'whatsappNumberId',
701
758
  type: 'string',
702
- displayOptions: { show: { resource: ['apiKey'], operation: ['create'] } },
759
+ required: true,
760
+ displayOptions: { show: { resource: ['apiKey'], operation: ['regenerate'] } },
703
761
  default: '',
704
- description: 'ID of the WhatsApp number to link to this API key',
762
+ description: 'ID of the WhatsApp number whose default API key to regenerate',
705
763
  routing: { send: { type: 'body', property: 'whatsappNumberId' } },
706
764
  },
707
765
  // ----------------------------------
@@ -724,7 +782,7 @@ class PilotStatus {
724
782
  {
725
783
  name: 'Get Status',
726
784
  value: 'getStatus',
727
- description: 'Get connection status of a number',
785
+ description: 'Get connection status of a number. Returns state plus stale — when true the provider did not answer and this is the last known value (lastKnownAt); when false it is a live reading (checkedAt). On failure the body carries code: PROVIDER_NOT_CONFIGURED is permanent (stop polling), UPSTREAM_TIMEOUT/UPSTREAM_ERROR are transient (retry).',
728
786
  action: 'Get status of a number',
729
787
  routing: { request: { method: 'GET', url: '=/numbers/{{$parameter.numberId}}/status' } },
730
788
  },
@@ -749,6 +807,20 @@ class PilotStatus {
749
807
  action: 'Remote pairing a number',
750
808
  routing: { request: { method: 'POST', url: '/numbers/remote-pairing' } },
751
809
  },
810
+ {
811
+ name: 'Get',
812
+ value: 'get',
813
+ description: 'Full detail of one number, including the settings block (history + Evolution GO advanced settings) and, for official Meta numbers, the nested meta block',
814
+ action: 'Get a number',
815
+ routing: { request: { method: 'GET', url: '=/numbers/{{$parameter.numberId}}' } },
816
+ },
817
+ {
818
+ name: 'Update Settings',
819
+ value: 'updateSettings',
820
+ description: 'Change per-number settings. This is the ONLY settings endpoint — there is no POST /numbers/{id}/settings, and Evolution syncFullHistory does not exist here (use History Import Enabled). Partial: only the fields you fill in change.',
821
+ action: 'Update settings of a number',
822
+ routing: { request: { method: 'PATCH', url: '=/numbers/{{$parameter.numberId}}' } },
823
+ },
752
824
  ],
753
825
  default: 'create',
754
826
  },
@@ -771,31 +843,123 @@ class PilotStatus {
771
843
  description: 'E.164 format (e.g. +5511999999999)',
772
844
  routing: { send: { type: 'body', property: 'number' } },
773
845
  },
774
- {
775
- displayName: 'Link to API Key',
776
- name: 'linkToApiKey',
777
- type: 'boolean',
778
- displayOptions: { show: { resource: ['number'], operation: ['create', 'remotePairing'] } },
779
- default: true,
780
- routing: { send: { type: 'body', property: 'linkToApiKey' } },
781
- },
782
- {
783
- displayName: 'Send via WhatsApp',
784
- name: 'sendViaWhatsApp',
785
- type: 'boolean',
786
- displayOptions: { show: { resource: ['number'], operation: ['remotePairing'] } },
787
- default: false,
788
- description: 'Whether to send the pairing code via WhatsApp message',
789
- routing: { send: { type: 'body', property: 'sendViaWhatsApp' } },
790
- },
846
+ // Removed: 'Link to API Key' (linkToApiKey) and 'Send via WhatsApp'
847
+ // (sendViaWhatsApp). Both were toggles that no longer do anything.
848
+ // linkToApiKey used to re-point the calling key at the new number, silently
849
+ // unscoping it from the number it was bound to — it is retired server-side
850
+ // and `linkedApiKeyId` always comes back null. sendViaWhatsApp no longer
851
+ // delivers the link; the endpoint hands back `remotePairingUrl` for the
852
+ // workflow to deliver. Both fields are still ACCEPTED by the API, so any
853
+ // saved workflow that carries them keeps running unchanged.
791
854
  {
792
855
  displayName: 'Number Instance ID',
793
856
  name: 'numberId',
794
857
  type: 'string',
795
- displayOptions: { show: { resource: ['number'], operation: ['getStatus', 'connect', 'delete'] } },
858
+ displayOptions: {
859
+ show: {
860
+ resource: ['number'],
861
+ operation: ['getStatus', 'connect', 'delete', 'get', 'updateSettings'],
862
+ },
863
+ },
796
864
  default: '',
797
865
  required: true,
798
866
  },
867
+ // Number: Update Settings
868
+ //
869
+ // Os seis campos do Evolution GO são tri-estado (true / false / herdar do
870
+ // provider), e `type: 'boolean'` do n8n não produz null — por isso são
871
+ // `options` com strings, traduzidas no hidden normalizado abaixo. Deixar de
872
+ // fora do collection é o que mantém o PATCH parcial: campo não preenchido
873
+ // não vai no corpo e portanto não é alterado.
874
+ {
875
+ displayName: 'Settings',
876
+ name: 'numberSettings',
877
+ type: 'collection',
878
+ placeholder: 'Add setting',
879
+ displayOptions: { show: { resource: ['number'], operation: ['updateSettings'] } },
880
+ default: {},
881
+ options: [
882
+ {
883
+ displayName: 'History Import Enabled',
884
+ name: 'historyImportEnabled',
885
+ type: 'boolean',
886
+ default: true,
887
+ description: 'Whether to import the history the provider dumps on connect (up to 30 days back) into the chat. Applies to every provider.',
888
+ },
889
+ {
890
+ displayName: 'Webhook Historical Messages',
891
+ name: 'webhookHistoricalMessages',
892
+ type: 'boolean',
893
+ default: false,
894
+ description: 'Whether to DELIVER those historical messages to your webhooks. Off by default: every reconnect replays the history and your integration cannot tell it apart from new traffic. To read history use the Message → Get History operation instead.',
895
+ },
896
+ {
897
+ displayName: 'Always Online',
898
+ name: 'alwaysOnline',
899
+ type: 'options',
900
+ options: exports.GO_TRISTATE,
901
+ default: 'inherit',
902
+ description: 'Keep the WhatsApp presence permanently online. Evolution GO only.',
903
+ },
904
+ {
905
+ displayName: 'Reject Call',
906
+ name: 'rejectCall',
907
+ type: 'options',
908
+ options: exports.GO_TRISTATE,
909
+ default: 'inherit',
910
+ description: 'Auto-reject incoming calls. Evolution GO only.',
911
+ },
912
+ {
913
+ displayName: 'Reject Call Message',
914
+ name: 'msgRejectCall',
915
+ type: 'string',
916
+ typeOptions: { maxValue: 1000 },
917
+ default: '',
918
+ description: 'Text replied when a call is rejected (max 1000 chars). Leave empty to keep the current value; use Reset Reject Call Message to clear it. Evolution GO only.',
919
+ },
920
+ {
921
+ displayName: 'Reset Reject Call Message',
922
+ name: 'msgRejectCallReset',
923
+ type: 'boolean',
924
+ default: false,
925
+ description: 'Whether to reset the reject-call message to the provider default. Wins over Reject Call Message.',
926
+ },
927
+ {
928
+ displayName: 'Read Messages',
929
+ name: 'readMessages',
930
+ type: 'options',
931
+ options: exports.GO_TRISTATE,
932
+ default: 'inherit',
933
+ description: 'Mark every received message as read. Evolution GO only.',
934
+ },
935
+ {
936
+ displayName: 'Ignore Groups',
937
+ name: 'ignoreGroups',
938
+ type: 'options',
939
+ options: exports.GO_TRISTATE,
940
+ default: 'inherit',
941
+ description: 'Drop group messages inside the provider. GO dialect (ignoreGroups), not the v2 groupsIgnore. Setting it explicitly beats the value derived from your group webhook subscriptions. Evolution GO only.',
942
+ },
943
+ {
944
+ displayName: 'Ignore Status',
945
+ name: 'ignoreStatus',
946
+ type: 'options',
947
+ options: exports.GO_TRISTATE,
948
+ default: 'inherit',
949
+ description: 'Drop status/stories updates. Evolution GO only.',
950
+ },
951
+ ],
952
+ },
953
+ {
954
+ displayName: 'Settings',
955
+ name: 'settingsNormalized',
956
+ type: 'hidden',
957
+ displayOptions: { show: { resource: ['number'], operation: ['updateSettings'] } },
958
+ // `|| undefined` no fim: um `settings: {}` seria rejeitado com 400
959
+ // EMPTY_PATCH pelo servidor.
960
+ default: '={{ (() => { const c = $parameter.numberSettings || {}; const out = {}; if (c.historyImportEnabled !== undefined) out.historyImportEnabled = c.historyImportEnabled; if (c.webhookHistoricalMessages !== undefined) out.webhookHistoricalMessages = c.webhookHistoricalMessages; for (const k of ["alwaysOnline","rejectCall","readMessages","ignoreGroups","ignoreStatus"]) { const v = c[k]; if (v === "on") out[k] = true; else if (v === "off") out[k] = false; else if (v === "default") out[k] = null; } if (c.msgRejectCallReset === true) out.msgRejectCall = null; else if (c.msgRejectCall) out.msgRejectCall = c.msgRejectCall; return Object.keys(out).length ? out : undefined; })() }}',
961
+ routing: { send: { type: 'body', property: 'settings' } },
962
+ },
799
963
  // ----------------------------------
800
964
  // Template Operations
801
965
  // ----------------------------------
@@ -943,6 +1107,217 @@ class PilotStatus {
943
1107
  required: true,
944
1108
  description: 'The remote pairing token',
945
1109
  },
1110
+ // ----------------------------------
1111
+ // Call Operations (WhatsApp Business Calling — Meta Cloud API + web/Pilot Status numbers;
1112
+ // settings/permissions are Meta-only, Play/Realtime Session are web-only)
1113
+ // ----------------------------------
1114
+ {
1115
+ displayName: 'Operation',
1116
+ name: 'operation',
1117
+ type: 'options',
1118
+ noDataExpression: true,
1119
+ displayOptions: { show: { resource: ['call'] } },
1120
+ options: [
1121
+ {
1122
+ name: 'Initiate',
1123
+ value: 'initiate',
1124
+ description: 'Start a business-initiated voice call (BIC). Meta numbers: requires the SDP offer and a prior user call permission; BIC minutes are billed by Meta directly on the WABA (6s pulses, only when answered). Web (Pilot Status) numbers: no SDP, no permission step and no Meta billing. Pilot Status does not charge.',
1125
+ action: 'Initiate a call',
1126
+ routing: { request: { method: 'POST', url: '/calls' } },
1127
+ },
1128
+ {
1129
+ name: 'Terminate',
1130
+ value: 'terminate',
1131
+ description: 'Hang up an active call',
1132
+ action: 'Terminate a call',
1133
+ routing: {
1134
+ request: { method: 'POST', url: '=/calls/{{$parameter.callId}}/terminate' },
1135
+ },
1136
+ },
1137
+ {
1138
+ name: 'Play',
1139
+ value: 'play',
1140
+ description: 'Play an audio file into an active call by URL (.mp3/.wav/.opus). Web (Pilot Status) numbers only — Meta numbers return 400 FEATURE_NOT_SUPPORTED. Queued and played on connect when the call is not active yet.',
1141
+ action: 'Play audio into a call',
1142
+ routing: {
1143
+ request: { method: 'POST', url: '=/calls/{{$parameter.callId}}/play' },
1144
+ },
1145
+ },
1146
+ {
1147
+ name: 'Realtime Session',
1148
+ value: 'realtimeSession',
1149
+ description: 'Open a short-lived full-duplex realtime media session on an active call. Web (Pilot Status) numbers only. Returns { wsUrl, token, expiresInSeconds }: connect a WebSocket to wsUrl and exchange raw binary PCM16 LE audio frames (NOT WebRTC; single-use token, ~2 min).',
1150
+ action: 'Open a realtime media session',
1151
+ routing: {
1152
+ request: { method: 'POST', url: '=/calls/{{$parameter.callId}}/realtime-session' },
1153
+ },
1154
+ },
1155
+ {
1156
+ name: 'Get Settings',
1157
+ value: 'getSettings',
1158
+ description: "Read the number's calling settings (the Meta calling object). Meta numbers only.",
1159
+ action: 'Get calling settings',
1160
+ routing: { request: { method: 'GET', url: '/calls/settings' } },
1161
+ },
1162
+ {
1163
+ name: 'Update Settings',
1164
+ value: 'updateSettings',
1165
+ description: 'Enable/disable calling on the number (partial settings update). Meta numbers only.',
1166
+ action: 'Update calling settings',
1167
+ routing: { request: { method: 'PUT', url: '/calls/settings' } },
1168
+ },
1169
+ {
1170
+ name: 'Get Permission',
1171
+ value: 'getPermission',
1172
+ description: 'Check whether the business may call a user (required before Initiate on Meta numbers). Meta numbers only.',
1173
+ action: 'Get call permission',
1174
+ routing: { request: { method: 'GET', url: '/calls/permissions' } },
1175
+ },
1176
+ {
1177
+ name: 'Request Permission',
1178
+ value: 'requestPermission',
1179
+ description: 'Send the interactive call-permission request to a user (inside the 24h service window). Meta numbers only.',
1180
+ action: 'Request call permission',
1181
+ routing: { request: { method: 'POST', url: '/calls/permissions/request' } },
1182
+ },
1183
+ ],
1184
+ default: 'getSettings',
1185
+ },
1186
+ // Call: Initiate
1187
+ {
1188
+ displayName: 'To',
1189
+ name: 'callTo',
1190
+ type: 'string',
1191
+ description: 'User phone to call (E.164, e.g. +5511999999999)',
1192
+ displayOptions: { show: { resource: ['call'], operation: ['initiate'] } },
1193
+ default: '',
1194
+ required: true,
1195
+ routing: { send: { type: 'body', property: 'to' } },
1196
+ },
1197
+ {
1198
+ displayName: 'SDP Offer',
1199
+ name: 'callSdp',
1200
+ type: 'string',
1201
+ typeOptions: { rows: 4 },
1202
+ description: 'SDP offer (RFC 8866) produced by your WebRTC client — REQUIRED for Meta Cloud API numbers (business-side SDP must use a=setup:active; media flows browser↔WhatsApp directly). LEAVE EMPTY for web (Pilot Status) numbers: their call media is handled server-side (no SDP).',
1203
+ displayOptions: { show: { resource: ['call'], operation: ['initiate'] } },
1204
+ default: '',
1205
+ },
1206
+ {
1207
+ displayName: 'SDP Offer',
1208
+ name: 'callSdpNormalized',
1209
+ type: 'hidden',
1210
+ displayOptions: { show: { resource: ['call'], operation: ['initiate'] } },
1211
+ default: '={{ $parameter.callSdp || undefined }}',
1212
+ routing: { send: { type: 'body', property: 'sdp' } },
1213
+ },
1214
+ {
1215
+ displayName: 'Opaque Callback Data',
1216
+ name: 'callBizOpaqueCallbackData',
1217
+ type: 'string',
1218
+ description: 'Optional opaque data echoed back on the call.ended webhook',
1219
+ displayOptions: { show: { resource: ['call'], operation: ['initiate'] } },
1220
+ default: '',
1221
+ },
1222
+ {
1223
+ displayName: 'Opaque Callback Data',
1224
+ name: 'callBizOpaqueCallbackDataNormalized',
1225
+ type: 'hidden',
1226
+ displayOptions: { show: { resource: ['call'], operation: ['initiate'] } },
1227
+ default: '={{ $parameter.callBizOpaqueCallbackData || undefined }}',
1228
+ routing: { send: { type: 'body', property: 'bizOpaqueCallbackData' } },
1229
+ },
1230
+ // Call: Terminate / Play / Realtime Session
1231
+ {
1232
+ displayName: 'Call ID',
1233
+ name: 'callId',
1234
+ type: 'string',
1235
+ description: 'The Pilot Status call id (call_...) OR the provider call id (Meta wacid / Evolution GO CallID)',
1236
+ displayOptions: {
1237
+ show: { resource: ['call'], operation: ['terminate', 'play', 'realtimeSession'] },
1238
+ },
1239
+ default: '',
1240
+ required: true,
1241
+ },
1242
+ // Call: Play
1243
+ {
1244
+ displayName: 'Media URL',
1245
+ name: 'callMediaUrl',
1246
+ type: 'string',
1247
+ description: 'Public http(s) URL of the audio file to play into the call (.mp3, .wav or .opus)',
1248
+ displayOptions: { show: { resource: ['call'], operation: ['play'] } },
1249
+ default: '',
1250
+ required: true,
1251
+ routing: { send: { type: 'body', property: 'mediaUrl' } },
1252
+ },
1253
+ // Call: Realtime Session
1254
+ {
1255
+ displayName: 'Mode',
1256
+ name: 'callRealtimeMode',
1257
+ type: 'options',
1258
+ options: [
1259
+ { name: 'Talk (send mic + receive)', value: 'talk' },
1260
+ { name: 'Listen (receive only)', value: 'listen' },
1261
+ ],
1262
+ description: 'talk sends your audio AND receives the peer audio; listen only receives. The returned wsUrl speaks raw binary PCM16 LE frames over WebSocket.',
1263
+ displayOptions: { show: { resource: ['call'], operation: ['realtimeSession'] } },
1264
+ default: 'talk',
1265
+ required: true,
1266
+ routing: { send: { type: 'body', property: 'mode' } },
1267
+ },
1268
+ // Call: Update Settings
1269
+ {
1270
+ displayName: 'Status',
1271
+ name: 'callSettingsStatus',
1272
+ type: 'options',
1273
+ options: [
1274
+ { name: 'Enabled', value: 'ENABLED' },
1275
+ { name: 'Disabled', value: 'DISABLED' },
1276
+ ],
1277
+ description: 'Enable or disable WhatsApp calling on the number',
1278
+ displayOptions: { show: { resource: ['call'], operation: ['updateSettings'] } },
1279
+ default: 'ENABLED',
1280
+ required: true,
1281
+ routing: { send: { type: 'body', property: 'status' } },
1282
+ },
1283
+ // Call: Get Permission
1284
+ {
1285
+ displayName: 'To',
1286
+ name: 'callPermissionTo',
1287
+ type: 'string',
1288
+ description: 'User phone to probe (E.164)',
1289
+ displayOptions: { show: { resource: ['call'], operation: ['getPermission'] } },
1290
+ default: '',
1291
+ required: true,
1292
+ routing: { send: { type: 'query', property: 'to' } },
1293
+ },
1294
+ // Call: Request Permission
1295
+ {
1296
+ displayName: 'To',
1297
+ name: 'callPermissionRequestTo',
1298
+ type: 'string',
1299
+ description: 'User phone (E.164)',
1300
+ displayOptions: { show: { resource: ['call'], operation: ['requestPermission'] } },
1301
+ default: '',
1302
+ required: true,
1303
+ routing: { send: { type: 'body', property: 'to' } },
1304
+ },
1305
+ {
1306
+ displayName: 'Text',
1307
+ name: 'callPermissionText',
1308
+ type: 'string',
1309
+ description: 'Optional reason shown on the permission request',
1310
+ displayOptions: { show: { resource: ['call'], operation: ['requestPermission'] } },
1311
+ default: '',
1312
+ },
1313
+ {
1314
+ displayName: 'Text',
1315
+ name: 'callPermissionTextNormalized',
1316
+ type: 'hidden',
1317
+ displayOptions: { show: { resource: ['call'], operation: ['requestPermission'] } },
1318
+ default: '={{ $parameter.callPermissionText || undefined }}',
1319
+ routing: { send: { type: 'body', property: 'text' } },
1320
+ },
946
1321
  ],
947
1322
  };
948
1323
  }
@@ -81,6 +81,26 @@ class PilotStatusTrigger {
81
81
  name: 'Number Removed',
82
82
  value: 'number.removed',
83
83
  },
84
+ {
85
+ name: 'Call Ringing',
86
+ value: 'call.ringing',
87
+ },
88
+ {
89
+ name: 'Call Connected',
90
+ value: 'call.connected',
91
+ },
92
+ {
93
+ name: 'Call Ended',
94
+ value: 'call.ended',
95
+ },
96
+ {
97
+ name: 'Call Missed',
98
+ value: 'call.missed',
99
+ },
100
+ {
101
+ name: 'Call Permission Updated',
102
+ value: 'call.permission_updated',
103
+ },
84
104
  ],
85
105
  default: '*',
86
106
  description: 'The event to listen to',
@@ -97,7 +117,7 @@ class PilotStatusTrigger {
97
117
  name: 'payloadNotice',
98
118
  type: 'notice',
99
119
  default: '',
100
- description: 'The full JSON body is passed through (event + data). Phones are E.164 with a leading "+"; message.* events carry from/to/numberId/id/messageId/type/createdAt and may include an optional correlationId. message.reply adds contentReplied and quotedMessageId.',
120
+ description: 'The full JSON body is passed through (event + data). Phones are E.164 with a leading "+"; message.* events carry from/to/numberId/id/messageId/type/createdAt and may include an optional correlationId. message.reply adds contentReplied and quotedMessageId. call.* events (WhatsApp Business Calling — Meta Cloud API and web/Pilot Status numbers; call.permission_updated is Meta-only) are FLAT — fields sit next to event with no data wrapper: { event, callId, externalCallId?, direction, status, from, to, timestamp, duration? }. externalCallId is the provider call id (Meta wacid or Evolution GO CallID). On every number.* event, data.numberId is the WhatsApp NUMBER id — the same id GET /v1/numbers returns and the other number operations take. It used to carry the underlying instance id on number.created/connected/removed, so a workflow that stored that value and matched later events against it never matched.',
101
121
  },
102
122
  ],
103
123
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-pilot-status",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "n8n node for Pilot Status API",
5
5
  "keywords": [
6
6
  "n8ncommunity",