n8n-nodes-aib 0.4.2 → 0.5.1
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.
|
@@ -48,7 +48,6 @@ class AibDigital {
|
|
|
48
48
|
defaults: { name: "AIB Digital" },
|
|
49
49
|
// Vira ferramenta de agente de IA no n8n — o mesmo truque do nó
|
|
50
50
|
// do Chatwoot que a Íris usa (chatwootTool).
|
|
51
|
-
usableAsTool: true,
|
|
52
51
|
inputs: ["main"],
|
|
53
52
|
outputs: ["main"],
|
|
54
53
|
credentials: [{ name: "aibDigitalApi", required: true }],
|
|
@@ -74,6 +73,7 @@ class AibDigital {
|
|
|
74
73
|
{ name: "Mensagem", value: "mensagem" },
|
|
75
74
|
{ name: "Contato", value: "contato" },
|
|
76
75
|
{ name: "Funil (Kanban)", value: "funil" },
|
|
76
|
+
{ name: "Etiqueta", value: "etiqueta" },
|
|
77
77
|
],
|
|
78
78
|
},
|
|
79
79
|
{
|
|
@@ -138,6 +138,18 @@ class AibDigital {
|
|
|
138
138
|
{ name: "Criar etapa", value: "criarEtapa", action: "Criar etapa num funil" },
|
|
139
139
|
],
|
|
140
140
|
},
|
|
141
|
+
{
|
|
142
|
+
displayName: "Operação",
|
|
143
|
+
name: "operation",
|
|
144
|
+
type: "options",
|
|
145
|
+
noDataExpression: true,
|
|
146
|
+
default: "criarEtiqueta",
|
|
147
|
+
displayOptions: { show: { recurso: ["etiqueta"] } },
|
|
148
|
+
options: [
|
|
149
|
+
{ name: "Criar etiqueta", value: "criarEtiqueta", action: "Criar ou atualizar uma etiqueta" },
|
|
150
|
+
{ name: "Listar etiquetas", value: "listarEtiquetas", action: "Listar as etiquetas da conta" },
|
|
151
|
+
],
|
|
152
|
+
},
|
|
141
153
|
// ── parâmetros por operação ─────────────────────────────
|
|
142
154
|
{
|
|
143
155
|
displayName: "Conversa (ID)",
|
|
@@ -248,12 +260,13 @@ class AibDigital {
|
|
|
248
260
|
description: "Lista de { nome, cor?, ganha?, perdida? } na ordem das colunas",
|
|
249
261
|
},
|
|
250
262
|
{
|
|
251
|
-
displayName: "Ambiente
|
|
263
|
+
displayName: "Ambiente",
|
|
252
264
|
name: "ambienteId",
|
|
253
|
-
type: "
|
|
265
|
+
type: "options",
|
|
266
|
+
typeOptions: { loadOptionsMethod: "getAmbientes", loadOptionsDependsOn: ["conta"] },
|
|
254
267
|
default: "",
|
|
255
|
-
displayOptions: { show: { operation: ["criarFunil"] } },
|
|
256
|
-
description: "
|
|
268
|
+
displayOptions: { show: { operation: ["selecionarConta", "criarFunil", "criarEtiqueta"] } },
|
|
269
|
+
description: "Onde o funil/dado vai nascer. Conta com 2+ ambientes exige escolher aqui.",
|
|
257
270
|
},
|
|
258
271
|
{
|
|
259
272
|
displayName: "Funil",
|
|
@@ -295,6 +308,28 @@ class AibDigital {
|
|
|
295
308
|
displayOptions: { show: { operation: ["criarEtapa"] } },
|
|
296
309
|
description: "Card que chega aqui conta como negócio perdido",
|
|
297
310
|
},
|
|
311
|
+
{
|
|
312
|
+
displayName: "Nome da etiqueta",
|
|
313
|
+
name: "etiquetaNome",
|
|
314
|
+
type: "string",
|
|
315
|
+
default: "",
|
|
316
|
+
required: true,
|
|
317
|
+
displayOptions: { show: { operation: ["criarEtiqueta"] } },
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
displayName: "Cor",
|
|
321
|
+
name: "etiquetaCor",
|
|
322
|
+
type: "color",
|
|
323
|
+
default: "",
|
|
324
|
+
displayOptions: { show: { operation: ["criarEtiqueta"] } },
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
displayName: "Descrição",
|
|
328
|
+
name: "etiquetaDescricao",
|
|
329
|
+
type: "string",
|
|
330
|
+
default: "",
|
|
331
|
+
displayOptions: { show: { operation: ["criarEtiqueta"] } },
|
|
332
|
+
},
|
|
298
333
|
{
|
|
299
334
|
displayName: "Contato (ID)",
|
|
300
335
|
name: "contatoId",
|
|
@@ -337,6 +372,20 @@ class AibDigital {
|
|
|
337
372
|
return [{ name: "— A conta da chave —", value: "" }];
|
|
338
373
|
}
|
|
339
374
|
},
|
|
375
|
+
async getAmbientes() {
|
|
376
|
+
const conta = this.getNodeParameter("conta", "");
|
|
377
|
+
try {
|
|
378
|
+
const res = await api(this, "GET", "/api/v1/ambientes", undefined, conta ? { conta } : undefined);
|
|
379
|
+
const ambientes = (res?.ambientes ?? []);
|
|
380
|
+
if (ambientes.length <= 1) {
|
|
381
|
+
return [{ name: "— Único ambiente da conta —", value: ambientes[0]?.id ?? "" }];
|
|
382
|
+
}
|
|
383
|
+
return ambientes.map((a) => ({ name: a.nome, value: a.id }));
|
|
384
|
+
}
|
|
385
|
+
catch {
|
|
386
|
+
return [{ name: "— Único ambiente da conta —", value: "" }];
|
|
387
|
+
}
|
|
388
|
+
},
|
|
340
389
|
async getFunis() {
|
|
341
390
|
const conta = this.getNodeParameter("conta", "");
|
|
342
391
|
const res = await api(this, "GET", "/api/v1/funis", undefined, conta ? { conta } : undefined);
|
|
@@ -366,6 +415,7 @@ class AibDigital {
|
|
|
366
415
|
mensagem: "enviarMensagem",
|
|
367
416
|
contato: "atualizarContato",
|
|
368
417
|
funil: "criarFunil",
|
|
418
|
+
etiqueta: "criarEtiqueta",
|
|
369
419
|
};
|
|
370
420
|
operation = padrao[recurso] ?? "selecionarConta";
|
|
371
421
|
}
|
|
@@ -446,21 +496,38 @@ class AibDigital {
|
|
|
446
496
|
const campos = this.getNodeParameter("camposContato", i, {});
|
|
447
497
|
res = await api(this, "PATCH", `/api/v1/contatos/${contatoId}`, campos, qs);
|
|
448
498
|
}
|
|
499
|
+
else if (operation === "criarEtiqueta") {
|
|
500
|
+
const ambienteSel = this.getNodeParameter("ambienteId", i, "");
|
|
501
|
+
res = await api(this, "POST", "/api/v1/etiquetas", {
|
|
502
|
+
nome: this.getNodeParameter("etiquetaNome", i),
|
|
503
|
+
...(this.getNodeParameter("etiquetaCor", i, "") ? { cor: this.getNodeParameter("etiquetaCor", i, "") } : {}),
|
|
504
|
+
...(this.getNodeParameter("etiquetaDescricao", i, "") ? { descricao: this.getNodeParameter("etiquetaDescricao", i, "") } : {}),
|
|
505
|
+
...(ambienteSel ? { ambiente_id: ambienteSel } : {}),
|
|
506
|
+
}, qs);
|
|
507
|
+
}
|
|
508
|
+
else if (operation === "listarEtiquetas") {
|
|
509
|
+
res = await api(this, "GET", "/api/v1/etiquetas", undefined, qs);
|
|
510
|
+
}
|
|
449
511
|
else if (operation === "selecionarConta") {
|
|
450
|
-
// A âncora do fluxo
|
|
451
|
-
//
|
|
512
|
+
// A âncora do fluxo: devolve a conta E o ambiente escolhidos para os
|
|
513
|
+
// nós seguintes referenciarem ($('Selecionar conta').item.json.id e
|
|
514
|
+
// .ambiente_id). É onde o funil vai nascer.
|
|
452
515
|
const contaSel = this.getNodeParameter("conta", i, "");
|
|
516
|
+
const ambienteSel = this.getNodeParameter("ambienteId", i, "");
|
|
517
|
+
let base;
|
|
453
518
|
if (contaSel) {
|
|
454
519
|
const r = await api(this, "GET", "/api/v1/contas");
|
|
455
520
|
const achada = (r?.contas ?? []).find((c) => c.id === contaSel);
|
|
456
521
|
if (!achada)
|
|
457
522
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Conta não encontrada para esta chave");
|
|
458
|
-
|
|
523
|
+
base = { ...achada };
|
|
459
524
|
}
|
|
460
525
|
else {
|
|
461
526
|
const ping = await api(this, "GET", "/api/v1/ping");
|
|
462
|
-
|
|
527
|
+
base = { id: "", nome: "— a conta da chave —", escopo: ping?.escopo };
|
|
463
528
|
}
|
|
529
|
+
base.ambiente_id = ambienteSel || null;
|
|
530
|
+
res = base;
|
|
464
531
|
}
|
|
465
532
|
else {
|
|
466
533
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operação desconhecida: ${operation}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-aib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Nós do Sistema AIB Digital para n8n: gatilho de mensagens do WhatsApp (via AIB Inbox) e ações — enviar mensagem, mover card no funil, pausar IA — escolhendo conta e caixa por dropdown.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "AIB Digital",
|