n8n-nodes-aib 0.2.1 → 0.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.
|
@@ -59,6 +59,9 @@ class AibDigital {
|
|
|
59
59
|
{ name: "Pausar/religar IA", value: "mudarIa", action: "Pausar ou religar a IA na conversa" },
|
|
60
60
|
{ name: "Atribuir atendente", value: "atribuirAtendente", action: "Atribuir a conversa a uma pessoa" },
|
|
61
61
|
{ name: "Atualizar contato", value: "atualizarContato", action: "Atualizar dados do contato" },
|
|
62
|
+
{ name: "Etiquetas da conversa", value: "mudarEtiquetas", action: "Adicionar/remover etiquetas na conversa" },
|
|
63
|
+
{ name: "Criar funil", value: "criarFunil", action: "Criar funil com etapas" },
|
|
64
|
+
{ name: "Criar etapa", value: "criarEtapa", action: "Criar etapa num funil" },
|
|
62
65
|
],
|
|
63
66
|
},
|
|
64
67
|
// ── parâmetros por operação ─────────────────────────────
|
|
@@ -69,7 +72,7 @@ class AibDigital {
|
|
|
69
72
|
default: "",
|
|
70
73
|
required: true,
|
|
71
74
|
displayOptions: {
|
|
72
|
-
show: { operation: ["enviarMensagem", "buscarConversa", "listarMensagens", "moverEtapa", "mudarIa", "atribuirAtendente"] },
|
|
75
|
+
show: { operation: ["enviarMensagem", "buscarConversa", "listarMensagens", "moverEtapa", "mudarIa", "atribuirAtendente", "mudarEtiquetas"] },
|
|
73
76
|
},
|
|
74
77
|
description: "Vem do gatilho (data.conversa_id) ou de Listar conversas",
|
|
75
78
|
},
|
|
@@ -137,6 +140,71 @@ class AibDigital {
|
|
|
137
140
|
{ displayName: "Limite", name: "limite", type: "number", default: 50 },
|
|
138
141
|
],
|
|
139
142
|
},
|
|
143
|
+
{
|
|
144
|
+
displayName: "Etiquetas a adicionar",
|
|
145
|
+
name: "etiquetasAdicionar",
|
|
146
|
+
type: "string",
|
|
147
|
+
default: "",
|
|
148
|
+
placeholder: "vip, urgente",
|
|
149
|
+
displayOptions: { show: { operation: ["mudarEtiquetas"] } },
|
|
150
|
+
description: "Separadas por vírgula. Etiqueta aqui é texto livre: aplicar já é criar.",
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
displayName: "Etiquetas a remover",
|
|
154
|
+
name: "etiquetasRemover",
|
|
155
|
+
type: "string",
|
|
156
|
+
default: "",
|
|
157
|
+
placeholder: "teste",
|
|
158
|
+
displayOptions: { show: { operation: ["mudarEtiquetas"] } },
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
displayName: "Nome do funil",
|
|
162
|
+
name: "funilNome",
|
|
163
|
+
type: "string",
|
|
164
|
+
default: "",
|
|
165
|
+
required: true,
|
|
166
|
+
displayOptions: { show: { operation: ["criarFunil"] } },
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
displayName: "Etapas (JSON)",
|
|
170
|
+
name: "funilEtapas",
|
|
171
|
+
type: "json",
|
|
172
|
+
default: '[\n { "nome": "Novo lead", "cor": "#5B9BD5" },\n { "nome": "Qualificado" },\n { "nome": "Ganho", "ganha": true },\n { "nome": "Perdido", "perdida": true }\n]',
|
|
173
|
+
displayOptions: { show: { operation: ["criarFunil"] } },
|
|
174
|
+
description: "Lista de { nome, cor?, ganha?, perdida? } na ordem das colunas",
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
displayName: "Ambiente (ID)",
|
|
178
|
+
name: "ambienteId",
|
|
179
|
+
type: "string",
|
|
180
|
+
default: "",
|
|
181
|
+
displayOptions: { show: { operation: ["criarFunil"] } },
|
|
182
|
+
description: "Obrigatório só quando a conta tem 2+ ambientes",
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
displayName: "Funil",
|
|
186
|
+
name: "funilId",
|
|
187
|
+
type: "options",
|
|
188
|
+
typeOptions: { loadOptionsMethod: "getFunis", loadOptionsDependsOn: ["conta"] },
|
|
189
|
+
default: "",
|
|
190
|
+
required: true,
|
|
191
|
+
displayOptions: { show: { operation: ["criarEtapa"] } },
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
displayName: "Nome da etapa",
|
|
195
|
+
name: "etapaNome",
|
|
196
|
+
type: "string",
|
|
197
|
+
default: "",
|
|
198
|
+
required: true,
|
|
199
|
+
displayOptions: { show: { operation: ["criarEtapa"] } },
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
displayName: "Cor",
|
|
203
|
+
name: "etapaCor",
|
|
204
|
+
type: "color",
|
|
205
|
+
default: "",
|
|
206
|
+
displayOptions: { show: { operation: ["criarEtapa"] } },
|
|
207
|
+
},
|
|
140
208
|
{
|
|
141
209
|
displayName: "Contato (ID)",
|
|
142
210
|
name: "contatoId",
|
|
@@ -179,6 +247,12 @@ class AibDigital {
|
|
|
179
247
|
return [{ name: "— A conta da chave —", value: "" }];
|
|
180
248
|
}
|
|
181
249
|
},
|
|
250
|
+
async getFunis() {
|
|
251
|
+
const conta = this.getNodeParameter("conta", "");
|
|
252
|
+
const res = await api(this, "GET", "/api/v1/funis", undefined, conta ? { conta } : undefined);
|
|
253
|
+
const funis = (res?.funis ?? []);
|
|
254
|
+
return funis.map((f) => ({ name: f.nome, value: f.id }));
|
|
255
|
+
},
|
|
182
256
|
async getEtapas() {
|
|
183
257
|
const conta = this.getNodeParameter("conta", "");
|
|
184
258
|
const res = await api(this, "GET", "/api/v1/funis", undefined, conta ? { conta } : undefined);
|
|
@@ -233,6 +307,34 @@ class AibDigital {
|
|
|
233
307
|
const atendenteId = this.getNodeParameter("atendenteId", i, "");
|
|
234
308
|
res = await api(this, "PATCH", `/api/v1/conversas/${conversaId}`, { atendente_id: atendenteId || null }, qs);
|
|
235
309
|
}
|
|
310
|
+
else if (operation === "mudarEtiquetas") {
|
|
311
|
+
const conversaId = this.getNodeParameter("conversaId", i);
|
|
312
|
+
const separa = (v) => v.split(",").map((x) => x.trim()).filter(Boolean);
|
|
313
|
+
res = await api(this, "PATCH", `/api/v1/conversas/${conversaId}`, {
|
|
314
|
+
etiquetas: {
|
|
315
|
+
adicionar: separa(this.getNodeParameter("etiquetasAdicionar", i, "")),
|
|
316
|
+
remover: separa(this.getNodeParameter("etiquetasRemover", i, "")),
|
|
317
|
+
},
|
|
318
|
+
}, qs);
|
|
319
|
+
}
|
|
320
|
+
else if (operation === "criarFunil") {
|
|
321
|
+
const nome = this.getNodeParameter("funilNome", i);
|
|
322
|
+
const ambienteId = this.getNodeParameter("ambienteId", i, "");
|
|
323
|
+
const bruto = this.getNodeParameter("funilEtapas", i, "[]");
|
|
324
|
+
const etapas = typeof bruto === "string" ? JSON.parse(bruto || "[]") : bruto;
|
|
325
|
+
res = await api(this, "POST", "/api/v1/funis", {
|
|
326
|
+
nome,
|
|
327
|
+
etapas,
|
|
328
|
+
...(ambienteId ? { ambiente_id: ambienteId } : {}),
|
|
329
|
+
}, qs);
|
|
330
|
+
}
|
|
331
|
+
else if (operation === "criarEtapa") {
|
|
332
|
+
const funilId = this.getNodeParameter("funilId", i);
|
|
333
|
+
res = await api(this, "POST", `/api/v1/funis/${funilId}/etapas`, {
|
|
334
|
+
nome: this.getNodeParameter("etapaNome", i),
|
|
335
|
+
...(this.getNodeParameter("etapaCor", i, "") ? { cor: this.getNodeParameter("etapaCor", i, "") } : {}),
|
|
336
|
+
}, qs);
|
|
337
|
+
}
|
|
236
338
|
else if (operation === "atualizarContato") {
|
|
237
339
|
const contatoId = this.getNodeParameter("contatoId", i);
|
|
238
340
|
const campos = this.getNodeParameter("camposContato", i, {});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-aib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
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",
|