n8n-nodes-aib 0.2.1 → 0.3.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.
|
@@ -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,87 @@ 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
|
+
},
|
|
208
|
+
{
|
|
209
|
+
displayName: "Etapa de ganho",
|
|
210
|
+
name: "etapaGanha",
|
|
211
|
+
type: "boolean",
|
|
212
|
+
default: false,
|
|
213
|
+
displayOptions: { show: { operation: ["criarEtapa"] } },
|
|
214
|
+
description: "Card que chega aqui conta como negócio ganho",
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
displayName: "Etapa de perda",
|
|
218
|
+
name: "etapaPerdida",
|
|
219
|
+
type: "boolean",
|
|
220
|
+
default: false,
|
|
221
|
+
displayOptions: { show: { operation: ["criarEtapa"] } },
|
|
222
|
+
description: "Card que chega aqui conta como negócio perdido",
|
|
223
|
+
},
|
|
140
224
|
{
|
|
141
225
|
displayName: "Contato (ID)",
|
|
142
226
|
name: "contatoId",
|
|
@@ -179,6 +263,12 @@ class AibDigital {
|
|
|
179
263
|
return [{ name: "— A conta da chave —", value: "" }];
|
|
180
264
|
}
|
|
181
265
|
},
|
|
266
|
+
async getFunis() {
|
|
267
|
+
const conta = this.getNodeParameter("conta", "");
|
|
268
|
+
const res = await api(this, "GET", "/api/v1/funis", undefined, conta ? { conta } : undefined);
|
|
269
|
+
const funis = (res?.funis ?? []);
|
|
270
|
+
return funis.map((f) => ({ name: f.nome, value: f.id }));
|
|
271
|
+
},
|
|
182
272
|
async getEtapas() {
|
|
183
273
|
const conta = this.getNodeParameter("conta", "");
|
|
184
274
|
const res = await api(this, "GET", "/api/v1/funis", undefined, conta ? { conta } : undefined);
|
|
@@ -233,6 +323,36 @@ class AibDigital {
|
|
|
233
323
|
const atendenteId = this.getNodeParameter("atendenteId", i, "");
|
|
234
324
|
res = await api(this, "PATCH", `/api/v1/conversas/${conversaId}`, { atendente_id: atendenteId || null }, qs);
|
|
235
325
|
}
|
|
326
|
+
else if (operation === "mudarEtiquetas") {
|
|
327
|
+
const conversaId = this.getNodeParameter("conversaId", i);
|
|
328
|
+
const separa = (v) => v.split(",").map((x) => x.trim()).filter(Boolean);
|
|
329
|
+
res = await api(this, "PATCH", `/api/v1/conversas/${conversaId}`, {
|
|
330
|
+
etiquetas: {
|
|
331
|
+
adicionar: separa(this.getNodeParameter("etiquetasAdicionar", i, "")),
|
|
332
|
+
remover: separa(this.getNodeParameter("etiquetasRemover", i, "")),
|
|
333
|
+
},
|
|
334
|
+
}, qs);
|
|
335
|
+
}
|
|
336
|
+
else if (operation === "criarFunil") {
|
|
337
|
+
const nome = this.getNodeParameter("funilNome", i);
|
|
338
|
+
const ambienteId = this.getNodeParameter("ambienteId", i, "");
|
|
339
|
+
const bruto = this.getNodeParameter("funilEtapas", i, "[]");
|
|
340
|
+
const etapas = typeof bruto === "string" ? JSON.parse(bruto || "[]") : bruto;
|
|
341
|
+
res = await api(this, "POST", "/api/v1/funis", {
|
|
342
|
+
nome,
|
|
343
|
+
etapas,
|
|
344
|
+
...(ambienteId ? { ambiente_id: ambienteId } : {}),
|
|
345
|
+
}, qs);
|
|
346
|
+
}
|
|
347
|
+
else if (operation === "criarEtapa") {
|
|
348
|
+
const funilId = this.getNodeParameter("funilId", i);
|
|
349
|
+
res = await api(this, "POST", `/api/v1/funis/${funilId}/etapas`, {
|
|
350
|
+
nome: this.getNodeParameter("etapaNome", i),
|
|
351
|
+
...(this.getNodeParameter("etapaCor", i, "") ? { cor: this.getNodeParameter("etapaCor", i, "") } : {}),
|
|
352
|
+
...(this.getNodeParameter("etapaGanha", i, false) ? { ganha: true } : {}),
|
|
353
|
+
...(this.getNodeParameter("etapaPerdida", i, false) ? { perdida: true } : {}),
|
|
354
|
+
}, qs);
|
|
355
|
+
}
|
|
236
356
|
else if (operation === "atualizarContato") {
|
|
237
357
|
const contatoId = this.getNodeParameter("contatoId", i);
|
|
238
358
|
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.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",
|