@ivanlaomarketing/n8n-nodes-risveglia 0.5.0 → 0.6.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.
|
@@ -29,7 +29,12 @@ const esempiCorpo = {
|
|
|
29
29
|
"trattative.card.crea": { chatId: "" },
|
|
30
30
|
"trattative.card.sposta": { stageId: "", version: 1 },
|
|
31
31
|
"webhook.iscrivi": { name: "", url: "https://", events: [] },
|
|
32
|
+
"media.da-link": { url: "https://", name: "" },
|
|
32
33
|
};
|
|
34
|
+
/** Come scrivere il corpo di «Invia in una chat» per i tipi diversi dal testo: si mostra sopra il campo. */
|
|
35
|
+
const guidaInviiCrea = 'Testo: {"kind":"testo","conversationId":"…","text":"…"}. File della libreria (foto, video, documento, vocale): {"kind":"allegato","conversationId":"…","mediaId":"…","caption":"…","asVoiceNote":true}. ' +
|
|
36
|
+
'Sondaggio: {"kind":"contenuto","conversationId":"…","content":{"type":"sondaggio","question":"…","options":["Sì","No"],"multipleAnswers":false}}. ' +
|
|
37
|
+
'Posizione: {"type":"posizione","latitude":43.77,"longitude":11.25,"name":"…"}. Contatto: {"type":"contatto","name":"…","phone":"+39…"}. Il sondaggio va solo con il QR code; un file da un link si importa prima con «Importa un file da un link».';
|
|
33
38
|
const esempiQuery = {
|
|
34
39
|
"invii.elenca": { conversationId: "" },
|
|
35
40
|
"allegati.elenca": { messageId: "" },
|
|
@@ -85,7 +90,15 @@ function campiNumero() {
|
|
|
85
90
|
],
|
|
86
91
|
description: "Se il canale scelto non è collegato l'invio si rifiuta, senza ripieghi",
|
|
87
92
|
},
|
|
88
|
-
{ displayName: "Testo", name: "testo", type: "string", typeOptions: { rows: 4 }, default: "", displayOptions: suNumero, description: "Compila il testo
|
|
93
|
+
{ displayName: "Testo", name: "testo", type: "string", typeOptions: { rows: 4 }, default: "", displayOptions: suNumero, description: "Compila il testo, il contenuto o il template: uno solo" },
|
|
94
|
+
{
|
|
95
|
+
displayName: "Contenuto (JSON)",
|
|
96
|
+
name: "contenuto",
|
|
97
|
+
type: "json",
|
|
98
|
+
default: "",
|
|
99
|
+
displayOptions: suNumero,
|
|
100
|
+
description: 'Al posto del testo: sondaggio e contatto via QR; pulsanti, lista e link via API nelle 24 ore; posizione su tutti e due. Esempio: {"type":"pulsanti","body":"Confermi?","buttons":[{"title":"Sì"},{"title":"No"}]}.',
|
|
101
|
+
},
|
|
89
102
|
{
|
|
90
103
|
// eslint-disable-next-line n8n-nodes-base/node-param-display-name-wrong-for-dynamic-options
|
|
91
104
|
displayName: "Template",
|
|
@@ -98,7 +111,7 @@ function campiNumero() {
|
|
|
98
111
|
description: "Solo i template approvati del numero scelto: si creano e si modificano nel portale o da un assistente collegato",
|
|
99
112
|
},
|
|
100
113
|
coppie("Variabili del template", "variabili", "Valori delle variabili del template"),
|
|
101
|
-
{ displayName: "File Libreria Media", name: "mediaId", type: "string", default: "", displayOptions: suNumero, description: "ID di un file della libreria:
|
|
114
|
+
{ displayName: "File Libreria Media", name: "mediaId", type: "string", default: "", displayOptions: suNumero, description: "ID di un file della libreria (foto, video, documento o vocale): da solo o con il testo come didascalia, o intestazione del template" },
|
|
102
115
|
{
|
|
103
116
|
// eslint-disable-next-line n8n-nodes-base/node-param-display-name-wrong-for-dynamic-options
|
|
104
117
|
displayName: "Template Alternativo",
|
|
@@ -130,6 +143,27 @@ const daCoppie = (v) => {
|
|
|
130
143
|
const voci = (v?.voce ?? []).filter((x) => x.chiave?.trim());
|
|
131
144
|
return voci.length ? Object.fromEntries(voci.map((x) => [x.chiave.trim(), x.valore ?? ""])) : undefined;
|
|
132
145
|
};
|
|
146
|
+
/** Il campo «Contenuto (JSON)» arriva come testo o come oggetto: vuoto vale nessun contenuto. */
|
|
147
|
+
function contenutoDi(v) {
|
|
148
|
+
if (v && typeof v === "object" && !Array.isArray(v))
|
|
149
|
+
return Object.keys(v).length ? v : undefined;
|
|
150
|
+
const testo = String(v ?? "").trim();
|
|
151
|
+
if (!testo || testo === "{}")
|
|
152
|
+
return undefined;
|
|
153
|
+
const nonValido = Symbol("non valido");
|
|
154
|
+
let valore;
|
|
155
|
+
try {
|
|
156
|
+
valore = JSON.parse(testo);
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
valore = nonValido;
|
|
160
|
+
}
|
|
161
|
+
if (valore === nonValido)
|
|
162
|
+
throw new n8n_workflow_1.UserError("Contenuto (JSON) non è un JSON valido.");
|
|
163
|
+
if (!valore || typeof valore !== "object" || Array.isArray(valore))
|
|
164
|
+
throw new n8n_workflow_1.UserError("Contenuto (JSON) deve essere un oggetto, per esempio {\"type\":\"posizione\",…}.");
|
|
165
|
+
return valore;
|
|
166
|
+
}
|
|
133
167
|
/** Corpo di «Invia a un numero» dai campi del nodo: i campi vuoti non si mandano. */
|
|
134
168
|
function corpoNumero(get) {
|
|
135
169
|
const t = (nome) => String(get(nome) ?? "").trim();
|
|
@@ -139,6 +173,9 @@ function corpoNumero(get) {
|
|
|
139
173
|
if (v)
|
|
140
174
|
body[chiave] = v;
|
|
141
175
|
}
|
|
176
|
+
const content = contenutoDi(get("contenuto"));
|
|
177
|
+
if (content)
|
|
178
|
+
body.content = content;
|
|
142
179
|
const variables = daCoppie(get("variabili"));
|
|
143
180
|
if (variables)
|
|
144
181
|
body.variables = variables;
|
|
@@ -218,6 +255,8 @@ function proprieta() {
|
|
|
218
255
|
for (const op of catalogo_1.operazioni) {
|
|
219
256
|
if (op.id === exports.OPERAZIONE_NUMERO)
|
|
220
257
|
continue;
|
|
258
|
+
if (op.id === "invii.crea")
|
|
259
|
+
props.push({ displayName: guidaInviiCrea, name: "guidaInviiCrea", type: "notice", default: "", displayOptions: { show: { operation: [op.id] } } });
|
|
221
260
|
if (conCorpo(op))
|
|
222
261
|
props.push({
|
|
223
262
|
displayName: "Corpo (JSON)",
|
|
@@ -20,7 +20,7 @@ exports.operazioni = [
|
|
|
20
20
|
"path": "/v2/invii",
|
|
21
21
|
"scope": "messages:send",
|
|
22
22
|
"group": "Messaggi",
|
|
23
|
-
"title": "Invia una
|
|
23
|
+
"title": "Invia in una chat: testo, file della libreria (foto, video, documento, vocale), sondaggio, posizione, contatto, reazione, modifica o eliminazione",
|
|
24
24
|
"idempotent": true,
|
|
25
25
|
"binary": false
|
|
26
26
|
},
|
|
@@ -70,7 +70,7 @@ exports.operazioni = [
|
|
|
70
70
|
"path": "/v2/invii/numero",
|
|
71
71
|
"scope": "messages:send",
|
|
72
72
|
"group": "Messaggi",
|
|
73
|
-
"title": "Invia a un numero, anche nuovo (testo o modello
|
|
73
|
+
"title": "Invia a un numero, anche nuovo (testo, file, sondaggio, posizione, contatto, pulsanti, lista, link o modello; QR o API)",
|
|
74
74
|
"idempotent": true,
|
|
75
75
|
"binary": false
|
|
76
76
|
},
|
|
@@ -514,6 +514,16 @@ exports.operazioni = [
|
|
|
514
514
|
"idempotent": false,
|
|
515
515
|
"binary": false
|
|
516
516
|
},
|
|
517
|
+
{
|
|
518
|
+
"id": "media.da-link",
|
|
519
|
+
"method": "POST",
|
|
520
|
+
"path": "/v2/media/da-link",
|
|
521
|
+
"scope": "media:write",
|
|
522
|
+
"group": "Media",
|
|
523
|
+
"title": "Importa un file da un link nella libreria, per mandarlo in chat",
|
|
524
|
+
"idempotent": false,
|
|
525
|
+
"binary": false
|
|
526
|
+
},
|
|
517
527
|
{
|
|
518
528
|
"id": "template.elenca",
|
|
519
529
|
"method": "GET",
|
|
@@ -665,5 +675,13 @@ exports.eventi = [
|
|
|
665
675
|
{
|
|
666
676
|
"value": "group.join_request",
|
|
667
677
|
"name": "Richiesta di ingresso in un gruppo da approvare"
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
"value": "chat.assigned",
|
|
681
|
+
"name": "Chat assegnata a una persona del team (a mano o a turno)"
|
|
682
|
+
},
|
|
683
|
+
{
|
|
684
|
+
"value": "agent.handoff",
|
|
685
|
+
"name": "L'agente AI passa la chat a una persona"
|
|
668
686
|
}
|
|
669
687
|
];
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CLIENTE = exports.VERSIONE_NODO = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* Versione del nodo, mandata a ogni chiamata nell'intestazione X-Risveglia-Client («n8n/0.
|
|
5
|
+
* Versione del nodo, mandata a ogni chiamata nell'intestazione X-Risveglia-Client («n8n/0.6.0»): RisveglIA sa chi usa
|
|
6
6
|
* n8n e con quale versione, e avvisa nel portale e per email quando ne esce una nuova (va aggiornata a mano in n8n).
|
|
7
7
|
* Deve coincidere con package.json e con integrationClientVersions.n8n di @risveglia/contracts (test N0).
|
|
8
8
|
*/
|
|
9
|
-
exports.VERSIONE_NODO = "0.
|
|
9
|
+
exports.VERSIONE_NODO = "0.6.0";
|
|
10
10
|
exports.CLIENTE = `n8n/${exports.VERSIONE_NODO}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ivanlaomarketing/n8n-nodes-risveglia",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
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
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package",
|