n8n-nodes-digitalsac 0.5.5 → 0.5.7
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 +108 -0
- package/nodes/Digitalsac/Digitalsac.node.ts +154 -39
- 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
|
},
|
|
@@ -82,6 +85,22 @@ class Digitalsac {
|
|
|
82
85
|
},
|
|
83
86
|
description: 'ID do usuário para listar kanbans',
|
|
84
87
|
},
|
|
88
|
+
{
|
|
89
|
+
displayName: 'Formato de Resposta',
|
|
90
|
+
name: 'agentsFormat',
|
|
91
|
+
type: 'options',
|
|
92
|
+
options: [
|
|
93
|
+
{ name: 'JSON Completo (Recomendado)', value: 'json' },
|
|
94
|
+
{ name: 'Texto Formatado (Compatibilidade)', value: 'string' },
|
|
95
|
+
],
|
|
96
|
+
default: 'json',
|
|
97
|
+
displayOptions: {
|
|
98
|
+
show: {
|
|
99
|
+
operation: ['listAgents'],
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
description: 'Formato de retorno: JSON completo com todos os campos (id, name, email, phoneNumber, status, profile, isOnline, isActive, isMaster) ou texto formatado para compatibilidade',
|
|
103
|
+
},
|
|
85
104
|
{
|
|
86
105
|
displayName: 'Corpo da Mensagem',
|
|
87
106
|
name: 'messageBody',
|
|
@@ -644,6 +663,55 @@ class Digitalsac {
|
|
|
644
663
|
},
|
|
645
664
|
description: 'ID do agendamento para gerar o link do calendário',
|
|
646
665
|
},
|
|
666
|
+
// Campos para Templates WABA
|
|
667
|
+
{
|
|
668
|
+
displayName: 'WhatsApp ID',
|
|
669
|
+
name: 'wabaWhatsappId',
|
|
670
|
+
type: 'number',
|
|
671
|
+
default: 1,
|
|
672
|
+
displayOptions: {
|
|
673
|
+
show: {
|
|
674
|
+
operation: ['listWabaTemplates', 'sendWabaTemplate'],
|
|
675
|
+
},
|
|
676
|
+
},
|
|
677
|
+
description: 'ID da conexão WhatsApp WABA',
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
displayName: 'Template ID',
|
|
681
|
+
name: 'wabaTemplateId',
|
|
682
|
+
type: 'number',
|
|
683
|
+
default: 1,
|
|
684
|
+
displayOptions: {
|
|
685
|
+
show: {
|
|
686
|
+
operation: ['sendWabaTemplate'],
|
|
687
|
+
},
|
|
688
|
+
},
|
|
689
|
+
description: 'ID do template no sistema (obtido após importação)',
|
|
690
|
+
},
|
|
691
|
+
{
|
|
692
|
+
displayName: 'Número de Telefone',
|
|
693
|
+
name: 'wabaPhoneNumber',
|
|
694
|
+
type: 'string',
|
|
695
|
+
default: '5511999999999',
|
|
696
|
+
displayOptions: {
|
|
697
|
+
show: {
|
|
698
|
+
operation: ['sendWabaTemplate'],
|
|
699
|
+
},
|
|
700
|
+
},
|
|
701
|
+
description: 'Número do destinatário com DDI (ex: 5511999999999)',
|
|
702
|
+
},
|
|
703
|
+
{
|
|
704
|
+
displayName: 'Parâmetros do Template (JSON)',
|
|
705
|
+
name: 'wabaTemplateParams',
|
|
706
|
+
type: 'json',
|
|
707
|
+
default: '{}',
|
|
708
|
+
displayOptions: {
|
|
709
|
+
show: {
|
|
710
|
+
operation: ['sendWabaTemplate'],
|
|
711
|
+
},
|
|
712
|
+
},
|
|
713
|
+
description: 'Parâmetros customizados para substituir variáveis no template (ex: {"nome_cliente": "João", "numero_pedido": "12345"})',
|
|
714
|
+
},
|
|
647
715
|
],
|
|
648
716
|
};
|
|
649
717
|
}
|
|
@@ -694,7 +762,11 @@ class Digitalsac {
|
|
|
694
762
|
url = '/typebot/listar_filas';
|
|
695
763
|
break;
|
|
696
764
|
case 'listAgents':
|
|
765
|
+
const agentsFormat = this.getNodeParameter('agentsFormat', i, 'json');
|
|
697
766
|
url = '/typebot/listar_atendentes';
|
|
767
|
+
if (agentsFormat === 'string') {
|
|
768
|
+
url += '?format=string';
|
|
769
|
+
}
|
|
698
770
|
break;
|
|
699
771
|
case 'transferQueue':
|
|
700
772
|
url = '/typebot/transferir_para_fila';
|
|
@@ -997,6 +1069,42 @@ class Digitalsac {
|
|
|
997
1069
|
const calendarScheduleId = this.getNodeParameter('calendarScheduleId', i);
|
|
998
1070
|
url = `/typebot/calendar-link?scheduleId=${calendarScheduleId}`;
|
|
999
1071
|
break;
|
|
1072
|
+
case 'listWabaTemplates':
|
|
1073
|
+
const wabaWhatsappIdForList = this.getNodeParameter('wabaWhatsappId', i);
|
|
1074
|
+
url = `/typebot/listar_templates_waba/${wabaWhatsappIdForList}`;
|
|
1075
|
+
method = 'GET';
|
|
1076
|
+
break;
|
|
1077
|
+
case 'sendWabaTemplate':
|
|
1078
|
+
url = '/typebot/enviar_template_waba';
|
|
1079
|
+
method = 'POST';
|
|
1080
|
+
const wabaTemplateId = this.getNodeParameter('wabaTemplateId', i);
|
|
1081
|
+
const wabaPhoneNumber = this.getNodeParameter('wabaPhoneNumber', i);
|
|
1082
|
+
const wabaWhatsappId = this.getNodeParameter('wabaWhatsappId', i);
|
|
1083
|
+
const wabaTemplateParams = this.getNodeParameter('wabaTemplateParams', i);
|
|
1084
|
+
let parsedTemplateParams = {};
|
|
1085
|
+
if (wabaTemplateParams && wabaTemplateParams.trim() !== '' && wabaTemplateParams.trim() !== '{}') {
|
|
1086
|
+
try {
|
|
1087
|
+
parsedTemplateParams = JSON.parse(wabaTemplateParams);
|
|
1088
|
+
}
|
|
1089
|
+
catch (error) {
|
|
1090
|
+
throw new Error('Erro ao fazer parse do JSON dos parâmetros do template. Verifique a sintaxe.');
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
body = {
|
|
1094
|
+
templateId: wabaTemplateId,
|
|
1095
|
+
phoneNumber: wabaPhoneNumber,
|
|
1096
|
+
whatsappId: wabaWhatsappId,
|
|
1097
|
+
templateParams: parsedTemplateParams
|
|
1098
|
+
};
|
|
1099
|
+
headers['Content-Type'] = 'application/json';
|
|
1100
|
+
options = {
|
|
1101
|
+
method,
|
|
1102
|
+
headers,
|
|
1103
|
+
body,
|
|
1104
|
+
uri: `${baseUrl}${url}`,
|
|
1105
|
+
json: true,
|
|
1106
|
+
};
|
|
1107
|
+
break;
|
|
1000
1108
|
case 'sendButtons':
|
|
1001
1109
|
// Validar se o UUID foi fornecido
|
|
1002
1110
|
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',
|
|
@@ -77,18 +80,34 @@ export class Digitalsac implements INodeType {
|
|
|
77
80
|
},
|
|
78
81
|
description: 'Número, CPF ou UUID da conexão (conforme operação)',
|
|
79
82
|
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
83
|
+
{
|
|
84
|
+
displayName: 'User ID',
|
|
85
|
+
name: 'userId',
|
|
86
|
+
type: 'number',
|
|
87
|
+
default: 1,
|
|
88
|
+
displayOptions: {
|
|
89
|
+
show: {
|
|
90
|
+
operation: ['listKanbans'],
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
description: 'ID do usuário para listar kanbans',
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
displayName: 'Formato de Resposta',
|
|
97
|
+
name: 'agentsFormat',
|
|
98
|
+
type: 'options',
|
|
99
|
+
options: [
|
|
100
|
+
{ name: 'JSON Completo (Recomendado)', value: 'json' },
|
|
101
|
+
{ name: 'Texto Formatado (Compatibilidade)', value: 'string' },
|
|
102
|
+
],
|
|
103
|
+
default: 'json',
|
|
104
|
+
displayOptions: {
|
|
105
|
+
show: {
|
|
106
|
+
operation: ['listAgents'],
|
|
89
107
|
},
|
|
90
|
-
description: 'ID do usuário para listar kanbans',
|
|
91
108
|
},
|
|
109
|
+
description: 'Formato de retorno: JSON completo com todos os campos (id, name, email, phoneNumber, status, profile, isOnline, isActive, isMaster) ou texto formatado para compatibilidade',
|
|
110
|
+
},
|
|
92
111
|
{
|
|
93
112
|
displayName: 'Corpo da Mensagem',
|
|
94
113
|
name: 'messageBody',
|
|
@@ -639,19 +658,68 @@ export class Digitalsac implements INodeType {
|
|
|
639
658
|
},
|
|
640
659
|
description: 'ID do agendamento a ser cancelado',
|
|
641
660
|
},
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
},
|
|
661
|
+
{
|
|
662
|
+
displayName: 'ID do Agendamento',
|
|
663
|
+
name: 'calendarScheduleId',
|
|
664
|
+
type: 'number',
|
|
665
|
+
default: 0,
|
|
666
|
+
displayOptions: {
|
|
667
|
+
show: {
|
|
668
|
+
operation: ['calendarLink'],
|
|
651
669
|
},
|
|
652
|
-
description: 'ID do agendamento para gerar o link do calendário',
|
|
653
670
|
},
|
|
654
|
-
|
|
671
|
+
description: 'ID do agendamento para gerar o link do calendário',
|
|
672
|
+
},
|
|
673
|
+
// Campos para Templates WABA
|
|
674
|
+
{
|
|
675
|
+
displayName: 'WhatsApp ID',
|
|
676
|
+
name: 'wabaWhatsappId',
|
|
677
|
+
type: 'number',
|
|
678
|
+
default: 1,
|
|
679
|
+
displayOptions: {
|
|
680
|
+
show: {
|
|
681
|
+
operation: ['listWabaTemplates', 'sendWabaTemplate'],
|
|
682
|
+
},
|
|
683
|
+
},
|
|
684
|
+
description: 'ID da conexão WhatsApp WABA',
|
|
685
|
+
},
|
|
686
|
+
{
|
|
687
|
+
displayName: 'Template ID',
|
|
688
|
+
name: 'wabaTemplateId',
|
|
689
|
+
type: 'number',
|
|
690
|
+
default: 1,
|
|
691
|
+
displayOptions: {
|
|
692
|
+
show: {
|
|
693
|
+
operation: ['sendWabaTemplate'],
|
|
694
|
+
},
|
|
695
|
+
},
|
|
696
|
+
description: 'ID do template no sistema (obtido após importação)',
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
displayName: 'Número de Telefone',
|
|
700
|
+
name: 'wabaPhoneNumber',
|
|
701
|
+
type: 'string',
|
|
702
|
+
default: '5511999999999',
|
|
703
|
+
displayOptions: {
|
|
704
|
+
show: {
|
|
705
|
+
operation: ['sendWabaTemplate'],
|
|
706
|
+
},
|
|
707
|
+
},
|
|
708
|
+
description: 'Número do destinatário com DDI (ex: 5511999999999)',
|
|
709
|
+
},
|
|
710
|
+
{
|
|
711
|
+
displayName: 'Parâmetros do Template (JSON)',
|
|
712
|
+
name: 'wabaTemplateParams',
|
|
713
|
+
type: 'json',
|
|
714
|
+
default: '{}',
|
|
715
|
+
displayOptions: {
|
|
716
|
+
show: {
|
|
717
|
+
operation: ['sendWabaTemplate'],
|
|
718
|
+
},
|
|
719
|
+
},
|
|
720
|
+
description: 'Parâmetros customizados para substituir variáveis no template (ex: {"nome_cliente": "João", "numero_pedido": "12345"})',
|
|
721
|
+
},
|
|
722
|
+
],
|
|
655
723
|
};
|
|
656
724
|
|
|
657
725
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
|
@@ -701,12 +769,16 @@ export class Digitalsac implements INodeType {
|
|
|
701
769
|
json: true,
|
|
702
770
|
};
|
|
703
771
|
break;
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
772
|
+
case 'listQueues':
|
|
773
|
+
url = '/typebot/listar_filas';
|
|
774
|
+
break;
|
|
775
|
+
case 'listAgents':
|
|
776
|
+
const agentsFormat = this.getNodeParameter('agentsFormat', i, 'json') as string;
|
|
777
|
+
url = '/typebot/listar_atendentes';
|
|
778
|
+
if (agentsFormat === 'string') {
|
|
779
|
+
url += '?format=string';
|
|
780
|
+
}
|
|
781
|
+
break;
|
|
710
782
|
case 'transferQueue':
|
|
711
783
|
url = '/typebot/transferir_para_fila';
|
|
712
784
|
method = 'POST';
|
|
@@ -1024,12 +1096,55 @@ export class Digitalsac implements INodeType {
|
|
|
1024
1096
|
};
|
|
1025
1097
|
break;
|
|
1026
1098
|
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1099
|
+
case 'calendarLink':
|
|
1100
|
+
const calendarScheduleId = this.getNodeParameter('calendarScheduleId', i) as number;
|
|
1101
|
+
|
|
1102
|
+
url = `/typebot/calendar-link?scheduleId=${calendarScheduleId}`;
|
|
1103
|
+
break;
|
|
1104
|
+
|
|
1105
|
+
case 'listWabaTemplates':
|
|
1106
|
+
const wabaWhatsappIdForList = this.getNodeParameter('wabaWhatsappId', i) as number;
|
|
1107
|
+
|
|
1108
|
+
url = `/typebot/listar_templates_waba/${wabaWhatsappIdForList}`;
|
|
1109
|
+
method = 'GET';
|
|
1110
|
+
break;
|
|
1111
|
+
|
|
1112
|
+
case 'sendWabaTemplate':
|
|
1113
|
+
url = '/typebot/enviar_template_waba';
|
|
1114
|
+
method = 'POST';
|
|
1115
|
+
|
|
1116
|
+
const wabaTemplateId = this.getNodeParameter('wabaTemplateId', i) as number;
|
|
1117
|
+
const wabaPhoneNumber = this.getNodeParameter('wabaPhoneNumber', i) as string;
|
|
1118
|
+
const wabaWhatsappId = this.getNodeParameter('wabaWhatsappId', i) as number;
|
|
1119
|
+
const wabaTemplateParams = this.getNodeParameter('wabaTemplateParams', i) as string;
|
|
1120
|
+
|
|
1121
|
+
let parsedTemplateParams = {};
|
|
1122
|
+
if (wabaTemplateParams && wabaTemplateParams.trim() !== '' && wabaTemplateParams.trim() !== '{}') {
|
|
1123
|
+
try {
|
|
1124
|
+
parsedTemplateParams = JSON.parse(wabaTemplateParams);
|
|
1125
|
+
} catch (error) {
|
|
1126
|
+
throw new Error('Erro ao fazer parse do JSON dos parâmetros do template. Verifique a sintaxe.');
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
body = {
|
|
1131
|
+
templateId: wabaTemplateId,
|
|
1132
|
+
phoneNumber: wabaPhoneNumber,
|
|
1133
|
+
whatsappId: wabaWhatsappId,
|
|
1134
|
+
templateParams: parsedTemplateParams
|
|
1135
|
+
};
|
|
1136
|
+
|
|
1137
|
+
headers['Content-Type'] = 'application/json';
|
|
1138
|
+
options = {
|
|
1139
|
+
method,
|
|
1140
|
+
headers,
|
|
1141
|
+
body,
|
|
1142
|
+
uri: `${baseUrl}${url}`,
|
|
1143
|
+
json: true,
|
|
1144
|
+
};
|
|
1145
|
+
break;
|
|
1146
|
+
|
|
1147
|
+
case 'sendButtons':
|
|
1033
1148
|
// Validar se o UUID foi fornecido
|
|
1034
1149
|
if (!param || param.trim() === '') {
|
|
1035
1150
|
throw new Error('UUID da conexão é obrigatório para enviar botões. Preencha o campo "Parâmetro" com o UUID da conexão.');
|