@growsalesai/n8n-nodes-datacrazy 2.0.1 → 2.0.3
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.
- package/README.md +44 -7
- package/dist/nodes/Datacrazy/resources/whatsappTemplates/whatsappTemplate.handler.d.ts.map +1 -1
- package/dist/nodes/Datacrazy/resources/whatsappTemplates/whatsappTemplate.handler.js +19 -27
- package/dist/nodes/Datacrazy/resources/whatsappTemplates/whatsappTemplate.handler.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,6 +11,7 @@ Nó da comunidade N8N para integração completa com a plataforma **Datacrazy CR
|
|
|
11
11
|
- [Configuração](#configuração)
|
|
12
12
|
- [Nós Disponíveis](#nós-disponíveis)
|
|
13
13
|
- [Módulos do CRM](#módulos-do-crm)
|
|
14
|
+
- [Templates WhatsApp](#-templates-whatsapp)
|
|
14
15
|
- [Nó de Automações](#nó-de-automações)
|
|
15
16
|
- [Webhook & Mensagens](#webhook--mensagens)
|
|
16
17
|
- [Lead & Pipeline](#lead--pipeline)
|
|
@@ -39,9 +40,14 @@ npm install @growsalesai/n8n-nodes-datacrazy
|
|
|
39
40
|
|
|
40
41
|
1. Crie uma nova credencial do tipo **Datacrazy API**
|
|
41
42
|
2. Configure os seguintes campos:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
|
|
44
|
+
| Campo | Padrão | Descrição |
|
|
45
|
+
|---|---|---|
|
|
46
|
+
| **URL CRM** | `https://crm.g1.datacrazy.io` | URL base para rotas `/api/crm/` |
|
|
47
|
+
| **URL API v1** | `https://api.g1.datacrazy.io` | URL base para rotas `/api/v1/` — deixe em branco para usar a URL CRM |
|
|
48
|
+
| **URL Messaging** | `https://messaging.g1.datacrazy.io` | URL base para rotas `/api/messaging/` (templates, mensagens agendadas) |
|
|
49
|
+
| **Fuso Horário** | `America/Sao_Paulo` | Fuso horário usado nas operações de agendamento |
|
|
50
|
+
| **Token da API** | — | Token JWT de acesso (sem o prefixo `Bearer`) |
|
|
45
51
|
|
|
46
52
|
## 🧩 Nós Disponíveis
|
|
47
53
|
|
|
@@ -233,9 +239,14 @@ Sistema de messaging e atendimento ao cliente.
|
|
|
233
239
|
| Listar Conversas | `GET` | `/api/v1/conversations` |
|
|
234
240
|
| Buscar Mensagens | `GET` | `/api/v1/conversations/:id/messages` |
|
|
235
241
|
| Enviar Mensagem | `POST` | `/api/v1/conversations/:id/messages` |
|
|
242
|
+
| Cancelar Mensagem Agendada | `DELETE` | `/api/messaging/conversations/:id/scheduled-message/:msgId` |
|
|
236
243
|
| Finalizar Conversa | `POST` | `/api/v1/conversations/:id/finish` |
|
|
237
244
|
|
|
238
|
-
**
|
|
245
|
+
**Tipos de mensagem suportados:** Texto · Imagem · Vídeo · Áudio · Arquivo / Documento
|
|
246
|
+
|
|
247
|
+
**Opções avançadas:** mensagem interna (nota para equipe) · responder mensagem (reply por ID) · agendamento de envio (data/hora futura)
|
|
248
|
+
|
|
249
|
+
**Cancelar agendamento:** selecione a conversa e informe o ID da mensagem agendada (retornado no output do Enviar Mensagem).
|
|
239
250
|
|
|
240
251
|
---
|
|
241
252
|
|
|
@@ -317,12 +328,35 @@ Gerenciamento de automações e fluxos do Datacrazy.
|
|
|
317
328
|
| Listar Todos | `GET` | `/api/crm/flows` |
|
|
318
329
|
| Buscar por ID | `GET` | `/api/crm/flows/:id` |
|
|
319
330
|
| Listar Grupos | `GET` | `/api/crm/flows/groups` |
|
|
331
|
+
| Executar Automação para Lead | `POST` | `/api/crm/flows/triggers/leads/execute-lead` |
|
|
320
332
|
| Atualizar | `PATCH` | `/api/crm/flows/:id` |
|
|
321
333
|
| Excluir | `DELETE` | `/api/crm/flows/:id` |
|
|
322
334
|
| Ativar | `PATCH` | `/api/crm/flows/:id` |
|
|
323
335
|
| Desativar | `PATCH` | `/api/crm/flows/:id` |
|
|
324
336
|
| Métricas de Versão | `GET` | `/api/crm/flows/:id/versions/:versionId/metrics` |
|
|
325
337
|
|
|
338
|
+
**Executar Automação para Lead:** selecione a automação (dropdown com filtro por tipo manual) e o lead. Dispara a automação manualmente para o lead escolhido sem precisar aguardar um trigger automático.
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
### 📲 Templates WhatsApp
|
|
343
|
+
> `resources/whatsappTemplates/`
|
|
344
|
+
|
|
345
|
+
Gerenciamento e envio de templates aprovados do WhatsApp Cloud API.
|
|
346
|
+
|
|
347
|
+
| Operação | Método | Rota |
|
|
348
|
+
|---|---|---|
|
|
349
|
+
| Listar Templates | `GET` | `/api/messaging/whatsapp-cloud/templates/:channelId` |
|
|
350
|
+
| Enviar Template | `POST` | `/api/messaging/whatsapp-cloud/templates/send` |
|
|
351
|
+
|
|
352
|
+
**Listar Templates:** retorna todos os templates aprovados do canal com `id`, `name`, `language`, `status`, `category`, `templateId` e variáveis/botões.
|
|
353
|
+
|
|
354
|
+
**Enviar Template:**
|
|
355
|
+
- Selecione o **Canal** (instância WhatsApp) → o dropdown de templates é carregado automaticamente
|
|
356
|
+
- O dropdown exibe cada template com a contagem de variáveis: ex. `id002 (pt_BR) — 2 variáveis — APPROVED`
|
|
357
|
+
- Preencha as **Variáveis do Template** em ordem (1º item = `{{1}}`, 2º = `{{2}}`, etc.)
|
|
358
|
+
- Botões e `parameter_format` são incluídos automaticamente a partir dos metadados do template
|
|
359
|
+
|
|
326
360
|
---
|
|
327
361
|
|
|
328
362
|
## 🤖 Nó de Automações
|
|
@@ -630,9 +664,12 @@ nodes/Datacrazy/
|
|
|
630
664
|
│ ├── additionalFields/
|
|
631
665
|
│ │ ├── additionalField.description.ts
|
|
632
666
|
│ │ └── additionalField.handler.ts
|
|
633
|
-
│
|
|
634
|
-
│
|
|
635
|
-
│
|
|
667
|
+
│ ├── flows/
|
|
668
|
+
│ │ ├── flow.description.ts
|
|
669
|
+
│ │ └── flow.handler.ts
|
|
670
|
+
│ └── whatsappTemplates/
|
|
671
|
+
│ ├── whatsappTemplate.description.ts
|
|
672
|
+
│ └── whatsappTemplate.handler.ts
|
|
636
673
|
│
|
|
637
674
|
├── automations/ # Nós utilitários de automação (cada um com description + handler)
|
|
638
675
|
│ ├── webhookParser/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whatsappTemplate.handler.d.ts","sourceRoot":"","sources":["../../../../../nodes/Datacrazy/resources/whatsappTemplates/whatsappTemplate.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAe,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"whatsappTemplate.handler.d.ts","sourceRoot":"","sources":["../../../../../nodes/Datacrazy/resources/whatsappTemplates/whatsappTemplate.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAe,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAI/D,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,iBAAiB,EACvB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,WAAW,EACpB,CAAC,EAAE,MAAM,GACR,OAAO,CAAC,GAAG,CAAC,CA2Dd"}
|
|
@@ -3,10 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.executeWhatsappTemplate = executeWhatsappTemplate;
|
|
4
4
|
const request_1 = require("../../utils/request");
|
|
5
5
|
const BASE_PATH = '/api/messaging/whatsapp-cloud/templates';
|
|
6
|
-
function extractBodyText(template) {
|
|
7
|
-
var _a, _b, _c, _d, _e;
|
|
8
|
-
return ((_e = (_b = (_a = template === null || template === void 0 ? void 0 : template.body) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : (_d = (_c = template === null || template === void 0 ? void 0 : template.components) === null || _c === void 0 ? void 0 : _c.find((c) => c.type === 'BODY')) === null || _d === void 0 ? void 0 : _d.text) !== null && _e !== void 0 ? _e : '');
|
|
9
|
-
}
|
|
10
6
|
async function executeWhatsappTemplate(operation, baseUrl, i) {
|
|
11
7
|
var _a, _b, _c, _d, _e, _f;
|
|
12
8
|
if (operation === 'listTemplates') {
|
|
@@ -20,28 +16,14 @@ async function executeWhatsappTemplate(operation, baseUrl, i) {
|
|
|
20
16
|
const templateId = this.getNodeParameter('templateSelector', i, '', { extractValue: true });
|
|
21
17
|
const variablesCollection = this.getNodeParameter('variables', i, { items: [] });
|
|
22
18
|
const variableValues = ((_a = variablesCollection === null || variablesCollection === void 0 ? void 0 : variablesCollection.items) !== null && _a !== void 0 ? _a : []).map((item) => item.value);
|
|
23
|
-
// busca
|
|
19
|
+
// busca o template completo (com body.text, body.parameters, buttons, etc.)
|
|
24
20
|
const listRes = await request_1.makeRequest.call(this, baseUrl, 'GET', `${BASE_PATH}/${channelId}`, undefined, { take: 200 });
|
|
25
21
|
const templates = ((_c = (_b = listRes === null || listRes === void 0 ? void 0 : listRes.data) !== null && _b !== void 0 ? _b : listRes) !== null && _c !== void 0 ? _c : []);
|
|
26
22
|
const template = templates.find((t) => { var _a; return String((_a = t.id) !== null && _a !== void 0 ? _a : '') === templateId; });
|
|
27
23
|
if (!template) {
|
|
28
24
|
throw new Error(`Template "${templateId}" não encontrado no canal "${channelId}". Verifique o Canal selecionado.`);
|
|
29
25
|
}
|
|
30
|
-
|
|
31
|
-
// definições de parâmetros que vêm do template (com name/example de cada variável)
|
|
32
|
-
const templateParamDefs = ((_e = (_d = template === null || template === void 0 ? void 0 : template.body) === null || _d === void 0 ? void 0 : _d.parameters) !== null && _e !== void 0 ? _e : []);
|
|
33
|
-
// monta cada parâmetro mesclando a definição do template com o valor fornecido pelo usuário
|
|
34
|
-
const parameters = variableValues.map((val, idx) => {
|
|
35
|
-
var _a, _b, _c, _d, _e;
|
|
36
|
-
const def = templateParamDefs[idx];
|
|
37
|
-
return {
|
|
38
|
-
name: (_b = (_a = def === null || def === void 0 ? void 0 : def.name) !== null && _a !== void 0 ? _a : def === null || def === void 0 ? void 0 : def.example) !== null && _b !== void 0 ? _b : val,
|
|
39
|
-
parameter_name: (_c = def === null || def === void 0 ? void 0 : def.parameter_name) !== null && _c !== void 0 ? _c : '',
|
|
40
|
-
value: val,
|
|
41
|
-
example: (_e = (_d = def === null || def === void 0 ? void 0 : def.example) !== null && _d !== void 0 ? _d : def === null || def === void 0 ? void 0 : def.name) !== null && _e !== void 0 ? _e : val,
|
|
42
|
-
type: 'text',
|
|
43
|
-
};
|
|
44
|
-
});
|
|
26
|
+
// monta os campos do template exatamente no formato esperado pela API
|
|
45
27
|
const templatePayload = {
|
|
46
28
|
id: template.id,
|
|
47
29
|
name: template.name,
|
|
@@ -49,17 +31,27 @@ async function executeWhatsappTemplate(operation, baseUrl, i) {
|
|
|
49
31
|
status: template.status,
|
|
50
32
|
templateId: template.templateId,
|
|
51
33
|
category: template.category,
|
|
52
|
-
parameter_format: (
|
|
34
|
+
parameter_format: (_d = template.parameter_format) !== null && _d !== void 0 ? _d : 'positional',
|
|
53
35
|
};
|
|
54
|
-
//
|
|
55
|
-
if (
|
|
36
|
+
// body: usa os parâmetros definidos no template, sobrescrevendo apenas o value com o que o usuário preencheu
|
|
37
|
+
if (template.body) {
|
|
38
|
+
const paramDefs = ((_e = template.body.parameters) !== null && _e !== void 0 ? _e : []);
|
|
56
39
|
templatePayload.body = {
|
|
57
|
-
text:
|
|
58
|
-
parameters,
|
|
40
|
+
text: (_f = template.body.text) !== null && _f !== void 0 ? _f : '',
|
|
41
|
+
parameters: paramDefs.map((def, idx) => {
|
|
42
|
+
var _a, _b, _c, _d, _e, _f;
|
|
43
|
+
return ({
|
|
44
|
+
name: (_a = def.name) !== null && _a !== void 0 ? _a : '',
|
|
45
|
+
parameter_name: (_b = def.parameter_name) !== null && _b !== void 0 ? _b : '',
|
|
46
|
+
value: (_c = variableValues[idx]) !== null && _c !== void 0 ? _c : '',
|
|
47
|
+
example: (_e = (_d = def.example) !== null && _d !== void 0 ? _d : def.name) !== null && _e !== void 0 ? _e : '',
|
|
48
|
+
type: (_f = def.type) !== null && _f !== void 0 ? _f : 'text',
|
|
49
|
+
});
|
|
50
|
+
}),
|
|
59
51
|
};
|
|
60
52
|
}
|
|
61
|
-
//
|
|
62
|
-
if (template.buttons && template.buttons.length > 0) {
|
|
53
|
+
// botões: exatamente como vêm do template
|
|
54
|
+
if (Array.isArray(template.buttons) && template.buttons.length > 0) {
|
|
63
55
|
templatePayload.buttons = template.buttons;
|
|
64
56
|
}
|
|
65
57
|
return request_1.makeRequest.call(this, baseUrl, 'POST', `${BASE_PATH}/send`, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whatsappTemplate.handler.js","sourceRoot":"","sources":["../../../../../nodes/Datacrazy/resources/whatsappTemplates/whatsappTemplate.handler.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"whatsappTemplate.handler.js","sourceRoot":"","sources":["../../../../../nodes/Datacrazy/resources/whatsappTemplates/whatsappTemplate.handler.ts"],"names":[],"mappings":";;AAKA,0DAgEC;AApED,iDAA+D;AAE/D,MAAM,SAAS,GAAG,yCAAyC,CAAC;AAErD,KAAK,UAAU,uBAAuB,CAE3C,SAAiB,EACjB,OAAoB,EACpB,CAAS;;IAET,IAAI,SAAS,KAAK,eAAe,EAAE,CAAC;QAClC,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAW,CAAC;QAC9F,MAAM,IAAI,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC,EAAE,GAAG,CAAW,CAAC;QAC7D,OAAO,qBAAW,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,SAAS,IAAI,SAAS,EAAE,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IAClG,CAAC;IAED,IAAI,SAAS,KAAK,cAAc,E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