@ivanlaomarketing/n8n-nodes-risveglia 0.0.0-stage → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ivan Lao <info@laoivan.com> - https://laoivan.com
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,62 @@
1
- # Temporary Holding Version
1
+ # n8n-nodes-risveglia
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm version](https://img.shields.io/npm/v/@ivanlaomarketing/n8n-nodes-risveglia?color=25D366&label=npm)](https://www.npmjs.com/package/@ivanlaomarketing/n8n-nodes-risveglia)
4
+ [![n8n compatible](https://img.shields.io/badge/n8n-compatible-FF6347)](https://n8n.io)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
6
+ [![Built by Ivan Lao](https://img.shields.io/badge/Built%20by-Ivan%20Lao-FF6B35)](https://laoivan.com)
7
+
8
+ Nodi n8n per [RisveglIA](https://risveglia.it), l'archivio e l'assistente delle chat WhatsApp della tua attività.
9
+
10
+ > **English.** n8n community node for RisveglIA (WhatsApp archive and assistant for businesses): send WhatsApp messages, manage contacts, deals, labels, reminders, groups and channels, AI agent and media, read the chat archive, and start workflows on RisveglIA events. The node UI is in Italian.
11
+
12
+ ## Cosa contiene
13
+
14
+ - **RisveglIA**: invia messaggi WhatsApp, gestisce contatti e trattative, gruppi e canali, agente AI e media, e legge l'archivio delle chat. Si può usare anche come strumento di un AI Agent.
15
+ - **RisveglIA Trigger**: avvia il workflow quando succede qualcosa in RisveglIA, per esempio un messaggio ricevuto o inviato. L'iscrizione si crea e si cancella da sola quando attivi o spegni il workflow, e ogni evento arriva firmato.
16
+
17
+ ## Installazione
18
+
19
+ In n8n apri **Settings > Community nodes > Install** e scrivi:
20
+
21
+ ```
22
+ @ivanlaomarketing/n8n-nodes-risveglia
23
+ ```
24
+
25
+ Il trigger ha bisogno che n8n sia raggiungibile da internet con un indirizzo https.
26
+
27
+ ## Credenziale
28
+
29
+ 1. In RisveglIA apri **Collegamenti** e crea un **token personale**. Scegli i permessi che servono al workflow: per esempio, per inviare messaggi serve il permesso di invio.
30
+ 2. In n8n crea una credenziale **RisveglIA API** e incolla il token. L'indirizzo resta quello predefinito, `https://app.risveglia.it/api`.
31
+
32
+ Il token dà accesso ai tuoi dati: tienilo riservato e, se non ti serve più, revocalo da Collegamenti.
33
+
34
+ ## Note
35
+
36
+ - **Chiave di idempotenza.** «Invia un messaggio» e «Crea promemoria» accettano una chiave di idempotenza. Se il workflow ripete la stessa chiamata con la stessa chiave, il messaggio parte una volta sola.
37
+ - **Elenchi.** Le risposte che contengono un elenco arrivano come un solo elemento. Per lavorare un elemento alla volta usa **Split Out**.
38
+ - **Limiti.** Valgono le stesse regole e gli stessi limiti di invio del portale RisveglIA.
39
+
40
+ ## Sviluppo
41
+
42
+ ```bash
43
+ npm install
44
+ npm run build
45
+ npm run lint
46
+ ```
47
+
48
+ Il codice dei nodi nasce dal catalogo delle operazioni di RisveglIA e viene aggiornato da lì: non modificare a mano `nodes/RisveglIa/catalogo.ts`.
49
+
50
+ La pubblicazione su npm parte da GitHub Actions quando si crea un tag `vX.Y.Z` uguale alla versione in `package.json`, con provenance.
51
+
52
+ ## Autore
53
+
54
+ **Ivan Lao**, consulente di Marketing Automation e AI dal 2015, Make Certified Partner e Meta Tech Provider WhatsApp Business Platform.
55
+
56
+ - Sito: [laoivan.com](https://laoivan.com)
57
+ - LinkedIn: [ivanlaomarketing](https://www.linkedin.com/in/ivanlaomarketing/)
58
+ - YouTube: [@IvanLaoMarketing](https://www.youtube.com/@IvanLaoMarketing)
59
+
60
+ ## Licenza
61
+
62
+ [MIT](LICENSE)
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RisveglIaApi = void 0;
4
+ /**
5
+ * Token personale di RisveglIA (rsv_pat_...): si crea nel portale, Impostazioni, Collegamenti, con gli ambiti che servono
6
+ * al flusso. Il token agisce come la persona che l'ha creato, con il suo ruolo e i suoi permessi di adesso.
7
+ */
8
+ class RisveglIaApi {
9
+ name = "risveglIaApi";
10
+ displayName = "RisveglIA API";
11
+ documentationUrl = "https://risveglia.it/guide";
12
+ icon = "file:../nodes/RisveglIa/risveglia.svg";
13
+ properties = [
14
+ {
15
+ displayName: "Token personale",
16
+ name: "token",
17
+ type: "string",
18
+ typeOptions: { password: true },
19
+ default: "",
20
+ required: true,
21
+ placeholder: "rsv_pat_...",
22
+ description: "Crealo in RisveglIA: Impostazioni, Collegamenti, Crea un token personale. Si vede una sola volta.",
23
+ },
24
+ {
25
+ displayName: "Indirizzo di RisveglIA",
26
+ name: "baseUrl",
27
+ type: "string",
28
+ default: "https://app.risveglia.it/api",
29
+ description: "Lascia il valore proposto, salvo indicazioni diverse dell'assistenza.",
30
+ },
31
+ ];
32
+ authenticate = {
33
+ type: "generic",
34
+ properties: { headers: { Authorization: "=Bearer {{$credentials.token}}" } },
35
+ };
36
+ test = {
37
+ request: { baseURL: "={{$credentials.baseUrl.replace(/\\/+$/, '')}}", url: "/v1/integrazioni/io", method: "GET" },
38
+ };
39
+ }
40
+ exports.RisveglIaApi = RisveglIaApi;
@@ -0,0 +1,237 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RisveglIa = exports.parametriDi = exports.risorsaDi = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ const catalogo_1 = require("./catalogo");
6
+ const richiesta_1 = require("./richiesta");
7
+ /** Valore della risorsa nel nodo: il gruppo del catalogo senza spazi né accenti. */
8
+ const risorsaDi = (gruppo) => gruppo
9
+ .toLowerCase()
10
+ .normalize("NFD")
11
+ .replace(/[̀-ͯ]/g, "")
12
+ .replace(/[^a-z0-9]+/g, "-")
13
+ .replace(/^-|-$/g, "");
14
+ exports.risorsaDi = risorsaDi;
15
+ const RISORSA_STRUMENTI = "letture";
16
+ const OPERAZIONE_STRUMENTO = "strumento.esegui";
17
+ /** Parametri del percorso (fra graffe) di un'operazione, nell'ordine in cui compaiono. */
18
+ const parametriDi = (op) => [...op.path.matchAll(/\{(\w+)\}/g)].map((m) => m[1]);
19
+ exports.parametriDi = parametriDi;
20
+ const conCorpo = (op) => op.method === "POST" || op.method === "PUT" || op.method === "PATCH";
21
+ /** Esempi di corpo e di parametri per le operazioni più usate: il resto parte da {}. */
22
+ const esempiCorpo = {
23
+ "invii.crea": { kind: "testo", conversationId: "", text: "" },
24
+ "etichette.crea": { name: "" },
25
+ "chat.etichette": { labelIds: [] },
26
+ "promemoria.crea": { title: "", chatId: "", dueAt: "", timezone: "Europe/Rome" },
27
+ "promemoria.aggiorna": { status: "done", version: 1 },
28
+ "trattative.card.crea": { chatId: "" },
29
+ "trattative.card.sposta": { stageId: "", version: 1 },
30
+ "webhook.iscrivi": { name: "", url: "https://", events: [] },
31
+ };
32
+ const esempiQuery = {
33
+ "invii.elenca": { conversationId: "" },
34
+ };
35
+ const nomiParametri = {
36
+ id: { displayName: "ID", description: "Identificativo dell'elemento, come lo restituisce un'altra operazione di RisveglIA" },
37
+ azione: { displayName: "Azione", description: "Nome dell'azione, come indicato nella guida dell'operazione" },
38
+ };
39
+ function proprieta() {
40
+ const risorse = [
41
+ ...catalogo_1.gruppi.map((g) => ({ name: g, value: (0, exports.risorsaDi)(g) })),
42
+ { name: "Archivio", value: RISORSA_STRUMENTI, description: "Chat, messaggi, contatti, trattative, promemoria e telefonate" },
43
+ ];
44
+ const props = [
45
+ { displayName: "Risorsa", name: "resource", type: "options", noDataExpression: true, options: risorse, default: (0, exports.risorsaDi)("Messaggi") },
46
+ ];
47
+ for (const g of catalogo_1.gruppi) {
48
+ const ops = catalogo_1.operazioni.filter((o) => o.group === g);
49
+ const primaOperazione = ops[0]?.id ?? "";
50
+ props.push({
51
+ displayName: "Operazione",
52
+ name: "operation",
53
+ type: "options",
54
+ noDataExpression: true,
55
+ displayOptions: { show: { resource: [(0, exports.risorsaDi)(g)] } },
56
+ options: ops.map((o) => ({ name: o.title, value: o.id, action: o.title, description: `${o.method} ${o.path}` })),
57
+ default: primaOperazione,
58
+ });
59
+ }
60
+ props.push({
61
+ displayName: "Operazione",
62
+ name: "operation",
63
+ type: "options",
64
+ noDataExpression: true,
65
+ displayOptions: { show: { resource: [RISORSA_STRUMENTI] } },
66
+ options: [{ name: "Leggi", value: OPERAZIONE_STRUMENTO, action: "Leggi archivio" }],
67
+ default: OPERAZIONE_STRUMENTO,
68
+ }, {
69
+ // Nomi in italiano: la regola chiede «Name or ID» e la frase inglese, che qui stonerebbero con il resto del nodo.
70
+ // eslint-disable-next-line n8n-nodes-base/node-param-display-name-wrong-for-dynamic-options
71
+ displayName: "Lettura",
72
+ name: "strumento",
73
+ type: "options",
74
+ typeOptions: { loadOptionsMethod: "strumenti" },
75
+ displayOptions: { show: { operation: [OPERAZIONE_STRUMENTO] } },
76
+ default: "",
77
+ required: true,
78
+ // eslint-disable-next-line n8n-nodes-base/node-param-description-wrong-for-dynamic-options
79
+ description: "Le letture ammesse dal token. Scegli dall'elenco o usa un'espressione.",
80
+ }, {
81
+ displayName: "Argomenti (JSON)",
82
+ name: "argomenti",
83
+ type: "json",
84
+ displayOptions: { show: { operation: [OPERAZIONE_STRUMENTO] } },
85
+ default: "{}",
86
+ description: "Argomenti della lettura, per esempio {\"query\": \"preventivo\"}",
87
+ });
88
+ const nomi = [...new Set(catalogo_1.operazioni.flatMap((o) => (0, exports.parametriDi)(o)))];
89
+ for (const nome of nomi) {
90
+ props.push({
91
+ displayName: nomiParametri[nome]?.displayName ?? nome,
92
+ name: `percorso_${nome}`,
93
+ type: "string",
94
+ required: true,
95
+ default: "",
96
+ displayOptions: { show: { operation: catalogo_1.operazioni.filter((o) => (0, exports.parametriDi)(o).includes(nome)).map((o) => o.id) } },
97
+ description: nomiParametri[nome]?.description ?? "",
98
+ });
99
+ }
100
+ for (const op of catalogo_1.operazioni) {
101
+ if (conCorpo(op))
102
+ props.push({
103
+ displayName: "Corpo (JSON)",
104
+ name: "corpo",
105
+ type: "json",
106
+ default: JSON.stringify(esempiCorpo[op.id] ?? {}, null, 2),
107
+ displayOptions: { show: { operation: [op.id] } },
108
+ description: "Dati dell'operazione, come nella documentazione dell'API di RisveglIA",
109
+ });
110
+ else
111
+ props.push({
112
+ displayName: "Parametri (JSON)",
113
+ name: "parametri",
114
+ type: "json",
115
+ default: JSON.stringify(esempiQuery[op.id] ?? {}, null, 2),
116
+ displayOptions: { show: { operation: [op.id] } },
117
+ description: "Filtri dell'operazione, come nella documentazione dell'API di RisveglIA",
118
+ });
119
+ }
120
+ props.push({
121
+ displayName: "Chiave di idempotenza",
122
+ name: "chiaveIdempotenza",
123
+ type: "string",
124
+ default: "",
125
+ displayOptions: { show: { operation: catalogo_1.operazioni.filter((o) => o.idempotent).map((o) => o.id) } },
126
+ description: "Facoltativa: con la stessa chiave (da 8 a 200 caratteri) un nuovo tentativo restituisce quello già creato invece di farne un doppione, per esempio l'ID dell'elemento che ha fatto partire il flusso",
127
+ });
128
+ props.push({
129
+ displayName: "Campo del file",
130
+ name: "campoFile",
131
+ type: "string",
132
+ default: "data",
133
+ displayOptions: { show: { operation: ["media.file"] } },
134
+ description: "Nome del campo binario in cui mettere il file scaricato",
135
+ });
136
+ return props;
137
+ }
138
+ function json(ctx, nome, i) {
139
+ const raw = ctx.getNodeParameter(nome, i, "{}");
140
+ if (typeof raw !== "string")
141
+ return raw;
142
+ if (raw.trim() === "")
143
+ return {};
144
+ try {
145
+ const parsed = JSON.parse(raw);
146
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed))
147
+ return parsed;
148
+ }
149
+ catch {
150
+ // sotto
151
+ }
152
+ throw new n8n_workflow_1.NodeOperationError(ctx.getNode(), `Il campo ${nome} deve essere un oggetto JSON.`, { itemIndex: i });
153
+ }
154
+ class RisveglIa {
155
+ description = {
156
+ displayName: "RisveglIA",
157
+ name: "risveglIa",
158
+ icon: "file:risveglia.svg",
159
+ group: ["transform"],
160
+ version: 1,
161
+ subtitle: '={{$parameter["operation"]}}',
162
+ description: "Risposte WhatsApp, contatti e trattative, gruppi e canali, agente AI, media e attivatori di RisveglIA",
163
+ defaults: { name: "RisveglIA" },
164
+ inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
165
+ outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
166
+ usableAsTool: true,
167
+ credentials: [{ name: richiesta_1.CREDENZIALE, required: true }],
168
+ properties: proprieta(),
169
+ };
170
+ methods = {
171
+ loadOptions: {
172
+ /** Letture ammesse dal token, dall'elenco dell'API: cambiano con gli ambiti del token, non con la versione del nodo. */
173
+ async strumenti() {
174
+ const res = await (0, richiesta_1.chiama)(this, { method: "GET", path: "/operazioni" });
175
+ const tools = res.body.tools ?? [];
176
+ return tools.map((t) => ({ name: t.title || t.name, value: t.name, description: t.description }));
177
+ },
178
+ },
179
+ };
180
+ async execute() {
181
+ const items = this.getInputData();
182
+ const out = [];
183
+ for (let i = 0; i < items.length; i++) {
184
+ try {
185
+ const operation = this.getNodeParameter("operation", i);
186
+ if (operation === OPERAZIONE_STRUMENTO) {
187
+ const nome = this.getNodeParameter("strumento", i);
188
+ const res = await (0, richiesta_1.chiama)(this, { method: "POST", path: `/strumenti/${encodeURIComponent(nome)}`, body: json(this, "argomenti", i), itemIndex: i });
189
+ out.push({ json: res.body, pairedItem: { item: i } });
190
+ continue;
191
+ }
192
+ const op = catalogo_1.operazioni.find((o) => o.id === operation);
193
+ if (!op)
194
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operazione sconosciuta: ${operation}`, { itemIndex: i });
195
+ let path = op.path;
196
+ for (const nome of (0, exports.parametriDi)(op)) {
197
+ const valore = String(this.getNodeParameter(`percorso_${nome}`, i)).trim();
198
+ if (!/^[A-Za-z0-9-]{1,64}$/.test(valore))
199
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Valore non valido per ${nomiParametri[nome]?.displayName ?? nome}.`, { itemIndex: i });
200
+ path = path.replace(`{${nome}}`, valore);
201
+ }
202
+ const binario = op.id === "media.file";
203
+ const chiave = op.idempotent ? String(this.getNodeParameter("chiaveIdempotenza", i, "")).trim() : "";
204
+ const res = await (0, richiesta_1.chiama)(this, {
205
+ method: op.method,
206
+ path: `/api${path}`,
207
+ ...(conCorpo(op) ? { body: json(this, "corpo", i) } : { qs: json(this, "parametri", i) }),
208
+ binario,
209
+ ...(chiave ? { headers: { "Idempotency-Key": chiave } } : {}),
210
+ itemIndex: i,
211
+ });
212
+ if (binario) {
213
+ const campo = this.getNodeParameter("campoFile", i, "data");
214
+ const tipo = String(res.headers["content-type"] ?? "application/octet-stream");
215
+ const nomeFile = /filename="?([^";]+)"?/.exec(String(res.headers["content-disposition"] ?? ""))?.[1];
216
+ const dati = await this.helpers.prepareBinaryData(Buffer.from(res.body), nomeFile, tipo);
217
+ out.push({ json: { id: path.split("/")[3] }, binary: { [campo]: dati }, pairedItem: { item: i } });
218
+ continue;
219
+ }
220
+ const body = res.body;
221
+ if (Array.isArray(body))
222
+ out.push(...body.map((b) => ({ json: b, pairedItem: { item: i } })));
223
+ else
224
+ out.push({ json: (body ?? { ok: true }), pairedItem: { item: i } });
225
+ }
226
+ catch (error) {
227
+ if (this.continueOnFail()) {
228
+ out.push({ json: { error: error.message }, pairedItem: { item: i } });
229
+ continue;
230
+ }
231
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
232
+ }
233
+ }
234
+ return [out];
235
+ }
236
+ }
237
+ exports.RisveglIa = RisveglIa;
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RisveglIaTrigger = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ const catalogo_1 = require("./catalogo");
6
+ const firma_1 = require("./firma");
7
+ const richiesta_1 = require("./richiesta");
8
+ /**
9
+ * Attivatore: quando il flusso si attiva iscrive l'indirizzo di n8n agli eventi di RisveglIA (webhook in uscita, payload
10
+ * v1), quando si disattiva lo toglie. Ogni evento arriva firmato: senza firma valida il flusso non parte.
11
+ * Serve un token con l'ambito Attivatori; l'indirizzo di n8n deve essere pubblico e in https.
12
+ */
13
+ class RisveglIaTrigger {
14
+ description = {
15
+ displayName: "RisveglIA Trigger",
16
+ name: "risveglIaTrigger",
17
+ icon: "file:risveglia.svg",
18
+ group: ["trigger"],
19
+ version: 1,
20
+ subtitle: '={{($parameter["eventi"] || []).join(", ") || "Tutte le attività"}}',
21
+ description: "Fa partire il flusso a ogni messaggio, chiamata o cambio di etichetta su RisveglIA",
22
+ defaults: { name: "RisveglIA Trigger" },
23
+ inputs: [],
24
+ outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
25
+ credentials: [{ name: richiesta_1.CREDENZIALE, required: true }],
26
+ webhooks: [{ name: "default", httpMethod: "POST", responseMode: "onReceived", path: "webhook" }],
27
+ properties: [
28
+ {
29
+ displayName: "Eventi",
30
+ name: "eventi",
31
+ type: "multiOptions",
32
+ options: catalogo_1.eventi.map((e) => ({ name: e.name, value: e.value })),
33
+ default: [],
34
+ description: "Vuoto: tutte le attività, anche quelle che RisveglIA aggiungerà in futuro",
35
+ },
36
+ {
37
+ // eslint-disable-next-line n8n-nodes-base/node-param-display-name-wrong-for-dynamic-options
38
+ displayName: "Numero",
39
+ name: "numero",
40
+ type: "options",
41
+ typeOptions: { loadOptionsMethod: "numeri" },
42
+ default: "",
43
+ // eslint-disable-next-line n8n-nodes-base/node-param-description-wrong-for-dynamic-options
44
+ description: "Solo gli eventi di questo numero. Vuoto: tutti i numeri.",
45
+ },
46
+ {
47
+ displayName: "Nome Iscrizione",
48
+ name: "nome",
49
+ type: "string",
50
+ default: "n8n",
51
+ description: "Come appare in RisveglIA, Impostazioni, Webhook",
52
+ },
53
+ ],
54
+ };
55
+ methods = {
56
+ loadOptions: {
57
+ async numeri() {
58
+ const res = await (0, richiesta_1.chiama)(this, { method: "GET", path: "/api/v2/numeri" });
59
+ const items = res.body.items ?? [];
60
+ return [{ name: "Tutti", value: "" }, ...items.map((n) => ({ name: n.label || n.phone || n.id, value: n.id }))];
61
+ },
62
+ },
63
+ };
64
+ webhookMethods = {
65
+ default: {
66
+ async checkExists() {
67
+ const data = this.getWorkflowStaticData("node");
68
+ if (!data.webhookId)
69
+ return false;
70
+ const res = await (0, richiesta_1.chiama)(this, { method: "GET", path: "/api/v2/webhook" });
71
+ const url = this.getNodeWebhookUrl("default");
72
+ const found = (res.body.webhooks ?? []).some((w) => w.id === data.webhookId && w.url === url);
73
+ if (!found) {
74
+ delete data.webhookId;
75
+ delete data.secret;
76
+ }
77
+ return found;
78
+ },
79
+ async create() {
80
+ const url = this.getNodeWebhookUrl("default");
81
+ if (!url?.startsWith("https://"))
82
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), "RisveglIA manda gli eventi solo a indirizzi https: pubblica n8n con un indirizzo https.");
83
+ const numero = this.getNodeParameter("numero", "");
84
+ const body = {
85
+ name: this.getNodeParameter("nome", "n8n") || "n8n",
86
+ url,
87
+ events: this.getNodeParameter("eventi", []),
88
+ ...(numero ? { numberId: numero } : {}),
89
+ };
90
+ const res = await (0, richiesta_1.chiama)(this, { method: "POST", path: "/api/v2/webhook", body });
91
+ const out = res.body;
92
+ const data = this.getWorkflowStaticData("node");
93
+ data.webhookId = out.webhook.id;
94
+ data.secret = out.secret;
95
+ return true;
96
+ },
97
+ async delete() {
98
+ const data = this.getWorkflowStaticData("node");
99
+ if (data.webhookId) {
100
+ try {
101
+ await (0, richiesta_1.chiama)(this, { method: "DELETE", path: `/api/v2/webhook/${String(data.webhookId)}` });
102
+ }
103
+ catch (error) {
104
+ // Già tolta dal portale: va bene lo stesso. Ogni altro errore si mostra.
105
+ if (error.httpCode !== "404")
106
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
107
+ }
108
+ }
109
+ delete data.webhookId;
110
+ delete data.secret;
111
+ return true;
112
+ },
113
+ },
114
+ };
115
+ async webhook() {
116
+ const req = this.getRequestObject();
117
+ const secret = this.getWorkflowStaticData("node").secret;
118
+ const raw = req.rawBody ? req.rawBody.toString("utf8") : JSON.stringify(this.getBodyData());
119
+ const header = this.getHeaderData()[firma_1.INTESTAZIONE_FIRMA];
120
+ if (!secret || !(0, firma_1.firmaValida)(secret, typeof header === "string" ? header : undefined, raw)) {
121
+ this.getResponseObject().status(401).json({ error: "firma non valida" });
122
+ return { noWebhookResponse: true };
123
+ }
124
+ return { workflowData: [[{ json: this.getBodyData() }]] };
125
+ }
126
+ }
127
+ exports.RisveglIaTrigger = RisveglIaTrigger;
@@ -0,0 +1,516 @@
1
+ "use strict";
2
+ // File generato da scripts/genera-catalogo.ts (pnpm --filter @ivanlaomarketing/n8n-nodes-risveglia genera): non modificarlo a mano.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.eventi = exports.operazioni = exports.gruppi = void 0;
5
+ exports.gruppi = ["Messaggi", "Contatti e trattative", "Gruppi e canali", "Agente AI", "Media", "Campagne e automazioni", "Attivatori", "Account"];
6
+ exports.operazioni = [
7
+ {
8
+ "id": "numeri.elenca",
9
+ "method": "GET",
10
+ "path": "/v2/numeri",
11
+ "scope": "sources:read",
12
+ "group": "Account",
13
+ "title": "Numeri collegati e stato del collegamento",
14
+ "idempotent": false
15
+ },
16
+ {
17
+ "id": "invii.crea",
18
+ "method": "POST",
19
+ "path": "/v2/invii",
20
+ "scope": "messages:send",
21
+ "group": "Messaggi",
22
+ "title": "Invia una risposta, una reazione, una modifica o un'eliminazione",
23
+ "idempotent": true
24
+ },
25
+ {
26
+ "id": "invii.elenca",
27
+ "method": "GET",
28
+ "path": "/v2/invii",
29
+ "scope": "messages:send",
30
+ "group": "Messaggi",
31
+ "title": "Invii recenti di una chat e il loro stato",
32
+ "idempotent": false
33
+ },
34
+ {
35
+ "id": "invii.annulla",
36
+ "method": "POST",
37
+ "path": "/v2/invii/{id}/annulla",
38
+ "scope": "messages:send",
39
+ "group": "Messaggi",
40
+ "title": "Annulla un invio ancora in attesa",
41
+ "idempotent": false
42
+ },
43
+ {
44
+ "id": "invii.impostazioni",
45
+ "method": "GET",
46
+ "path": "/v2/invii/impostazioni",
47
+ "scope": "messages:send",
48
+ "group": "Messaggi",
49
+ "title": "Tetti e fasce orarie degli invii",
50
+ "idempotent": false
51
+ },
52
+ {
53
+ "id": "etichette.elenca",
54
+ "method": "GET",
55
+ "path": "/v2/etichette",
56
+ "scope": "contacts:read",
57
+ "group": "Contatti e trattative",
58
+ "title": "Elenca le etichette",
59
+ "idempotent": false
60
+ },
61
+ {
62
+ "id": "etichette.crea",
63
+ "method": "POST",
64
+ "path": "/v2/etichette",
65
+ "scope": "crm:write",
66
+ "group": "Contatti e trattative",
67
+ "title": "Crea un'etichetta",
68
+ "idempotent": false
69
+ },
70
+ {
71
+ "id": "chat.etichette",
72
+ "method": "PUT",
73
+ "path": "/v2/chats/{id}/etichette",
74
+ "scope": "crm:write",
75
+ "group": "Contatti e trattative",
76
+ "title": "Imposta le etichette di una chat",
77
+ "idempotent": false
78
+ },
79
+ {
80
+ "id": "promemoria.crea",
81
+ "method": "POST",
82
+ "path": "/v2/reminders",
83
+ "scope": "crm:write",
84
+ "group": "Contatti e trattative",
85
+ "title": "Crea un promemoria",
86
+ "idempotent": true
87
+ },
88
+ {
89
+ "id": "promemoria.aggiorna",
90
+ "method": "PATCH",
91
+ "path": "/v2/reminders/{id}",
92
+ "scope": "crm:write",
93
+ "group": "Contatti e trattative",
94
+ "title": "Aggiorna o chiude un promemoria",
95
+ "idempotent": false
96
+ },
97
+ {
98
+ "id": "promemoria.elimina",
99
+ "method": "DELETE",
100
+ "path": "/v2/reminders/{id}",
101
+ "scope": "crm:write",
102
+ "group": "Contatti e trattative",
103
+ "title": "Elimina un promemoria",
104
+ "idempotent": false
105
+ },
106
+ {
107
+ "id": "trattative.board",
108
+ "method": "GET",
109
+ "path": "/v2/trattative",
110
+ "scope": "opportunities:read",
111
+ "group": "Contatti e trattative",
112
+ "title": "Pipeline, fasi e card delle trattative",
113
+ "idempotent": false
114
+ },
115
+ {
116
+ "id": "trattative.card.crea",
117
+ "method": "POST",
118
+ "path": "/v2/trattative/card",
119
+ "scope": "crm:write",
120
+ "group": "Contatti e trattative",
121
+ "title": "Mette una chat in una pipeline",
122
+ "idempotent": false
123
+ },
124
+ {
125
+ "id": "trattative.card.sposta",
126
+ "method": "PATCH",
127
+ "path": "/v2/trattative/card/{id}",
128
+ "scope": "crm:write",
129
+ "group": "Contatti e trattative",
130
+ "title": "Sposta o aggiorna una card",
131
+ "idempotent": false
132
+ },
133
+ {
134
+ "id": "trattative.card.elimina",
135
+ "method": "DELETE",
136
+ "path": "/v2/trattative/card/{id}",
137
+ "scope": "crm:write",
138
+ "group": "Contatti e trattative",
139
+ "title": "Toglie una card dalla pipeline",
140
+ "idempotent": false
141
+ },
142
+ {
143
+ "id": "consensi.registra",
144
+ "method": "POST",
145
+ "path": "/v2/consensi",
146
+ "scope": "crm:write",
147
+ "group": "Contatti e trattative",
148
+ "title": "Registra un consenso o una disiscrizione",
149
+ "idempotent": false
150
+ },
151
+ {
152
+ "id": "esclusioni.elenca",
153
+ "method": "GET",
154
+ "path": "/v2/esclusioni",
155
+ "scope": "contacts:read",
156
+ "group": "Contatti e trattative",
157
+ "title": "Elenca i numeri esclusi dalle automazioni",
158
+ "idempotent": false
159
+ },
160
+ {
161
+ "id": "esclusioni.crea",
162
+ "method": "POST",
163
+ "path": "/v2/esclusioni",
164
+ "scope": "crm:write",
165
+ "group": "Contatti e trattative",
166
+ "title": "Esclude un numero dalle automazioni",
167
+ "idempotent": false
168
+ },
169
+ {
170
+ "id": "esclusioni.elimina",
171
+ "method": "DELETE",
172
+ "path": "/v2/esclusioni/{id}",
173
+ "scope": "crm:write",
174
+ "group": "Contatti e trattative",
175
+ "title": "Toglie un'esclusione",
176
+ "idempotent": false
177
+ },
178
+ {
179
+ "id": "spazi.elenca",
180
+ "method": "GET",
181
+ "path": "/v2/spazi",
182
+ "scope": "groups:write",
183
+ "group": "Gruppi e canali",
184
+ "title": "Elenca gruppi, community e canali",
185
+ "idempotent": false
186
+ },
187
+ {
188
+ "id": "spazi.dettaglio",
189
+ "method": "GET",
190
+ "path": "/v2/spazi/{id}",
191
+ "scope": "groups:write",
192
+ "group": "Gruppi e canali",
193
+ "title": "Dettaglio di un gruppo o canale",
194
+ "idempotent": false
195
+ },
196
+ {
197
+ "id": "spazi.gruppo.crea",
198
+ "method": "POST",
199
+ "path": "/v2/spazi/gruppi",
200
+ "scope": "groups:write",
201
+ "group": "Gruppi e canali",
202
+ "title": "Crea un gruppo",
203
+ "idempotent": false
204
+ },
205
+ {
206
+ "id": "spazi.canale.crea",
207
+ "method": "POST",
208
+ "path": "/v2/spazi/canali",
209
+ "scope": "groups:write",
210
+ "group": "Gruppi e canali",
211
+ "title": "Crea un canale",
212
+ "idempotent": false
213
+ },
214
+ {
215
+ "id": "spazi.azione",
216
+ "method": "POST",
217
+ "path": "/v2/spazi/{id}/azioni",
218
+ "scope": "groups:write",
219
+ "group": "Gruppi e canali",
220
+ "title": "Impostazioni, amministratori, rimozioni, richieste e link di invito",
221
+ "idempotent": false
222
+ },
223
+ {
224
+ "id": "spazi.invitabili",
225
+ "method": "GET",
226
+ "path": "/v2/spazi/{id}/contatti",
227
+ "scope": "groups:write",
228
+ "group": "Gruppi e canali",
229
+ "title": "Contatti invitabili in un gruppo",
230
+ "idempotent": false
231
+ },
232
+ {
233
+ "id": "spazi.inviti.crea",
234
+ "method": "POST",
235
+ "path": "/v2/spazi/{id}/inviti",
236
+ "scope": "groups:write",
237
+ "group": "Gruppi e canali",
238
+ "title": "Mette in coda gli inviti, con i tetti giornalieri",
239
+ "idempotent": false
240
+ },
241
+ {
242
+ "id": "spazi.inviti.elenca",
243
+ "method": "GET",
244
+ "path": "/v2/spazi/inviti",
245
+ "scope": "groups:write",
246
+ "group": "Gruppi e canali",
247
+ "title": "Code degli inviti",
248
+ "idempotent": false
249
+ },
250
+ {
251
+ "id": "spazi.inviti.dettaglio",
252
+ "method": "GET",
253
+ "path": "/v2/spazi/inviti/{id}",
254
+ "scope": "groups:write",
255
+ "group": "Gruppi e canali",
256
+ "title": "Stato di una coda degli inviti",
257
+ "idempotent": false
258
+ },
259
+ {
260
+ "id": "spazi.inviti.azione",
261
+ "method": "POST",
262
+ "path": "/v2/spazi/inviti/{id}/{azione}",
263
+ "scope": "groups:write",
264
+ "group": "Gruppi e canali",
265
+ "title": "Mette in pausa, riprende o annulla una coda degli inviti",
266
+ "idempotent": false
267
+ },
268
+ {
269
+ "id": "pubblicazioni.elenca",
270
+ "method": "GET",
271
+ "path": "/v2/pubblicazioni",
272
+ "scope": "groups:write",
273
+ "group": "Gruppi e canali",
274
+ "title": "Elenca le pubblicazioni",
275
+ "idempotent": false
276
+ },
277
+ {
278
+ "id": "pubblicazioni.destinazioni",
279
+ "method": "GET",
280
+ "path": "/v2/pubblicazioni/destinazioni",
281
+ "scope": "groups:write",
282
+ "group": "Gruppi e canali",
283
+ "title": "Gruppi, canali e stato dove si può pubblicare",
284
+ "idempotent": false
285
+ },
286
+ {
287
+ "id": "pubblicazioni.crea",
288
+ "method": "POST",
289
+ "path": "/v2/pubblicazioni",
290
+ "scope": "groups:write",
291
+ "group": "Gruppi e canali",
292
+ "title": "Crea una pubblicazione in gruppi, canali o stato",
293
+ "idempotent": false
294
+ },
295
+ {
296
+ "id": "pubblicazioni.dettaglio",
297
+ "method": "GET",
298
+ "path": "/v2/pubblicazioni/{id}",
299
+ "scope": "groups:write",
300
+ "group": "Gruppi e canali",
301
+ "title": "Dettaglio di una pubblicazione",
302
+ "idempotent": false
303
+ },
304
+ {
305
+ "id": "pubblicazioni.azione",
306
+ "method": "POST",
307
+ "path": "/v2/pubblicazioni/{id}/{azione}",
308
+ "scope": "groups:write",
309
+ "group": "Gruppi e canali",
310
+ "title": "Programma, mette in pausa o annulla una pubblicazione",
311
+ "idempotent": false
312
+ },
313
+ {
314
+ "id": "agente.stato",
315
+ "method": "GET",
316
+ "path": "/v2/agente",
317
+ "scope": "agent:write",
318
+ "group": "Agente AI",
319
+ "title": "Impostazioni dell'agente e chat in pausa",
320
+ "idempotent": false
321
+ },
322
+ {
323
+ "id": "agente.riprendi",
324
+ "method": "POST",
325
+ "path": "/v2/agente/pause/{id}/riprendi",
326
+ "scope": "agent:write",
327
+ "group": "Agente AI",
328
+ "title": "Fa riprendere l'agente in una chat in pausa",
329
+ "idempotent": false
330
+ },
331
+ {
332
+ "id": "media.elenca",
333
+ "method": "GET",
334
+ "path": "/v2/media",
335
+ "scope": "media:write",
336
+ "group": "Media",
337
+ "title": "Elenca la libreria media",
338
+ "idempotent": false
339
+ },
340
+ {
341
+ "id": "media.dettaglio",
342
+ "method": "GET",
343
+ "path": "/v2/media/{id}",
344
+ "scope": "media:write",
345
+ "group": "Media",
346
+ "title": "Dettaglio e stato di una generazione",
347
+ "idempotent": false
348
+ },
349
+ {
350
+ "id": "media.file",
351
+ "method": "GET",
352
+ "path": "/v2/media/{id}/file",
353
+ "scope": "media:write",
354
+ "group": "Media",
355
+ "title": "Scarica il file di un media",
356
+ "idempotent": false
357
+ },
358
+ {
359
+ "id": "media.fal",
360
+ "method": "GET",
361
+ "path": "/v2/media/fal",
362
+ "scope": "media:write",
363
+ "group": "Media",
364
+ "title": "Stato della chiave fal.ai e budget",
365
+ "idempotent": false
366
+ },
367
+ {
368
+ "id": "media.stima",
369
+ "method": "POST",
370
+ "path": "/v2/media/fal/stima",
371
+ "scope": "media:write",
372
+ "group": "Media",
373
+ "title": "Stima il costo di una generazione",
374
+ "idempotent": false
375
+ },
376
+ {
377
+ "id": "media.genera",
378
+ "method": "POST",
379
+ "path": "/v2/media/genera",
380
+ "scope": "media:write",
381
+ "group": "Media",
382
+ "title": "Genera un'immagine o un video con fal.ai",
383
+ "idempotent": false
384
+ },
385
+ {
386
+ "id": "template.elenca",
387
+ "method": "GET",
388
+ "path": "/v2/waba/template",
389
+ "scope": "campaigns:write",
390
+ "group": "Campagne e automazioni",
391
+ "title": "Elenca i modelli di messaggio approvati",
392
+ "idempotent": false
393
+ },
394
+ {
395
+ "id": "liste.elenca",
396
+ "method": "GET",
397
+ "path": "/v2/liste",
398
+ "scope": "campaigns:write",
399
+ "group": "Campagne e automazioni",
400
+ "title": "Elenca le liste dei destinatari",
401
+ "idempotent": false
402
+ },
403
+ {
404
+ "id": "automazioni.simula",
405
+ "method": "POST",
406
+ "path": "/v2/automazioni/simula",
407
+ "scope": "automations:write",
408
+ "group": "Campagne e automazioni",
409
+ "title": "Simula un'automazione sugli ultimi 30 giorni",
410
+ "idempotent": false
411
+ },
412
+ {
413
+ "id": "automazioni.esecuzioni",
414
+ "method": "GET",
415
+ "path": "/v2/flussi/esecuzioni",
416
+ "scope": "automations:write",
417
+ "group": "Campagne e automazioni",
418
+ "title": "Elenca le esecuzioni delle automazioni",
419
+ "idempotent": false
420
+ },
421
+ {
422
+ "id": "webhook.elenca",
423
+ "method": "GET",
424
+ "path": "/v2/webhook",
425
+ "scope": "webhooks:write",
426
+ "group": "Attivatori",
427
+ "title": "Elenca gli indirizzi iscritti",
428
+ "idempotent": false
429
+ },
430
+ {
431
+ "id": "webhook.iscrivi",
432
+ "method": "POST",
433
+ "path": "/v2/webhook",
434
+ "scope": "webhooks:write",
435
+ "group": "Attivatori",
436
+ "title": "Iscrive un indirizzo alle attività",
437
+ "idempotent": false
438
+ },
439
+ {
440
+ "id": "webhook.elimina",
441
+ "method": "DELETE",
442
+ "path": "/v2/webhook/{id}",
443
+ "scope": "webhooks:write",
444
+ "group": "Attivatori",
445
+ "title": "Toglie un indirizzo iscritto",
446
+ "idempotent": false
447
+ },
448
+ {
449
+ "id": "webhook.prova",
450
+ "method": "POST",
451
+ "path": "/v2/webhook/{id}/prova",
452
+ "scope": "webhooks:write",
453
+ "group": "Attivatori",
454
+ "title": "Manda un evento di prova",
455
+ "idempotent": false
456
+ },
457
+ {
458
+ "id": "webhook.consegne",
459
+ "method": "GET",
460
+ "path": "/v2/webhook/{id}/consegne",
461
+ "scope": "webhooks:write",
462
+ "group": "Attivatori",
463
+ "title": "Registro delle consegne",
464
+ "idempotent": false
465
+ }
466
+ ];
467
+ exports.eventi = [
468
+ {
469
+ "value": "message.received",
470
+ "name": "Messaggio ricevuto"
471
+ },
472
+ {
473
+ "value": "message.sent",
474
+ "name": "Messaggio inviato (anche dal telefono)"
475
+ },
476
+ {
477
+ "value": "message.status",
478
+ "name": "Stato di consegna (consegnato, letto)"
479
+ },
480
+ {
481
+ "value": "message.reaction",
482
+ "name": "Reazione a un messaggio"
483
+ },
484
+ {
485
+ "value": "message.edited",
486
+ "name": "Messaggio modificato"
487
+ },
488
+ {
489
+ "value": "message.deleted",
490
+ "name": "Messaggio cancellato"
491
+ },
492
+ {
493
+ "value": "call.received",
494
+ "name": "Chiamata ricevuta"
495
+ },
496
+ {
497
+ "value": "call.accepted",
498
+ "name": "Chiamata accettata dal telefono"
499
+ },
500
+ {
501
+ "value": "call.rejected",
502
+ "name": "Chiamata rifiutata (dal telefono o da una regola di RisveglIA)"
503
+ },
504
+ {
505
+ "value": "label.changed",
506
+ "name": "Etichetta di WhatsApp aggiunta o tolta"
507
+ },
508
+ {
509
+ "value": "number.connected",
510
+ "name": "Numero collegato"
511
+ },
512
+ {
513
+ "value": "number.disconnected",
514
+ "name": "Numero scollegato"
515
+ }
516
+ ];
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.INTESTAZIONE_EVENTO = exports.INTESTAZIONE_FIRMA = void 0;
4
+ exports.firmaValida = firmaValida;
5
+ const node_crypto_1 = require("node:crypto");
6
+ /** Intestazioni degli eventi di RisveglIA (webhook in uscita, payload v1). */
7
+ exports.INTESTAZIONE_FIRMA = "x-risveglia-signature";
8
+ exports.INTESTAZIONE_EVENTO = "x-risveglia-event";
9
+ /**
10
+ * Verifica la firma "t=<secondi>,v1=<hex>": HMAC SHA-256 di "<t>.<corpo>" con il segreto dell'iscrizione, orario entro
11
+ * 5 minuti. Così nessuno può far partire il flusso con un evento inventato o ripetere più tardi uno vero.
12
+ */
13
+ function firmaValida(segreto, intestazione, corpo, adesso = Date.now(), tolleranzaS = 300) {
14
+ if (!intestazione)
15
+ return false;
16
+ const parti = Object.fromEntries(intestazione.split(",").map((p) => p.trim().split("=", 2)));
17
+ const t = Number(parti.t);
18
+ const v1 = parti.v1;
19
+ if (!Number.isInteger(t) || !v1 || !/^[0-9a-f]{64}$/.test(v1))
20
+ return false;
21
+ if (Math.abs(Math.floor(adesso / 1000) - t) > tolleranzaS)
22
+ return false;
23
+ const atteso = (0, node_crypto_1.createHmac)("sha256", segreto).update(`${t}.${corpo}`).digest();
24
+ return (0, node_crypto_1.timingSafeEqual)(atteso, Buffer.from(v1, "hex"));
25
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PREFISSO = exports.CREDENZIALE = void 0;
4
+ exports.erroreDi = erroreDi;
5
+ exports.chiama = chiama;
6
+ const n8n_workflow_1 = require("n8n-workflow");
7
+ exports.CREDENZIALE = "risveglIaApi";
8
+ /** Percorso dell'API per n8n e Make sotto l'indirizzo di RisveglIA (https://app.risveglia.it/api). */
9
+ exports.PREFISSO = "/v1/integrazioni";
10
+ /** Messaggio leggibile di un errore di RisveglIA ({ error: { code, message } }), anche quando il corpo è un buffer. */
11
+ function erroreDi(body) {
12
+ let data = body;
13
+ if (Buffer.isBuffer(data) || data instanceof ArrayBuffer) {
14
+ try {
15
+ data = JSON.parse(Buffer.from(data).toString("utf8"));
16
+ }
17
+ catch {
18
+ data = undefined;
19
+ }
20
+ }
21
+ const err = data?.error;
22
+ return { code: err?.code, message: err?.message ?? "RisveglIA non ha accettato la richiesta." };
23
+ }
24
+ /**
25
+ * Chiamata all'API per n8n e Make con il token della credenziale. Gli errori di RisveglIA diventano errori del nodo con
26
+ * il messaggio in italiano e il codice (ambito_mancante, troppe_richieste, ...), così il flusso può ramificarsi.
27
+ */
28
+ async function chiama(ctx, opts) {
29
+ const cred = await ctx.getCredentials(exports.CREDENZIALE);
30
+ const base = String(cred.baseUrl ?? "https://app.risveglia.it/api").replace(/\/+$/, "");
31
+ const conCorpo = opts.body !== undefined && opts.method !== "GET" && opts.method !== "DELETE";
32
+ const res = (await ctx.helpers.httpRequestWithAuthentication.call(ctx, exports.CREDENZIALE, {
33
+ method: opts.method,
34
+ url: `${base}${exports.PREFISSO}${opts.path}`,
35
+ ...(opts.headers ? { headers: opts.headers } : {}),
36
+ ...(opts.qs && Object.keys(opts.qs).length > 0 ? { qs: opts.qs } : {}),
37
+ ...(conCorpo ? { body: opts.body, json: true } : { json: !opts.binario }),
38
+ ...(opts.binario ? { encoding: "arraybuffer" } : {}),
39
+ returnFullResponse: true,
40
+ ignoreHttpStatusErrors: true,
41
+ }));
42
+ if (res.statusCode >= 400) {
43
+ const { code, message } = erroreDi(res.body);
44
+ throw new n8n_workflow_1.NodeApiError(ctx.getNode(), { code: code ?? String(res.statusCode), message }, {
45
+ message,
46
+ description: code ? `Codice RisveglIA: ${code}` : undefined,
47
+ httpCode: String(res.statusCode),
48
+ ...(opts.itemIndex !== undefined ? { itemIndex: opts.itemIndex } : {}),
49
+ });
50
+ }
51
+ return { status: res.statusCode, body: res.body, headers: res.headers ?? {} };
52
+ }
@@ -0,0 +1,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 455 455" width="64" height="64" xmlns:c2pa="http://c2pa.org/manifest"><metadata><c2pa:manifest>AAAWgmp1bWIAAAAeanVtZGMycGEAEQAQgAAAqgA4m3EDYzJwYQAAABZcanVtYgAAAEdqdW1kYzJtYQARABCAAACqADibcQN1cm46YzJwYTpjYTRiZmM2OC1hZTM4LTRjMTUtODFhYS05NWUwYzRhYWRhZDMAAAADl2p1bWIAAAApanVtZGMyYXMAEQAQgAAAqgA4m3EDYzJwYS5hc3NlcnRpb25zAAAAALxqdW1iAAAARGp1bWRjYm9yABEAEIAAAKoAOJtxE2MycGEuaW5ncmVkaWVudC52MwAAAAAYYzJzaHlrQakk3A2agnQnVZHaJV4AAABwY2JvcqNpZGM6Zm9ybWF0bWltYWdlL3N2Zyt4bWxqaW5zdGFuY2VJRHgseG1wOmlpZDo2ODE2YzZmNy1mNjk1LTQ1Y2UtYmViOS1mNjUxZmE4NzA1NGJscmVsYXRpb25zaGlwaHBhcmVudE9mAAAB4mp1bWIAAABBanVtZGNib3IAEQAQgAAAqgA4m3ETYzJwYS5hY3Rpb25zLnYyAAAAABhjMnNo8WEGwau/C7EPgQfq9/+bawAAAZljYm9yomdhY3Rpb25zgqJmYWN0aW9ua2MycGEub3BlbmVkanBhcmFtZXRlcnOha2luZ3JlZGllbnRzgaJjdXJseC1zZWxmI2p1bWJmPWMycGEuYXNzZXJ0aW9ucy9jMnBhLmluZ3JlZGllbnQudjNkaGFzaFggVMEf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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPZYQBGS5htZVQ10WdHFis25UYCcndeCy4uM+HvM+mmw3BxK/wEEebVH/wP+uDXa4fffoYZ2MCGDFjLNq/xR2ortAFg=</c2pa:manifest></metadata>
2
+ <g transform="translate(0 455) scale(0.025 -0.025)">
3
+ <path fill="#25D366" d="M5685 17209 c-1908 -6 -1881 -5 -2150 -50 -1400 -233 -2435 -1366 -2556 -2796 -21 -250 -17 -13092 4 -13164 44 -146 176 -233 357 -232 149 1 195 30 560 363 104 95 354 313 480 420 36 30 115 102 175 160 61 58 164 151 230 207 66 55 195 172 286 260 231 222 194 210 619 185 210 -12 710 -22 2080 -42 371 -5 815 -14 985 -19 171 -5 470 -9 665 -10 409 -1 1397 -16 2030 -31 795 -18 2435 -32 3205 -28 l760 4 220 37 c917 154 1635 617 2135 1377 292 445 433 951 460 1655 16 402 8 8840 -8 8955 -134 953 -519 1618 -1253 2166 -434 322 -943 504 -1614 575 -125 13 -4520 18 -7670 8z"/>
4
+ <path fill="#FFFFFF" d="M4355 15030 c-328 -7 -423 -56 -474 -245 -16 -60 -17 -9936 -1 -9996 28 -101 114 -200 207 -235 59 -23 2070 -35 2192 -14 121 21 219 99 262 207 l23 58 1 1330 c0 1437 -3 1359 52 1432 58 76 69 78 523 78 l405 0 46 -27 c30 -18 65 -54 105 -109 32 -45 135 -181 228 -303 92 -122 213 -284 269 -361 55 -77 126 -171 157 -210 31 -38 127 -162 211 -275 244 -324 654 -855 748 -970 48 -58 127 -157 176 -220 295 -382 448 -551 536 -592 103 -49 92 -49 1649 -46 l1465 3 52 21 c229 94 252 313 57 534 -93 105 -351 411 -464 550 -95 117 -563 668 -760 895 -58 67 -175 204 -260 305 -85 101 -236 277 -335 393 -99 115 -216 252 -259 305 -44 54 -140 167 -214 252 -226 260 -226 267 -7 361 894 385 1516 1021 1875 1919 292 730 308 1818 38 2615 -454 1344 -1545 2132 -3228 2332 -135 16 -4601 27 -5275 13z m4883 -2448 c647 -125 1032 -581 1032 -1222 0 -611 -363 -1090 -936 -1236 -201 -50 -332 -55 -1524 -52 l-1095 3 -42 23 c-88 46 -97 74 -105 326 -11 321 0 1980 14 2034 15 57 74 117 135 136 89 28 2372 17 2521 -12z"/>
5
+ </g>
6
+ </svg>
package/package.json CHANGED
@@ -1,6 +1,61 @@
1
1
  {
2
2
  "name": "@ivanlaomarketing/n8n-nodes-risveglia",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.2",
4
+ "description": "n8n community node for RisveglIA: WhatsApp messages, contacts and deals, groups and channels, AI agent, media and triggers. Built by Ivan Lao (@ivanlaomarketing).",
5
+ "keywords": [
6
+ "n8n-community-node-package",
7
+ "n8n",
8
+ "risveglia",
9
+ "whatsapp",
10
+ "whatsapp-business",
11
+ "crm",
12
+ "marketing-automation",
13
+ "ivanlaomarketing"
14
+ ],
15
+ "license": "MIT",
16
+ "homepage": "https://github.com/IvanLaoMarketing/n8n-nodes-risveglia#readme",
17
+ "author": {
18
+ "name": "Ivan Lao",
19
+ "email": "info@laoivan.com",
20
+ "url": "https://laoivan.com"
21
+ },
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/IvanLaoMarketing/n8n-nodes-risveglia.git"
25
+ },
26
+ "bugs": {
27
+ "url": "https://github.com/IvanLaoMarketing/n8n-nodes-risveglia/issues"
28
+ },
29
+ "scripts": {
30
+ "build": "tsc -p tsconfig.json && node scripts/copia-icone.mjs",
31
+ "typecheck": "tsc -p tsconfig.json --noEmit",
32
+ "lint": "n8n-node lint",
33
+ "prepublishOnly": "npm run build && npm run lint",
34
+ "lintfix": "n8n-node lint --fix"
35
+ },
36
+ "files": [
37
+ "dist",
38
+ "README.md",
39
+ "LICENSE"
40
+ ],
41
+ "n8n": {
42
+ "n8nNodesApiVersion": 1,
43
+ "credentials": [
44
+ "dist/credentials/RisveglIaApi.credentials.js"
45
+ ],
46
+ "nodes": [
47
+ "dist/nodes/RisveglIa/RisveglIa.node.js",
48
+ "dist/nodes/RisveglIa/RisveglIaTrigger.node.js"
49
+ ]
50
+ },
51
+ "peerDependencies": {
52
+ "n8n-workflow": "*"
53
+ },
54
+ "devDependencies": {
55
+ "@n8n/node-cli": "0.55.6",
56
+ "@types/node": "24.19.1",
57
+ "eslint": "9.29.0",
58
+ "n8n-workflow": "2.46.5",
59
+ "typescript": "5.9.3"
60
+ }
61
+ }