n8n-nodes-aib 0.3.2 → 0.4.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.
|
@@ -6,14 +6,30 @@ const n8n_workflow_1 = require("n8n-workflow");
|
|
|
6
6
|
async function api(ctx, method, path, body, qs) {
|
|
7
7
|
const cred = (await ctx.getCredentials("aibDigitalApi"));
|
|
8
8
|
const base = String(cred.baseUrl).replace(/\/+$/, "");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
try {
|
|
10
|
+
return await ctx.helpers.httpRequest({
|
|
11
|
+
method,
|
|
12
|
+
url: `${base}${path}`,
|
|
13
|
+
qs,
|
|
14
|
+
body,
|
|
15
|
+
json: true,
|
|
16
|
+
headers: { Authorization: `Bearer ${cred.apiKey}` },
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
// A API responde { error: "..." } com a causa real; o axios do n8n
|
|
21
|
+
// esconde isso atrás de "Request failed with status code 400".
|
|
22
|
+
// Traz a mensagem de verdade para o usuário.
|
|
23
|
+
const corpo = e?.response?.body ?? e?.cause?.response?.body;
|
|
24
|
+
const msg = (corpo && typeof corpo === "object" && (corpo.error || corpo.message)) ||
|
|
25
|
+
(typeof corpo === "string" && corpo) ||
|
|
26
|
+
e?.message;
|
|
27
|
+
const status = e?.httpCode ?? e?.response?.status ?? e?.cause?.response?.status;
|
|
28
|
+
throw new n8n_workflow_1.NodeApiError(ctx.getNode(), e, {
|
|
29
|
+
message: status ? `AIB (${status}): ${msg}` : `AIB: ${msg}`,
|
|
30
|
+
description: "Resposta do Sistema AIB Digital",
|
|
31
|
+
});
|
|
32
|
+
}
|
|
17
33
|
}
|
|
18
34
|
/** A conta escolhida no nó (vazio = a conta da própria chave). */
|
|
19
35
|
function contaQs(ctx, i) {
|
|
@@ -23,6 +39,7 @@ function contaQs(ctx, i) {
|
|
|
23
39
|
class AibDigital {
|
|
24
40
|
description = {
|
|
25
41
|
displayName: "AIB Digital",
|
|
42
|
+
icon: "file:aibdigital.svg",
|
|
26
43
|
name: "aibDigital",
|
|
27
44
|
group: ["output"],
|
|
28
45
|
version: 1,
|
|
@@ -44,23 +61,79 @@ class AibDigital {
|
|
|
44
61
|
default: "",
|
|
45
62
|
description: "O cliente. Com chave de agência, escolha aqui; com chave de conta, deixe vazio.",
|
|
46
63
|
},
|
|
64
|
+
// ── Recurso → Operação, como no nó do Chatwoot ──────────────
|
|
65
|
+
{
|
|
66
|
+
displayName: "Recurso",
|
|
67
|
+
name: "recurso",
|
|
68
|
+
type: "options",
|
|
69
|
+
noDataExpression: true,
|
|
70
|
+
default: "conversa",
|
|
71
|
+
options: [
|
|
72
|
+
{ name: "Conta", value: "conta" },
|
|
73
|
+
{ name: "Conversa", value: "conversa" },
|
|
74
|
+
{ name: "Mensagem", value: "mensagem" },
|
|
75
|
+
{ name: "Contato", value: "contato" },
|
|
76
|
+
{ name: "Funil (Kanban)", value: "funil" },
|
|
77
|
+
],
|
|
78
|
+
},
|
|
47
79
|
{
|
|
48
80
|
displayName: "Operação",
|
|
49
81
|
name: "operation",
|
|
50
82
|
type: "options",
|
|
51
83
|
noDataExpression: true,
|
|
52
|
-
default: "
|
|
84
|
+
default: "selecionarConta",
|
|
85
|
+
displayOptions: { show: { recurso: ["conta"] } },
|
|
53
86
|
options: [
|
|
54
87
|
{ name: "Selecionar conta", value: "selecionarConta", action: "Selecionar a conta (âncora do fluxo)" },
|
|
55
|
-
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
displayName: "Operação",
|
|
92
|
+
name: "operation",
|
|
93
|
+
type: "options",
|
|
94
|
+
noDataExpression: true,
|
|
95
|
+
default: "listarConversas",
|
|
96
|
+
displayOptions: { show: { recurso: ["conversa"] } },
|
|
97
|
+
options: [
|
|
56
98
|
{ name: "Listar conversas", value: "listarConversas", action: "Listar conversas" },
|
|
57
99
|
{ name: "Buscar conversa", value: "buscarConversa", action: "Buscar uma conversa" },
|
|
58
|
-
{ name: "Listar mensagens", value: "listarMensagens", action: "Listar mensagens da conversa" },
|
|
59
100
|
{ name: "Mover etapa (Kanban)", value: "moverEtapa", action: "Mover card no funil" },
|
|
60
101
|
{ name: "Pausar/religar IA", value: "mudarIa", action: "Pausar ou religar a IA na conversa" },
|
|
61
102
|
{ name: "Atribuir atendente", value: "atribuirAtendente", action: "Atribuir a conversa a uma pessoa" },
|
|
62
|
-
{ name: "Atualizar contato", value: "atualizarContato", action: "Atualizar dados do contato" },
|
|
63
103
|
{ name: "Etiquetas da conversa", value: "mudarEtiquetas", action: "Adicionar/remover etiquetas na conversa" },
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
displayName: "Operação",
|
|
108
|
+
name: "operation",
|
|
109
|
+
type: "options",
|
|
110
|
+
noDataExpression: true,
|
|
111
|
+
default: "enviarMensagem",
|
|
112
|
+
displayOptions: { show: { recurso: ["mensagem"] } },
|
|
113
|
+
options: [
|
|
114
|
+
{ name: "Enviar mensagem", value: "enviarMensagem", action: "Enviar mensagem de texto" },
|
|
115
|
+
{ name: "Listar mensagens", value: "listarMensagens", action: "Listar mensagens da conversa" },
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
displayName: "Operação",
|
|
120
|
+
name: "operation",
|
|
121
|
+
type: "options",
|
|
122
|
+
noDataExpression: true,
|
|
123
|
+
default: "atualizarContato",
|
|
124
|
+
displayOptions: { show: { recurso: ["contato"] } },
|
|
125
|
+
options: [
|
|
126
|
+
{ name: "Atualizar contato", value: "atualizarContato", action: "Atualizar dados do contato" },
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
displayName: "Operação",
|
|
131
|
+
name: "operation",
|
|
132
|
+
type: "options",
|
|
133
|
+
noDataExpression: true,
|
|
134
|
+
default: "criarFunil",
|
|
135
|
+
displayOptions: { show: { recurso: ["funil"] } },
|
|
136
|
+
options: [
|
|
64
137
|
{ name: "Criar funil", value: "criarFunil", action: "Criar funil com etapas" },
|
|
65
138
|
{ name: "Criar etapa", value: "criarEtapa", action: "Criar etapa num funil" },
|
|
66
139
|
],
|
|
@@ -375,6 +448,9 @@ class AibDigital {
|
|
|
375
448
|
res = { id: "", nome: "— a conta da chave —", escopo: ping?.escopo };
|
|
376
449
|
}
|
|
377
450
|
}
|
|
451
|
+
else if (operation === "__CUSTOM_API_CALL__") {
|
|
452
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Escolha o Recurso e a Operação no nó (o n8n perdeu a seleção ao atualizar o pacote).", { description: "Reabra o nó, selecione Recurso → Operação e salve." });
|
|
453
|
+
}
|
|
378
454
|
else {
|
|
379
455
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operação desconhecida: ${operation}`);
|
|
380
456
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60">
|
|
2
|
+
<rect width="60" height="60" rx="13" fill="#0D141C"/>
|
|
3
|
+
<rect x="1.5" y="1.5" width="57" height="57" rx="11.5" fill="none" stroke="#37BFDB" stroke-opacity=".35" stroke-width="3"/>
|
|
4
|
+
<path d="M14 42 L24 18 h4 L38 42 h-6 l-2-5 H22 l-2 5 Z M24 32 h4.5 L26.2 25 Z" fill="#37BFDB"/>
|
|
5
|
+
<circle cx="43" cy="21" r="4" fill="#57B98A"/>
|
|
6
|
+
<rect x="39" y="29" width="8" height="13" rx="2.5" fill="#E8EEF3" opacity=".85"/>
|
|
7
|
+
</svg>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-aib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.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",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
18
|
"scripts": {
|
|
19
|
-
"build": "tsc"
|
|
19
|
+
"build": "tsc && cp nodes/AibDigital/aibdigital.svg dist/nodes/AibDigital/"
|
|
20
20
|
},
|
|
21
21
|
"n8n": {
|
|
22
22
|
"n8nNodesApiVersion": 1,
|