n8n-nodes-digitalsac 0.5.4 → 0.5.6
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 +119 -3
- package/dist/nodes/Digitalsac/Digitalsac.node.js +101 -22
- package/nodes/Digitalsac/Digitalsac.node.ts +125 -35
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,6 +31,9 @@ Este pacote adiciona um nó personalizado ao n8n para interagir com a API do Dig
|
|
|
31
31
|
- Criar Agendamento
|
|
32
32
|
- Cancelar Agendamento
|
|
33
33
|
- Gerar Link do Calendário (.ics)
|
|
34
|
+
- **Templates WABA:**
|
|
35
|
+
- Listar Templates WABA
|
|
36
|
+
- Enviar Template WABA
|
|
34
37
|
|
|
35
38
|
## Instalação
|
|
36
39
|
|
|
@@ -50,7 +53,21 @@ cd ~/.n8n
|
|
|
50
53
|
npm install n8n-nodes-digitalsac
|
|
51
54
|
```
|
|
52
55
|
|
|
53
|
-
## ✨ Novas Funcionalidades (v0.5.
|
|
56
|
+
## ✨ Novas Funcionalidades (v0.5.6)
|
|
57
|
+
|
|
58
|
+
### 📱 Templates WABA
|
|
59
|
+
Envie templates pré-aprovados do WhatsApp Business API:
|
|
60
|
+
- **Listar Templates WABA**: Busca todos os templates disponíveis na conta WABA
|
|
61
|
+
- **Enviar Template WABA**: Envia template com variáveis dinâmicas para contatos
|
|
62
|
+
|
|
63
|
+
**Benefícios:**
|
|
64
|
+
- ✅ Templates aprovados pelo Meta/Facebook
|
|
65
|
+
- ✅ Baixo custo de envio
|
|
66
|
+
- ✅ Alta taxa de entrega
|
|
67
|
+
- ✅ Suporte a variáveis personalizadas
|
|
68
|
+
- ✅ Ideais para notificações transacionais
|
|
69
|
+
|
|
70
|
+
## ✨ Funcionalidades Anteriores (v0.5.1)
|
|
54
71
|
|
|
55
72
|
### 🔘 Enviar Botões Interativos
|
|
56
73
|
Envie mensagens com botões clicáveis:
|
|
@@ -211,7 +228,6 @@ Onde:
|
|
|
211
228
|
- `copy`: Copia texto para área de transferência
|
|
212
229
|
- `call`: Inicia uma chamada telefônica
|
|
213
230
|
|
|
214
|
-
<!-- TEMPORARIAMENTE DESABILITADO - ENVIAR LISTA
|
|
215
231
|
### 📋 Enviar Lista
|
|
216
232
|
1. Selecione a operação **Enviar Lista**
|
|
217
233
|
2. No campo **Parâmetro**, insira o UUID da conexão
|
|
@@ -268,7 +284,6 @@ Onde:
|
|
|
268
284
|
}
|
|
269
285
|
]
|
|
270
286
|
```
|
|
271
|
-
-->
|
|
272
287
|
|
|
273
288
|
### 🖼️ Enviar Mídia com Caption
|
|
274
289
|
1. **Conecte um nó com arquivo** (ex: HTTP Request, Read Binary File, Google Drive)
|
|
@@ -635,6 +650,79 @@ Gera um link para download do arquivo .ics (calendário) de um agendamento espec
|
|
|
635
650
|
- Pode ser importado em qualquer aplicativo de calendário (Google Calendar, Outlook, Apple Calendar, etc.)
|
|
636
651
|
- É útil para integração com sistemas externos ou envio para clientes
|
|
637
652
|
|
|
653
|
+
### 📱 Listar Templates WABA
|
|
654
|
+
Lista todos os templates disponíveis na conta WABA (WhatsApp Business API).
|
|
655
|
+
1. Selecione a operação **Listar Templates WABA**
|
|
656
|
+
2. Preencha:
|
|
657
|
+
- **WhatsApp ID**: ID da conexão WhatsApp WABA
|
|
658
|
+
|
|
659
|
+
**Retorno exemplo:**
|
|
660
|
+
```json
|
|
661
|
+
[
|
|
662
|
+
{
|
|
663
|
+
"id": "123456789",
|
|
664
|
+
"name": "boas_vindas",
|
|
665
|
+
"language": "pt_BR",
|
|
666
|
+
"category": "MARKETING",
|
|
667
|
+
"status": "APPROVED",
|
|
668
|
+
"alreadyImported": true
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
"id": "987654321",
|
|
672
|
+
"name": "confirmacao_pedido",
|
|
673
|
+
"language": "pt_BR",
|
|
674
|
+
"category": "UTILITY",
|
|
675
|
+
"status": "APPROVED",
|
|
676
|
+
"alreadyImported": false
|
|
677
|
+
}
|
|
678
|
+
]
|
|
679
|
+
```
|
|
680
|
+
|
|
681
|
+
**Campos retornados:**
|
|
682
|
+
- `id`: ID do template no Facebook Graph API
|
|
683
|
+
- `name`: Nome do template
|
|
684
|
+
- `language`: Idioma do template
|
|
685
|
+
- `category`: Categoria (MARKETING, UTILITY, AUTHENTICATION)
|
|
686
|
+
- `status`: Status (APPROVED, PENDING, REJECTED)
|
|
687
|
+
- `alreadyImported`: Indica se o template já foi importado no sistema
|
|
688
|
+
|
|
689
|
+
### 📤 Enviar Template WABA
|
|
690
|
+
Envia um template WABA pré-aprovado para um número de WhatsApp.
|
|
691
|
+
1. Selecione a operação **Enviar Template WABA**
|
|
692
|
+
2. Preencha:
|
|
693
|
+
- **WhatsApp ID**: ID da conexão WhatsApp WABA
|
|
694
|
+
- **Template ID**: ID do template no sistema (obtido após importação)
|
|
695
|
+
- **Número de Telefone**: Número do destinatário com DDI (ex: 5511999999999)
|
|
696
|
+
- **Parâmetros do Template**: JSON com variáveis para substituir no template (opcional)
|
|
697
|
+
|
|
698
|
+
**Exemplo de parâmetros:**
|
|
699
|
+
```json
|
|
700
|
+
{
|
|
701
|
+
"nome_cliente": "João Silva",
|
|
702
|
+
"numero_pedido": "12345",
|
|
703
|
+
"data_entrega": "15/01/2025"
|
|
704
|
+
}
|
|
705
|
+
```
|
|
706
|
+
|
|
707
|
+
**Retorno exemplo:**
|
|
708
|
+
```json
|
|
709
|
+
{
|
|
710
|
+
"success": true,
|
|
711
|
+
"message": "Template enviado com sucesso",
|
|
712
|
+
"messageId": "wamid.HBgNNTUxMTk4NzY1NDMyMRUCABIYIDNBNjdFRjg5RjY4OTRDNTA5MDk5",
|
|
713
|
+
"templateName": "boas_vindas",
|
|
714
|
+
"recipient": "5511999999999",
|
|
715
|
+
"whatsappId": 3
|
|
716
|
+
}
|
|
717
|
+
```
|
|
718
|
+
|
|
719
|
+
**Observações importantes:**
|
|
720
|
+
- Templates WABA precisam ser pré-aprovados pelo Meta/Facebook
|
|
721
|
+
- O template deve estar importado no sistema para ser enviado
|
|
722
|
+
- Use `listWabaTemplates` para ver quais templates estão disponíveis
|
|
723
|
+
- Os parâmetros devem corresponder às variáveis definidas no template
|
|
724
|
+
- Templates WABA são ideais para notificações, confirmações e mensagens de marketing
|
|
725
|
+
|
|
638
726
|
## 💡 Casos de Uso Práticos
|
|
639
727
|
|
|
640
728
|
### 🤖 Bot de Atendimento Interativo
|
|
@@ -703,6 +791,34 @@ Webhook (Capturar resposta)
|
|
|
703
791
|
9. Webhook (Notificar vendedor)
|
|
704
792
|
```
|
|
705
793
|
|
|
794
|
+
### 📱 Templates WABA
|
|
795
|
+
**Cenário**: Notificação de pedido aprovado
|
|
796
|
+
|
|
797
|
+
```
|
|
798
|
+
1. Webhook (Pedido aprovado)
|
|
799
|
+
↓
|
|
800
|
+
2. Listar Templates WABA (Buscar template de confirmação)
|
|
801
|
+
↓
|
|
802
|
+
3. Enviar Template WABA (Notificar cliente)
|
|
803
|
+
↓
|
|
804
|
+
Parâmetros: {
|
|
805
|
+
"nome_cliente": "{{$json.customer_name}}",
|
|
806
|
+
"numero_pedido": "{{$json.order_id}}",
|
|
807
|
+
"valor_total": "{{$json.total}}",
|
|
808
|
+
"data_entrega": "{{$json.delivery_date}}"
|
|
809
|
+
}
|
|
810
|
+
↓
|
|
811
|
+
4. Database (Registrar envio)
|
|
812
|
+
```
|
|
813
|
+
|
|
814
|
+
**Vantagens dos Templates WABA:**
|
|
815
|
+
- ✅ Aprovação prévia do Meta/Facebook
|
|
816
|
+
- ✅ Baixo custo de envio
|
|
817
|
+
- ✅ Alta taxa de entrega
|
|
818
|
+
- ✅ Ideais para notificações transacionais
|
|
819
|
+
- ✅ Suporte a variáveis dinâmicas
|
|
820
|
+
- ✅ Podem incluir botões e mídia
|
|
821
|
+
|
|
706
822
|
## Suporte
|
|
707
823
|
|
|
708
824
|
Para suporte, entre em contato com [contato@digitalsac.io](mailto:contato@digitalsac.io).
|
|
@@ -37,7 +37,7 @@ class Digitalsac {
|
|
|
37
37
|
{ name: 'Fechar Ticket', value: 'closeTicket' },
|
|
38
38
|
{ name: 'Enviar Mensagem', value: 'sendMessage' },
|
|
39
39
|
{ name: 'Enviar Botões', value: 'sendButtons' },
|
|
40
|
-
|
|
40
|
+
{ name: 'Enviar Lista', value: 'sendList' },
|
|
41
41
|
{ name: 'Enviar Mídia com Caption', value: 'sendMediaCaption' },
|
|
42
42
|
{ name: 'Enviar Base64', value: 'sendBase64' },
|
|
43
43
|
{ name: 'Listar Tags', value: 'listTags' },
|
|
@@ -55,6 +55,9 @@ class Digitalsac {
|
|
|
55
55
|
{ name: 'Criar Agendamento', value: 'createSchedule' },
|
|
56
56
|
{ name: 'Cancelar Agendamento', value: 'cancelSchedule' },
|
|
57
57
|
{ name: 'Gerar Link do Calendário (.ics)', value: 'calendarLink' },
|
|
58
|
+
// Templates WABA
|
|
59
|
+
{ name: 'Listar Templates WABA', value: 'listWabaTemplates' },
|
|
60
|
+
{ name: 'Enviar Template WABA', value: 'sendWabaTemplate' },
|
|
58
61
|
],
|
|
59
62
|
default: 'validateWhatsapp',
|
|
60
63
|
},
|
|
@@ -65,7 +68,7 @@ class Digitalsac {
|
|
|
65
68
|
default: '',
|
|
66
69
|
displayOptions: {
|
|
67
70
|
show: {
|
|
68
|
-
operation: ['validateWhatsapp', 'validateCpf', 'sendMessage', 'sendButtons',
|
|
71
|
+
operation: ['validateWhatsapp', 'validateCpf', 'sendMessage', 'sendButtons', 'sendList', 'sendMediaCaption', 'sendBase64'],
|
|
69
72
|
},
|
|
70
73
|
},
|
|
71
74
|
description: 'Número, CPF ou UUID da conexão (conforme operação)',
|
|
@@ -113,7 +116,7 @@ class Digitalsac {
|
|
|
113
116
|
default: 'Digitalsac123',
|
|
114
117
|
displayOptions: {
|
|
115
118
|
show: {
|
|
116
|
-
operation: ['sendMessage', 'sendButtons',
|
|
119
|
+
operation: ['sendMessage', 'sendButtons', 'sendList', 'sendMediaCaption', 'sendBase64'],
|
|
117
120
|
},
|
|
118
121
|
},
|
|
119
122
|
description: 'Identificador único opcional para a mensagem',
|
|
@@ -167,8 +170,7 @@ class Digitalsac {
|
|
|
167
170
|
},
|
|
168
171
|
description: 'Array de botões em formato JSON',
|
|
169
172
|
},
|
|
170
|
-
// Campos para Enviar Lista
|
|
171
|
-
/*
|
|
173
|
+
// Campos para Enviar Lista
|
|
172
174
|
{
|
|
173
175
|
displayName: 'Título',
|
|
174
176
|
name: 'listTitle',
|
|
@@ -241,7 +243,6 @@ class Digitalsac {
|
|
|
241
243
|
},
|
|
242
244
|
description: 'Array de seções da lista em formato JSON',
|
|
243
245
|
},
|
|
244
|
-
*/
|
|
245
246
|
// Campos para Enviar Mídia com Caption
|
|
246
247
|
{
|
|
247
248
|
displayName: 'Caption',
|
|
@@ -646,6 +647,55 @@ class Digitalsac {
|
|
|
646
647
|
},
|
|
647
648
|
description: 'ID do agendamento para gerar o link do calendário',
|
|
648
649
|
},
|
|
650
|
+
// Campos para Templates WABA
|
|
651
|
+
{
|
|
652
|
+
displayName: 'WhatsApp ID',
|
|
653
|
+
name: 'wabaWhatsappId',
|
|
654
|
+
type: 'number',
|
|
655
|
+
default: 1,
|
|
656
|
+
displayOptions: {
|
|
657
|
+
show: {
|
|
658
|
+
operation: ['listWabaTemplates', 'sendWabaTemplate'],
|
|
659
|
+
},
|
|
660
|
+
},
|
|
661
|
+
description: 'ID da conexão WhatsApp WABA',
|
|
662
|
+
},
|
|
663
|
+
{
|
|
664
|
+
displayName: 'Template ID',
|
|
665
|
+
name: 'wabaTemplateId',
|
|
666
|
+
type: 'number',
|
|
667
|
+
default: 1,
|
|
668
|
+
displayOptions: {
|
|
669
|
+
show: {
|
|
670
|
+
operation: ['sendWabaTemplate'],
|
|
671
|
+
},
|
|
672
|
+
},
|
|
673
|
+
description: 'ID do template no sistema (obtido após importação)',
|
|
674
|
+
},
|
|
675
|
+
{
|
|
676
|
+
displayName: 'Número de Telefone',
|
|
677
|
+
name: 'wabaPhoneNumber',
|
|
678
|
+
type: 'string',
|
|
679
|
+
default: '5511999999999',
|
|
680
|
+
displayOptions: {
|
|
681
|
+
show: {
|
|
682
|
+
operation: ['sendWabaTemplate'],
|
|
683
|
+
},
|
|
684
|
+
},
|
|
685
|
+
description: 'Número do destinatário com DDI (ex: 5511999999999)',
|
|
686
|
+
},
|
|
687
|
+
{
|
|
688
|
+
displayName: 'Parâmetros do Template (JSON)',
|
|
689
|
+
name: 'wabaTemplateParams',
|
|
690
|
+
type: 'json',
|
|
691
|
+
default: '{}',
|
|
692
|
+
displayOptions: {
|
|
693
|
+
show: {
|
|
694
|
+
operation: ['sendWabaTemplate'],
|
|
695
|
+
},
|
|
696
|
+
},
|
|
697
|
+
description: 'Parâmetros customizados para substituir variáveis no template (ex: {"nome_cliente": "João", "numero_pedido": "12345"})',
|
|
698
|
+
},
|
|
649
699
|
],
|
|
650
700
|
};
|
|
651
701
|
}
|
|
@@ -999,6 +1049,42 @@ class Digitalsac {
|
|
|
999
1049
|
const calendarScheduleId = this.getNodeParameter('calendarScheduleId', i);
|
|
1000
1050
|
url = `/typebot/calendar-link?scheduleId=${calendarScheduleId}`;
|
|
1001
1051
|
break;
|
|
1052
|
+
case 'listWabaTemplates':
|
|
1053
|
+
const wabaWhatsappIdForList = this.getNodeParameter('wabaWhatsappId', i);
|
|
1054
|
+
url = `/typebot/listar_templates_waba/${wabaWhatsappIdForList}`;
|
|
1055
|
+
method = 'GET';
|
|
1056
|
+
break;
|
|
1057
|
+
case 'sendWabaTemplate':
|
|
1058
|
+
url = '/typebot/enviar_template_waba';
|
|
1059
|
+
method = 'POST';
|
|
1060
|
+
const wabaTemplateId = this.getNodeParameter('wabaTemplateId', i);
|
|
1061
|
+
const wabaPhoneNumber = this.getNodeParameter('wabaPhoneNumber', i);
|
|
1062
|
+
const wabaWhatsappId = this.getNodeParameter('wabaWhatsappId', i);
|
|
1063
|
+
const wabaTemplateParams = this.getNodeParameter('wabaTemplateParams', i);
|
|
1064
|
+
let parsedTemplateParams = {};
|
|
1065
|
+
if (wabaTemplateParams && wabaTemplateParams.trim() !== '' && wabaTemplateParams.trim() !== '{}') {
|
|
1066
|
+
try {
|
|
1067
|
+
parsedTemplateParams = JSON.parse(wabaTemplateParams);
|
|
1068
|
+
}
|
|
1069
|
+
catch (error) {
|
|
1070
|
+
throw new Error('Erro ao fazer parse do JSON dos parâmetros do template. Verifique a sintaxe.');
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
body = {
|
|
1074
|
+
templateId: wabaTemplateId,
|
|
1075
|
+
phoneNumber: wabaPhoneNumber,
|
|
1076
|
+
whatsappId: wabaWhatsappId,
|
|
1077
|
+
templateParams: parsedTemplateParams
|
|
1078
|
+
};
|
|
1079
|
+
headers['Content-Type'] = 'application/json';
|
|
1080
|
+
options = {
|
|
1081
|
+
method,
|
|
1082
|
+
headers,
|
|
1083
|
+
body,
|
|
1084
|
+
uri: `${baseUrl}${url}`,
|
|
1085
|
+
json: true,
|
|
1086
|
+
};
|
|
1087
|
+
break;
|
|
1002
1088
|
case 'sendButtons':
|
|
1003
1089
|
// Validar se o UUID foi fornecido
|
|
1004
1090
|
if (!param || param.trim() === '') {
|
|
@@ -1034,32 +1120,27 @@ class Digitalsac {
|
|
|
1034
1120
|
json: true,
|
|
1035
1121
|
};
|
|
1036
1122
|
break;
|
|
1037
|
-
// TEMPORARIAMENTE DESABILITADO - sendList
|
|
1038
|
-
/*
|
|
1039
1123
|
case 'sendList':
|
|
1040
1124
|
// Validar se o UUID foi fornecido
|
|
1041
1125
|
if (!param || param.trim() === '') {
|
|
1042
1126
|
throw new Error('UUID da conexão é obrigatório para enviar lista. Preencha o campo "Parâmetro" com o UUID da conexão.');
|
|
1043
1127
|
}
|
|
1044
|
-
|
|
1045
1128
|
url = `/v1/api/external/${param}/send-list`;
|
|
1046
1129
|
method = 'POST';
|
|
1047
|
-
|
|
1048
|
-
const
|
|
1049
|
-
const
|
|
1050
|
-
const
|
|
1051
|
-
const
|
|
1052
|
-
const
|
|
1053
|
-
const
|
|
1054
|
-
const sectionsData = this.getNodeParameter('sectionsData', i) as string;
|
|
1055
|
-
|
|
1130
|
+
const listTitle = this.getNodeParameter('listTitle', i);
|
|
1131
|
+
const listText = this.getNodeParameter('listText', i);
|
|
1132
|
+
const listButtonText = this.getNodeParameter('listButtonText', i);
|
|
1133
|
+
const listFooter = this.getNodeParameter('listFooter', i);
|
|
1134
|
+
const listPhoneNumber = this.getNodeParameter('listPhoneNumber', i);
|
|
1135
|
+
const listExternalKey = this.getNodeParameter('externalKey', i);
|
|
1136
|
+
const sectionsData = this.getNodeParameter('sectionsData', i);
|
|
1056
1137
|
let parsedSections;
|
|
1057
1138
|
try {
|
|
1058
1139
|
parsedSections = JSON.parse(sectionsData);
|
|
1059
|
-
}
|
|
1140
|
+
}
|
|
1141
|
+
catch (error) {
|
|
1060
1142
|
throw new Error('Erro ao fazer parse do JSON das seções. Verifique a sintaxe.');
|
|
1061
1143
|
}
|
|
1062
|
-
|
|
1063
1144
|
body = {
|
|
1064
1145
|
title: listTitle,
|
|
1065
1146
|
text: listText,
|
|
@@ -1069,7 +1150,6 @@ class Digitalsac {
|
|
|
1069
1150
|
sections: parsedSections,
|
|
1070
1151
|
externalKey: listExternalKey
|
|
1071
1152
|
};
|
|
1072
|
-
|
|
1073
1153
|
headers['Content-Type'] = 'application/json';
|
|
1074
1154
|
options = {
|
|
1075
1155
|
method,
|
|
@@ -1079,7 +1159,6 @@ class Digitalsac {
|
|
|
1079
1159
|
json: true,
|
|
1080
1160
|
};
|
|
1081
1161
|
break;
|
|
1082
|
-
*/
|
|
1083
1162
|
case 'sendMediaCaption':
|
|
1084
1163
|
// Validar se o UUID foi fornecido
|
|
1085
1164
|
if (!param || param.trim() === '') {
|
|
@@ -42,10 +42,10 @@ export class Digitalsac implements INodeType {
|
|
|
42
42
|
{ name: 'Transferir para Fila', value: 'transferQueue' },
|
|
43
43
|
{ name: 'Transferir para Atendente', value: 'transferAgent' },
|
|
44
44
|
{ name: 'Fechar Ticket', value: 'closeTicket' },
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
{ name: 'Enviar Mensagem', value: 'sendMessage' },
|
|
46
|
+
{ name: 'Enviar Botões', value: 'sendButtons' },
|
|
47
|
+
{ name: 'Enviar Lista', value: 'sendList' },
|
|
48
|
+
{ name: 'Enviar Mídia com Caption', value: 'sendMediaCaption' },
|
|
49
49
|
{ name: 'Enviar Base64', value: 'sendBase64' },
|
|
50
50
|
{ name: 'Listar Tags', value: 'listTags' },
|
|
51
51
|
{ name: 'Vincular Tag', value: 'linkTag' },
|
|
@@ -59,12 +59,15 @@ export class Digitalsac implements INodeType {
|
|
|
59
59
|
{ name: 'Listar Usuários Disponíveis', value: 'listAvailableUsers' },
|
|
60
60
|
{ name: 'Listar Horários Disponíveis', value: 'listAvailableSlots' },
|
|
61
61
|
{ name: 'Listar Agendamentos', value: 'listSchedules' },
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
{ name: 'Criar Agendamento', value: 'createSchedule' },
|
|
63
|
+
{ name: 'Cancelar Agendamento', value: 'cancelSchedule' },
|
|
64
|
+
{ name: 'Gerar Link do Calendário (.ics)', value: 'calendarLink' },
|
|
65
|
+
// Templates WABA
|
|
66
|
+
{ name: 'Listar Templates WABA', value: 'listWabaTemplates' },
|
|
67
|
+
{ name: 'Enviar Template WABA', value: 'sendWabaTemplate' },
|
|
68
|
+
],
|
|
69
|
+
default: 'validateWhatsapp',
|
|
70
|
+
},
|
|
68
71
|
{
|
|
69
72
|
displayName: 'Parâmetro',
|
|
70
73
|
name: 'param',
|
|
@@ -72,7 +75,7 @@ export class Digitalsac implements INodeType {
|
|
|
72
75
|
default: '',
|
|
73
76
|
displayOptions: {
|
|
74
77
|
show: {
|
|
75
|
-
operation: ['validateWhatsapp', 'validateCpf', 'sendMessage', 'sendButtons',
|
|
78
|
+
operation: ['validateWhatsapp', 'validateCpf', 'sendMessage', 'sendButtons', 'sendList', 'sendMediaCaption', 'sendBase64'],
|
|
76
79
|
},
|
|
77
80
|
},
|
|
78
81
|
description: 'Número, CPF ou UUID da conexão (conforme operação)',
|
|
@@ -120,7 +123,7 @@ export class Digitalsac implements INodeType {
|
|
|
120
123
|
default: 'Digitalsac123',
|
|
121
124
|
displayOptions: {
|
|
122
125
|
show: {
|
|
123
|
-
operation: ['sendMessage', 'sendButtons',
|
|
126
|
+
operation: ['sendMessage', 'sendButtons', 'sendList', 'sendMediaCaption', 'sendBase64'],
|
|
124
127
|
},
|
|
125
128
|
},
|
|
126
129
|
description: 'Identificador único opcional para a mensagem',
|
|
@@ -174,8 +177,7 @@ export class Digitalsac implements INodeType {
|
|
|
174
177
|
},
|
|
175
178
|
description: 'Array de botões em formato JSON',
|
|
176
179
|
},
|
|
177
|
-
// Campos para Enviar Lista
|
|
178
|
-
/*
|
|
180
|
+
// Campos para Enviar Lista
|
|
179
181
|
{
|
|
180
182
|
displayName: 'Título',
|
|
181
183
|
name: 'listTitle',
|
|
@@ -248,7 +250,6 @@ export class Digitalsac implements INodeType {
|
|
|
248
250
|
},
|
|
249
251
|
description: 'Array de seções da lista em formato JSON',
|
|
250
252
|
},
|
|
251
|
-
*/
|
|
252
253
|
// Campos para Enviar Mídia com Caption
|
|
253
254
|
{
|
|
254
255
|
displayName: 'Caption',
|
|
@@ -641,19 +642,68 @@ export class Digitalsac implements INodeType {
|
|
|
641
642
|
},
|
|
642
643
|
description: 'ID do agendamento a ser cancelado',
|
|
643
644
|
},
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
},
|
|
645
|
+
{
|
|
646
|
+
displayName: 'ID do Agendamento',
|
|
647
|
+
name: 'calendarScheduleId',
|
|
648
|
+
type: 'number',
|
|
649
|
+
default: 0,
|
|
650
|
+
displayOptions: {
|
|
651
|
+
show: {
|
|
652
|
+
operation: ['calendarLink'],
|
|
653
653
|
},
|
|
654
|
-
description: 'ID do agendamento para gerar o link do calendário',
|
|
655
654
|
},
|
|
656
|
-
|
|
655
|
+
description: 'ID do agendamento para gerar o link do calendário',
|
|
656
|
+
},
|
|
657
|
+
// Campos para Templates WABA
|
|
658
|
+
{
|
|
659
|
+
displayName: 'WhatsApp ID',
|
|
660
|
+
name: 'wabaWhatsappId',
|
|
661
|
+
type: 'number',
|
|
662
|
+
default: 1,
|
|
663
|
+
displayOptions: {
|
|
664
|
+
show: {
|
|
665
|
+
operation: ['listWabaTemplates', 'sendWabaTemplate'],
|
|
666
|
+
},
|
|
667
|
+
},
|
|
668
|
+
description: 'ID da conexão WhatsApp WABA',
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
displayName: 'Template ID',
|
|
672
|
+
name: 'wabaTemplateId',
|
|
673
|
+
type: 'number',
|
|
674
|
+
default: 1,
|
|
675
|
+
displayOptions: {
|
|
676
|
+
show: {
|
|
677
|
+
operation: ['sendWabaTemplate'],
|
|
678
|
+
},
|
|
679
|
+
},
|
|
680
|
+
description: 'ID do template no sistema (obtido após importação)',
|
|
681
|
+
},
|
|
682
|
+
{
|
|
683
|
+
displayName: 'Número de Telefone',
|
|
684
|
+
name: 'wabaPhoneNumber',
|
|
685
|
+
type: 'string',
|
|
686
|
+
default: '5511999999999',
|
|
687
|
+
displayOptions: {
|
|
688
|
+
show: {
|
|
689
|
+
operation: ['sendWabaTemplate'],
|
|
690
|
+
},
|
|
691
|
+
},
|
|
692
|
+
description: 'Número do destinatário com DDI (ex: 5511999999999)',
|
|
693
|
+
},
|
|
694
|
+
{
|
|
695
|
+
displayName: 'Parâmetros do Template (JSON)',
|
|
696
|
+
name: 'wabaTemplateParams',
|
|
697
|
+
type: 'json',
|
|
698
|
+
default: '{}',
|
|
699
|
+
displayOptions: {
|
|
700
|
+
show: {
|
|
701
|
+
operation: ['sendWabaTemplate'],
|
|
702
|
+
},
|
|
703
|
+
},
|
|
704
|
+
description: 'Parâmetros customizados para substituir variáveis no template (ex: {"nome_cliente": "João", "numero_pedido": "12345"})',
|
|
705
|
+
},
|
|
706
|
+
],
|
|
657
707
|
};
|
|
658
708
|
|
|
659
709
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
|
@@ -1026,12 +1076,55 @@ export class Digitalsac implements INodeType {
|
|
|
1026
1076
|
};
|
|
1027
1077
|
break;
|
|
1028
1078
|
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1079
|
+
case 'calendarLink':
|
|
1080
|
+
const calendarScheduleId = this.getNodeParameter('calendarScheduleId', i) as number;
|
|
1081
|
+
|
|
1082
|
+
url = `/typebot/calendar-link?scheduleId=${calendarScheduleId}`;
|
|
1083
|
+
break;
|
|
1084
|
+
|
|
1085
|
+
case 'listWabaTemplates':
|
|
1086
|
+
const wabaWhatsappIdForList = this.getNodeParameter('wabaWhatsappId', i) as number;
|
|
1087
|
+
|
|
1088
|
+
url = `/typebot/listar_templates_waba/${wabaWhatsappIdForList}`;
|
|
1089
|
+
method = 'GET';
|
|
1090
|
+
break;
|
|
1091
|
+
|
|
1092
|
+
case 'sendWabaTemplate':
|
|
1093
|
+
url = '/typebot/enviar_template_waba';
|
|
1094
|
+
method = 'POST';
|
|
1095
|
+
|
|
1096
|
+
const wabaTemplateId = this.getNodeParameter('wabaTemplateId', i) as number;
|
|
1097
|
+
const wabaPhoneNumber = this.getNodeParameter('wabaPhoneNumber', i) as string;
|
|
1098
|
+
const wabaWhatsappId = this.getNodeParameter('wabaWhatsappId', i) as number;
|
|
1099
|
+
const wabaTemplateParams = this.getNodeParameter('wabaTemplateParams', i) as string;
|
|
1100
|
+
|
|
1101
|
+
let parsedTemplateParams = {};
|
|
1102
|
+
if (wabaTemplateParams && wabaTemplateParams.trim() !== '' && wabaTemplateParams.trim() !== '{}') {
|
|
1103
|
+
try {
|
|
1104
|
+
parsedTemplateParams = JSON.parse(wabaTemplateParams);
|
|
1105
|
+
} catch (error) {
|
|
1106
|
+
throw new Error('Erro ao fazer parse do JSON dos parâmetros do template. Verifique a sintaxe.');
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
body = {
|
|
1111
|
+
templateId: wabaTemplateId,
|
|
1112
|
+
phoneNumber: wabaPhoneNumber,
|
|
1113
|
+
whatsappId: wabaWhatsappId,
|
|
1114
|
+
templateParams: parsedTemplateParams
|
|
1115
|
+
};
|
|
1116
|
+
|
|
1117
|
+
headers['Content-Type'] = 'application/json';
|
|
1118
|
+
options = {
|
|
1119
|
+
method,
|
|
1120
|
+
headers,
|
|
1121
|
+
body,
|
|
1122
|
+
uri: `${baseUrl}${url}`,
|
|
1123
|
+
json: true,
|
|
1124
|
+
};
|
|
1125
|
+
break;
|
|
1126
|
+
|
|
1127
|
+
case 'sendButtons':
|
|
1035
1128
|
// Validar se o UUID foi fornecido
|
|
1036
1129
|
if (!param || param.trim() === '') {
|
|
1037
1130
|
throw new Error('UUID da conexão é obrigatório para enviar botões. Preencha o campo "Parâmetro" com o UUID da conexão.');
|
|
@@ -1070,8 +1163,6 @@ export class Digitalsac implements INodeType {
|
|
|
1070
1163
|
json: true,
|
|
1071
1164
|
};
|
|
1072
1165
|
break;
|
|
1073
|
-
// TEMPORARIAMENTE DESABILITADO - sendList
|
|
1074
|
-
/*
|
|
1075
1166
|
case 'sendList':
|
|
1076
1167
|
// Validar se o UUID foi fornecido
|
|
1077
1168
|
if (!param || param.trim() === '') {
|
|
@@ -1115,7 +1206,6 @@ export class Digitalsac implements INodeType {
|
|
|
1115
1206
|
json: true,
|
|
1116
1207
|
};
|
|
1117
1208
|
break;
|
|
1118
|
-
*/
|
|
1119
1209
|
case 'sendMediaCaption':
|
|
1120
1210
|
// Validar se o UUID foi fornecido
|
|
1121
1211
|
if (!param || param.trim() === '') {
|