n8n-nodes-digitalsac 0.5.5 → 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 -1
- package/dist/nodes/Digitalsac/Digitalsac.node.js +88 -0
- package/nodes/Digitalsac/Digitalsac.node.ts +118 -23
- 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:
|
|
@@ -633,6 +650,79 @@ Gera um link para download do arquivo .ics (calendário) de um agendamento espec
|
|
|
633
650
|
- Pode ser importado em qualquer aplicativo de calendário (Google Calendar, Outlook, Apple Calendar, etc.)
|
|
634
651
|
- É útil para integração com sistemas externos ou envio para clientes
|
|
635
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
|
+
|
|
636
726
|
## 💡 Casos de Uso Práticos
|
|
637
727
|
|
|
638
728
|
### 🤖 Bot de Atendimento Interativo
|
|
@@ -701,6 +791,34 @@ Webhook (Capturar resposta)
|
|
|
701
791
|
9. Webhook (Notificar vendedor)
|
|
702
792
|
```
|
|
703
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
|
+
|
|
704
822
|
## Suporte
|
|
705
823
|
|
|
706
824
|
Para suporte, entre em contato com [contato@digitalsac.io](mailto:contato@digitalsac.io).
|
|
@@ -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
|
},
|
|
@@ -644,6 +647,55 @@ class Digitalsac {
|
|
|
644
647
|
},
|
|
645
648
|
description: 'ID do agendamento para gerar o link do calendário',
|
|
646
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
|
+
},
|
|
647
699
|
],
|
|
648
700
|
};
|
|
649
701
|
}
|
|
@@ -997,6 +1049,42 @@ class Digitalsac {
|
|
|
997
1049
|
const calendarScheduleId = this.getNodeParameter('calendarScheduleId', i);
|
|
998
1050
|
url = `/typebot/calendar-link?scheduleId=${calendarScheduleId}`;
|
|
999
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;
|
|
1000
1088
|
case 'sendButtons':
|
|
1001
1089
|
// Validar se o UUID foi fornecido
|
|
1002
1090
|
if (!param || param.trim() === '') {
|
|
@@ -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',
|
|
@@ -639,19 +642,68 @@ export class Digitalsac implements INodeType {
|
|
|
639
642
|
},
|
|
640
643
|
description: 'ID do agendamento a ser cancelado',
|
|
641
644
|
},
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
},
|
|
645
|
+
{
|
|
646
|
+
displayName: 'ID do Agendamento',
|
|
647
|
+
name: 'calendarScheduleId',
|
|
648
|
+
type: 'number',
|
|
649
|
+
default: 0,
|
|
650
|
+
displayOptions: {
|
|
651
|
+
show: {
|
|
652
|
+
operation: ['calendarLink'],
|
|
651
653
|
},
|
|
652
|
-
description: 'ID do agendamento para gerar o link do calendário',
|
|
653
654
|
},
|
|
654
|
-
|
|
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
|
+
],
|
|
655
707
|
};
|
|
656
708
|
|
|
657
709
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
|
@@ -1024,12 +1076,55 @@ export class Digitalsac implements INodeType {
|
|
|
1024
1076
|
};
|
|
1025
1077
|
break;
|
|
1026
1078
|
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
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':
|
|
1033
1128
|
// Validar se o UUID foi fornecido
|
|
1034
1129
|
if (!param || param.trim() === '') {
|
|
1035
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.');
|