n8n-nodes-digitalsac 0.3.1 → 0.4.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.
- package/README.md +97 -0
- package/dist/nodes/Digitalsac/Digitalsac.node.js +260 -0
- package/nodes/Digitalsac/Digitalsac.node.ts +273 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -20,6 +20,12 @@ Este pacote adiciona um nó personalizado ao n8n para interagir com a API do Dig
|
|
|
20
20
|
- Vincular Kanban
|
|
21
21
|
- Listar Carteiras
|
|
22
22
|
- Vincular Carteira
|
|
23
|
+
- **Agendamento:**
|
|
24
|
+
- Listar Serviços
|
|
25
|
+
- Listar Usuários Disponíveis
|
|
26
|
+
- Listar Horários Disponíveis
|
|
27
|
+
- Criar Agendamento
|
|
28
|
+
- Cancelar Agendamento
|
|
23
29
|
|
|
24
30
|
## Instalação
|
|
25
31
|
|
|
@@ -323,6 +329,97 @@ Onde:
|
|
|
323
329
|
}
|
|
324
330
|
```
|
|
325
331
|
|
|
332
|
+
## Funcionalidades de Agendamento
|
|
333
|
+
|
|
334
|
+
### Listar Serviços
|
|
335
|
+
Lista todos os serviços disponíveis para agendamento.
|
|
336
|
+
1. Selecione a operação **Listar Serviços**
|
|
337
|
+
2. (Opcional) No campo **ID do Usuário**, insira o ID do usuário para filtrar apenas os serviços que ele atende
|
|
338
|
+
|
|
339
|
+
**Retorno exemplo:**
|
|
340
|
+
```json
|
|
341
|
+
{
|
|
342
|
+
"servicos": "*1* - Consulta (30min - R$ 100,00)\n*2* - Retorno (15min - R$ 50,00)"
|
|
343
|
+
}
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### Listar Usuários Disponíveis
|
|
347
|
+
Lista os usuários/atendentes disponíveis para um serviço em uma data específica.
|
|
348
|
+
1. Selecione a operação **Listar Usuários Disponíveis**
|
|
349
|
+
2. Preencha:
|
|
350
|
+
- **ID do Serviço**: ID do serviço desejado
|
|
351
|
+
- **Data**: Data no formato YYYY-MM-DD (ex: 2025-08-07)
|
|
352
|
+
- **Horário** (opcional): Horário específico no formato HH:mm (ex: 09:00)
|
|
353
|
+
|
|
354
|
+
**Retorno exemplo:**
|
|
355
|
+
```json
|
|
356
|
+
{
|
|
357
|
+
"usuarios": "*28* - João Silva\n*29* - Maria Santos"
|
|
358
|
+
}
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### Listar Horários Disponíveis
|
|
362
|
+
Lista os horários disponíveis para um serviço e usuário em uma data específica.
|
|
363
|
+
1. Selecione a operação **Listar Horários Disponíveis**
|
|
364
|
+
2. Preencha:
|
|
365
|
+
- **ID do Serviço**: ID do serviço desejado
|
|
366
|
+
- **ID do Usuário**: ID do atendente/usuário
|
|
367
|
+
- **Data**: Data no formato YYYY-MM-DD
|
|
368
|
+
|
|
369
|
+
**Retorno exemplo:**
|
|
370
|
+
```json
|
|
371
|
+
{
|
|
372
|
+
"horarios": "*1* - 09:00\n*2* - 09:30\n*3* - 10:00\n*4* - 10:30"
|
|
373
|
+
}
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
### Criar Agendamento
|
|
377
|
+
Cria um novo agendamento no sistema.
|
|
378
|
+
1. Selecione a operação **Criar Agendamento**
|
|
379
|
+
2. Preencha:
|
|
380
|
+
- **ID do Serviço**: ID do serviço
|
|
381
|
+
- **ID do Usuário**: ID do atendente/usuário
|
|
382
|
+
- **Data**: Data do agendamento (YYYY-MM-DD)
|
|
383
|
+
- **Horário**: Horário do agendamento (HH:mm)
|
|
384
|
+
- **Nome do Contato**: Nome do cliente
|
|
385
|
+
- **Telefone do Contato**: Telefone do cliente (formato: 5511999999999)
|
|
386
|
+
- **Observações** (opcional): Notas sobre o agendamento
|
|
387
|
+
- **ID da Conexão WhatsApp** (opcional): ID da conexão WhatsApp (usa primeira disponível se não informado)
|
|
388
|
+
- **Mensagem Personalizada** (opcional): Mensagem personalizada do agendamento
|
|
389
|
+
- **Lembretes (minutos)**: Lembretes em minutos antes do agendamento (separados por vírgula, ex: 60,240,1440)
|
|
390
|
+
- **Duração do Intervalo (minutos)**: Duração do intervalo em minutos (padrão: 30)
|
|
391
|
+
- **Fechar Ticket**: Se deve fechar o ticket após criar agendamento
|
|
392
|
+
|
|
393
|
+
**Observações importantes:**
|
|
394
|
+
- Se o contato não existir no sistema, ele será criado automaticamente
|
|
395
|
+
- Se não informar conexão WhatsApp, será usada a primeira disponível
|
|
396
|
+
- Os lembretes são em minutos (60 = 1 hora, 240 = 4 horas, 1440 = 1 dia)
|
|
397
|
+
|
|
398
|
+
**Retorno exemplo:**
|
|
399
|
+
```json
|
|
400
|
+
{
|
|
401
|
+
"status": 1,
|
|
402
|
+
"mensagem": "Agendamento criado com sucesso",
|
|
403
|
+
"scheduleId": 123,
|
|
404
|
+
"contactId": 456,
|
|
405
|
+
"whatsappId": 789
|
|
406
|
+
}
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
### Cancelar Agendamento
|
|
410
|
+
Cancela um agendamento existente.
|
|
411
|
+
1. Selecione a operação **Cancelar Agendamento**
|
|
412
|
+
2. Preencha:
|
|
413
|
+
- **ID do Agendamento**: ID do agendamento a ser cancelado
|
|
414
|
+
|
|
415
|
+
**Retorno exemplo:**
|
|
416
|
+
```json
|
|
417
|
+
{
|
|
418
|
+
"status": 0,
|
|
419
|
+
"mensagem": "Agendamento cancelado com sucesso"
|
|
420
|
+
}
|
|
421
|
+
```
|
|
422
|
+
|
|
326
423
|
## Suporte
|
|
327
424
|
|
|
328
425
|
Para suporte, entre em contato com [contato@digitalsac.io](mailto:contato@digitalsac.io).
|
|
@@ -43,6 +43,12 @@ class Digitalsac {
|
|
|
43
43
|
{ name: 'Vincular Kanban', value: 'linkKanban' },
|
|
44
44
|
{ name: 'Listar Carteiras', value: 'listCarteiras' },
|
|
45
45
|
{ name: 'Vincular Carteira', value: 'linkCarteira' },
|
|
46
|
+
// Agendamento
|
|
47
|
+
{ name: 'Listar Serviços', value: 'listServices' },
|
|
48
|
+
{ name: 'Listar Usuários Disponíveis', value: 'listAvailableUsers' },
|
|
49
|
+
{ name: 'Listar Horários Disponíveis', value: 'listAvailableSlots' },
|
|
50
|
+
{ name: 'Criar Agendamento', value: 'createSchedule' },
|
|
51
|
+
{ name: 'Cancelar Agendamento', value: 'cancelSchedule' },
|
|
46
52
|
],
|
|
47
53
|
default: 'validateWhatsapp',
|
|
48
54
|
},
|
|
@@ -214,6 +220,179 @@ class Digitalsac {
|
|
|
214
220
|
},
|
|
215
221
|
description: 'ID do ticket e ID do usuário da carteira',
|
|
216
222
|
},
|
|
223
|
+
// Campos para Agendamento
|
|
224
|
+
{
|
|
225
|
+
displayName: 'ID do Usuário',
|
|
226
|
+
name: 'scheduleUserId',
|
|
227
|
+
type: 'number',
|
|
228
|
+
default: 0,
|
|
229
|
+
displayOptions: {
|
|
230
|
+
show: {
|
|
231
|
+
operation: ['listServices'],
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
description: 'ID do usuário para filtrar serviços (opcional)',
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
displayName: 'ID do Serviço',
|
|
238
|
+
name: 'serviceId',
|
|
239
|
+
type: 'number',
|
|
240
|
+
default: 1,
|
|
241
|
+
displayOptions: {
|
|
242
|
+
show: {
|
|
243
|
+
operation: ['listAvailableUsers', 'listAvailableSlots', 'createSchedule'],
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
description: 'ID do serviço',
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
displayName: 'Data',
|
|
250
|
+
name: 'scheduleDate',
|
|
251
|
+
type: 'string',
|
|
252
|
+
default: '',
|
|
253
|
+
placeholder: '2025-08-07',
|
|
254
|
+
displayOptions: {
|
|
255
|
+
show: {
|
|
256
|
+
operation: ['listAvailableUsers', 'listAvailableSlots', 'createSchedule'],
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
description: 'Data no formato YYYY-MM-DD',
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
displayName: 'Horário',
|
|
263
|
+
name: 'scheduleTime',
|
|
264
|
+
type: 'string',
|
|
265
|
+
default: '',
|
|
266
|
+
placeholder: '09:00',
|
|
267
|
+
displayOptions: {
|
|
268
|
+
show: {
|
|
269
|
+
operation: ['listAvailableUsers', 'createSchedule'],
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
description: 'Horário no formato HH:mm (opcional para listar usuários)',
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
displayName: 'ID do Usuário',
|
|
276
|
+
name: 'scheduleAttendantId',
|
|
277
|
+
type: 'number',
|
|
278
|
+
default: 1,
|
|
279
|
+
displayOptions: {
|
|
280
|
+
show: {
|
|
281
|
+
operation: ['listAvailableSlots', 'createSchedule'],
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
description: 'ID do atendente/usuário',
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
displayName: 'Nome do Contato',
|
|
288
|
+
name: 'contactName',
|
|
289
|
+
type: 'string',
|
|
290
|
+
default: '',
|
|
291
|
+
displayOptions: {
|
|
292
|
+
show: {
|
|
293
|
+
operation: ['createSchedule'],
|
|
294
|
+
},
|
|
295
|
+
},
|
|
296
|
+
description: 'Nome do cliente/contato',
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
displayName: 'Telefone do Contato',
|
|
300
|
+
name: 'contactPhone',
|
|
301
|
+
type: 'string',
|
|
302
|
+
default: '',
|
|
303
|
+
placeholder: '5511999999999',
|
|
304
|
+
displayOptions: {
|
|
305
|
+
show: {
|
|
306
|
+
operation: ['createSchedule'],
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
description: 'Telefone do cliente/contato',
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
displayName: 'Observações',
|
|
313
|
+
name: 'scheduleNotes',
|
|
314
|
+
type: 'string',
|
|
315
|
+
default: '',
|
|
316
|
+
displayOptions: {
|
|
317
|
+
show: {
|
|
318
|
+
operation: ['createSchedule'],
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
description: 'Observações sobre o agendamento (opcional)',
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
displayName: 'ID da Conexão WhatsApp',
|
|
325
|
+
name: 'whatsappId',
|
|
326
|
+
type: 'number',
|
|
327
|
+
default: 0,
|
|
328
|
+
displayOptions: {
|
|
329
|
+
show: {
|
|
330
|
+
operation: ['createSchedule'],
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
description: 'ID da conexão WhatsApp (opcional - usa primeira disponível se não informado)',
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
displayName: 'Mensagem Personalizada',
|
|
337
|
+
name: 'customMessage',
|
|
338
|
+
type: 'string',
|
|
339
|
+
default: '',
|
|
340
|
+
displayOptions: {
|
|
341
|
+
show: {
|
|
342
|
+
operation: ['createSchedule'],
|
|
343
|
+
},
|
|
344
|
+
},
|
|
345
|
+
description: 'Mensagem personalizada do agendamento (opcional)',
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
displayName: 'Lembretes (minutos)',
|
|
349
|
+
name: 'reminders',
|
|
350
|
+
type: 'string',
|
|
351
|
+
default: '60,240',
|
|
352
|
+
placeholder: '60,240,1440',
|
|
353
|
+
displayOptions: {
|
|
354
|
+
show: {
|
|
355
|
+
operation: ['createSchedule'],
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
description: 'Lembretes em minutos antes do agendamento (separados por vírgula)',
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
displayName: 'Duração do Intervalo (minutos)',
|
|
362
|
+
name: 'intervalDuration',
|
|
363
|
+
type: 'number',
|
|
364
|
+
default: 30,
|
|
365
|
+
displayOptions: {
|
|
366
|
+
show: {
|
|
367
|
+
operation: ['createSchedule'],
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
description: 'Duração do intervalo em minutos',
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
displayName: 'Fechar Ticket',
|
|
374
|
+
name: 'closeTicket',
|
|
375
|
+
type: 'boolean',
|
|
376
|
+
default: false,
|
|
377
|
+
displayOptions: {
|
|
378
|
+
show: {
|
|
379
|
+
operation: ['createSchedule'],
|
|
380
|
+
},
|
|
381
|
+
},
|
|
382
|
+
description: 'Se deve fechar o ticket após criar agendamento',
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
displayName: 'ID do Agendamento',
|
|
386
|
+
name: 'scheduleId',
|
|
387
|
+
type: 'number',
|
|
388
|
+
default: 0,
|
|
389
|
+
displayOptions: {
|
|
390
|
+
show: {
|
|
391
|
+
operation: ['cancelSchedule'],
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
|
+
description: 'ID do agendamento a ser cancelado',
|
|
395
|
+
},
|
|
217
396
|
],
|
|
218
397
|
};
|
|
219
398
|
}
|
|
@@ -474,6 +653,87 @@ class Digitalsac {
|
|
|
474
653
|
json: true,
|
|
475
654
|
};
|
|
476
655
|
break;
|
|
656
|
+
// Casos para Agendamento
|
|
657
|
+
case 'listServices':
|
|
658
|
+
const scheduleUserId = this.getNodeParameter('scheduleUserId', i);
|
|
659
|
+
if (scheduleUserId > 0) {
|
|
660
|
+
url = `/typebot/listar_servicos?userId=${scheduleUserId}`;
|
|
661
|
+
}
|
|
662
|
+
else {
|
|
663
|
+
url = '/typebot/listar_servicos';
|
|
664
|
+
}
|
|
665
|
+
break;
|
|
666
|
+
case 'listAvailableUsers':
|
|
667
|
+
const serviceIdForUsers = this.getNodeParameter('serviceId', i);
|
|
668
|
+
const dateForUsers = this.getNodeParameter('scheduleDate', i);
|
|
669
|
+
const timeForUsers = this.getNodeParameter('scheduleTime', i);
|
|
670
|
+
url = `/typebot/listar_usuarios_disponiveis?serviceId=${serviceIdForUsers}&date=${dateForUsers}`;
|
|
671
|
+
if (timeForUsers) {
|
|
672
|
+
url += `&time=${timeForUsers}`;
|
|
673
|
+
}
|
|
674
|
+
break;
|
|
675
|
+
case 'listAvailableSlots':
|
|
676
|
+
const serviceIdForSlots = this.getNodeParameter('serviceId', i);
|
|
677
|
+
const userIdForSlots = this.getNodeParameter('scheduleAttendantId', i);
|
|
678
|
+
const dateForSlots = this.getNodeParameter('scheduleDate', i);
|
|
679
|
+
url = `/typebot/listar_horarios_disponiveis?serviceId=${serviceIdForSlots}&userId=${userIdForSlots}&date=${dateForSlots}`;
|
|
680
|
+
break;
|
|
681
|
+
case 'createSchedule':
|
|
682
|
+
url = '/typebot/criar_agendamento';
|
|
683
|
+
method = 'POST';
|
|
684
|
+
const serviceIdForCreate = this.getNodeParameter('serviceId', i);
|
|
685
|
+
const userIdForCreate = this.getNodeParameter('scheduleAttendantId', i);
|
|
686
|
+
const dateForCreate = this.getNodeParameter('scheduleDate', i);
|
|
687
|
+
const timeForCreate = this.getNodeParameter('scheduleTime', i);
|
|
688
|
+
const contactNameForCreate = this.getNodeParameter('contactName', i);
|
|
689
|
+
const contactPhoneForCreate = this.getNodeParameter('contactPhone', i);
|
|
690
|
+
const notesForCreate = this.getNodeParameter('scheduleNotes', i);
|
|
691
|
+
const whatsappIdForCreate = this.getNodeParameter('whatsappId', i);
|
|
692
|
+
const customMessageForCreate = this.getNodeParameter('customMessage', i);
|
|
693
|
+
const remindersForCreate = this.getNodeParameter('reminders', i);
|
|
694
|
+
const intervalDurationForCreate = this.getNodeParameter('intervalDuration', i);
|
|
695
|
+
const closeTicketForCreate = this.getNodeParameter('closeTicket', i);
|
|
696
|
+
// Converter string de lembretes para array
|
|
697
|
+
const remindersArray = remindersForCreate ? remindersForCreate.split(',').map(r => parseInt(r.trim())) : [60, 240];
|
|
698
|
+
body = {
|
|
699
|
+
serviceId: serviceIdForCreate,
|
|
700
|
+
userId: userIdForCreate,
|
|
701
|
+
date: dateForCreate,
|
|
702
|
+
time: timeForCreate,
|
|
703
|
+
contactName: contactNameForCreate,
|
|
704
|
+
contactPhone: contactPhoneForCreate,
|
|
705
|
+
notes: notesForCreate,
|
|
706
|
+
whatsappId: whatsappIdForCreate > 0 ? whatsappIdForCreate : undefined,
|
|
707
|
+
message: customMessageForCreate || undefined,
|
|
708
|
+
reminders: remindersArray,
|
|
709
|
+
intervalDuration: intervalDurationForCreate,
|
|
710
|
+
closeTicket: closeTicketForCreate
|
|
711
|
+
};
|
|
712
|
+
headers['Content-Type'] = 'application/json';
|
|
713
|
+
options = {
|
|
714
|
+
method,
|
|
715
|
+
headers,
|
|
716
|
+
body,
|
|
717
|
+
uri: `${baseUrl}${url}`,
|
|
718
|
+
json: true,
|
|
719
|
+
};
|
|
720
|
+
break;
|
|
721
|
+
case 'cancelSchedule':
|
|
722
|
+
url = '/typebot/cancelar_agendamento';
|
|
723
|
+
method = 'POST';
|
|
724
|
+
const scheduleIdForCancel = this.getNodeParameter('scheduleId', i);
|
|
725
|
+
body = {
|
|
726
|
+
scheduleId: scheduleIdForCancel
|
|
727
|
+
};
|
|
728
|
+
headers['Content-Type'] = 'application/json';
|
|
729
|
+
options = {
|
|
730
|
+
method,
|
|
731
|
+
headers,
|
|
732
|
+
body,
|
|
733
|
+
uri: `${baseUrl}${url}`,
|
|
734
|
+
json: true,
|
|
735
|
+
};
|
|
736
|
+
break;
|
|
477
737
|
}
|
|
478
738
|
// Se as opções não foram definidas no switch, defina-as aqui para operações GET
|
|
479
739
|
if (!options.method) {
|
|
@@ -50,6 +50,12 @@ export class Digitalsac implements INodeType {
|
|
|
50
50
|
{ name: 'Vincular Kanban', value: 'linkKanban' },
|
|
51
51
|
{ name: 'Listar Carteiras', value: 'listCarteiras' },
|
|
52
52
|
{ name: 'Vincular Carteira', value: 'linkCarteira' },
|
|
53
|
+
// Agendamento
|
|
54
|
+
{ name: 'Listar Serviços', value: 'listServices' },
|
|
55
|
+
{ name: 'Listar Usuários Disponíveis', value: 'listAvailableUsers' },
|
|
56
|
+
{ name: 'Listar Horários Disponíveis', value: 'listAvailableSlots' },
|
|
57
|
+
{ name: 'Criar Agendamento', value: 'createSchedule' },
|
|
58
|
+
{ name: 'Cancelar Agendamento', value: 'cancelSchedule' },
|
|
53
59
|
],
|
|
54
60
|
default: 'validateWhatsapp',
|
|
55
61
|
},
|
|
@@ -221,6 +227,179 @@ export class Digitalsac implements INodeType {
|
|
|
221
227
|
},
|
|
222
228
|
description: 'ID do ticket e ID do usuário da carteira',
|
|
223
229
|
},
|
|
230
|
+
// Campos para Agendamento
|
|
231
|
+
{
|
|
232
|
+
displayName: 'ID do Usuário',
|
|
233
|
+
name: 'scheduleUserId',
|
|
234
|
+
type: 'number',
|
|
235
|
+
default: 0,
|
|
236
|
+
displayOptions: {
|
|
237
|
+
show: {
|
|
238
|
+
operation: ['listServices'],
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
description: 'ID do usuário para filtrar serviços (opcional)',
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
displayName: 'ID do Serviço',
|
|
245
|
+
name: 'serviceId',
|
|
246
|
+
type: 'number',
|
|
247
|
+
default: 1,
|
|
248
|
+
displayOptions: {
|
|
249
|
+
show: {
|
|
250
|
+
operation: ['listAvailableUsers', 'listAvailableSlots', 'createSchedule'],
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
description: 'ID do serviço',
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
displayName: 'Data',
|
|
257
|
+
name: 'scheduleDate',
|
|
258
|
+
type: 'string',
|
|
259
|
+
default: '',
|
|
260
|
+
placeholder: '2025-08-07',
|
|
261
|
+
displayOptions: {
|
|
262
|
+
show: {
|
|
263
|
+
operation: ['listAvailableUsers', 'listAvailableSlots', 'createSchedule'],
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
description: 'Data no formato YYYY-MM-DD',
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
displayName: 'Horário',
|
|
270
|
+
name: 'scheduleTime',
|
|
271
|
+
type: 'string',
|
|
272
|
+
default: '',
|
|
273
|
+
placeholder: '09:00',
|
|
274
|
+
displayOptions: {
|
|
275
|
+
show: {
|
|
276
|
+
operation: ['listAvailableUsers', 'createSchedule'],
|
|
277
|
+
},
|
|
278
|
+
},
|
|
279
|
+
description: 'Horário no formato HH:mm (opcional para listar usuários)',
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
displayName: 'ID do Usuário',
|
|
283
|
+
name: 'scheduleAttendantId',
|
|
284
|
+
type: 'number',
|
|
285
|
+
default: 1,
|
|
286
|
+
displayOptions: {
|
|
287
|
+
show: {
|
|
288
|
+
operation: ['listAvailableSlots', 'createSchedule'],
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
description: 'ID do atendente/usuário',
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
displayName: 'Nome do Contato',
|
|
295
|
+
name: 'contactName',
|
|
296
|
+
type: 'string',
|
|
297
|
+
default: '',
|
|
298
|
+
displayOptions: {
|
|
299
|
+
show: {
|
|
300
|
+
operation: ['createSchedule'],
|
|
301
|
+
},
|
|
302
|
+
},
|
|
303
|
+
description: 'Nome do cliente/contato',
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
displayName: 'Telefone do Contato',
|
|
307
|
+
name: 'contactPhone',
|
|
308
|
+
type: 'string',
|
|
309
|
+
default: '',
|
|
310
|
+
placeholder: '5511999999999',
|
|
311
|
+
displayOptions: {
|
|
312
|
+
show: {
|
|
313
|
+
operation: ['createSchedule'],
|
|
314
|
+
},
|
|
315
|
+
},
|
|
316
|
+
description: 'Telefone do cliente/contato',
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
displayName: 'Observações',
|
|
320
|
+
name: 'scheduleNotes',
|
|
321
|
+
type: 'string',
|
|
322
|
+
default: '',
|
|
323
|
+
displayOptions: {
|
|
324
|
+
show: {
|
|
325
|
+
operation: ['createSchedule'],
|
|
326
|
+
},
|
|
327
|
+
},
|
|
328
|
+
description: 'Observações sobre o agendamento (opcional)',
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
displayName: 'ID da Conexão WhatsApp',
|
|
332
|
+
name: 'whatsappId',
|
|
333
|
+
type: 'number',
|
|
334
|
+
default: 0,
|
|
335
|
+
displayOptions: {
|
|
336
|
+
show: {
|
|
337
|
+
operation: ['createSchedule'],
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
description: 'ID da conexão WhatsApp (opcional - usa primeira disponível se não informado)',
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
displayName: 'Mensagem Personalizada',
|
|
344
|
+
name: 'customMessage',
|
|
345
|
+
type: 'string',
|
|
346
|
+
default: '',
|
|
347
|
+
displayOptions: {
|
|
348
|
+
show: {
|
|
349
|
+
operation: ['createSchedule'],
|
|
350
|
+
},
|
|
351
|
+
},
|
|
352
|
+
description: 'Mensagem personalizada do agendamento (opcional)',
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
displayName: 'Lembretes (minutos)',
|
|
356
|
+
name: 'reminders',
|
|
357
|
+
type: 'string',
|
|
358
|
+
default: '60,240',
|
|
359
|
+
placeholder: '60,240,1440',
|
|
360
|
+
displayOptions: {
|
|
361
|
+
show: {
|
|
362
|
+
operation: ['createSchedule'],
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
description: 'Lembretes em minutos antes do agendamento (separados por vírgula)',
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
displayName: 'Duração do Intervalo (minutos)',
|
|
369
|
+
name: 'intervalDuration',
|
|
370
|
+
type: 'number',
|
|
371
|
+
default: 30,
|
|
372
|
+
displayOptions: {
|
|
373
|
+
show: {
|
|
374
|
+
operation: ['createSchedule'],
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
description: 'Duração do intervalo em minutos',
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
displayName: 'Fechar Ticket',
|
|
381
|
+
name: 'closeTicket',
|
|
382
|
+
type: 'boolean',
|
|
383
|
+
default: false,
|
|
384
|
+
displayOptions: {
|
|
385
|
+
show: {
|
|
386
|
+
operation: ['createSchedule'],
|
|
387
|
+
},
|
|
388
|
+
},
|
|
389
|
+
description: 'Se deve fechar o ticket após criar agendamento',
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
displayName: 'ID do Agendamento',
|
|
393
|
+
name: 'scheduleId',
|
|
394
|
+
type: 'number',
|
|
395
|
+
default: 0,
|
|
396
|
+
displayOptions: {
|
|
397
|
+
show: {
|
|
398
|
+
operation: ['cancelSchedule'],
|
|
399
|
+
},
|
|
400
|
+
},
|
|
401
|
+
description: 'ID do agendamento a ser cancelado',
|
|
402
|
+
},
|
|
224
403
|
],
|
|
225
404
|
};
|
|
226
405
|
|
|
@@ -489,6 +668,100 @@ export class Digitalsac implements INodeType {
|
|
|
489
668
|
json: true,
|
|
490
669
|
};
|
|
491
670
|
break;
|
|
671
|
+
|
|
672
|
+
// Casos para Agendamento
|
|
673
|
+
case 'listServices':
|
|
674
|
+
const scheduleUserId = this.getNodeParameter('scheduleUserId', i) as number;
|
|
675
|
+
if (scheduleUserId > 0) {
|
|
676
|
+
url = `/typebot/listar_servicos?userId=${scheduleUserId}`;
|
|
677
|
+
} else {
|
|
678
|
+
url = '/typebot/listar_servicos';
|
|
679
|
+
}
|
|
680
|
+
break;
|
|
681
|
+
|
|
682
|
+
case 'listAvailableUsers':
|
|
683
|
+
const serviceIdForUsers = this.getNodeParameter('serviceId', i) as number;
|
|
684
|
+
const dateForUsers = this.getNodeParameter('scheduleDate', i) as string;
|
|
685
|
+
const timeForUsers = this.getNodeParameter('scheduleTime', i) as string;
|
|
686
|
+
|
|
687
|
+
url = `/typebot/listar_usuarios_disponiveis?serviceId=${serviceIdForUsers}&date=${dateForUsers}`;
|
|
688
|
+
if (timeForUsers) {
|
|
689
|
+
url += `&time=${timeForUsers}`;
|
|
690
|
+
}
|
|
691
|
+
break;
|
|
692
|
+
|
|
693
|
+
case 'listAvailableSlots':
|
|
694
|
+
const serviceIdForSlots = this.getNodeParameter('serviceId', i) as number;
|
|
695
|
+
const userIdForSlots = this.getNodeParameter('scheduleAttendantId', i) as number;
|
|
696
|
+
const dateForSlots = this.getNodeParameter('scheduleDate', i) as string;
|
|
697
|
+
|
|
698
|
+
url = `/typebot/listar_horarios_disponiveis?serviceId=${serviceIdForSlots}&userId=${userIdForSlots}&date=${dateForSlots}`;
|
|
699
|
+
break;
|
|
700
|
+
|
|
701
|
+
case 'createSchedule':
|
|
702
|
+
url = '/typebot/criar_agendamento';
|
|
703
|
+
method = 'POST';
|
|
704
|
+
|
|
705
|
+
const serviceIdForCreate = this.getNodeParameter('serviceId', i) as number;
|
|
706
|
+
const userIdForCreate = this.getNodeParameter('scheduleAttendantId', i) as number;
|
|
707
|
+
const dateForCreate = this.getNodeParameter('scheduleDate', i) as string;
|
|
708
|
+
const timeForCreate = this.getNodeParameter('scheduleTime', i) as string;
|
|
709
|
+
const contactNameForCreate = this.getNodeParameter('contactName', i) as string;
|
|
710
|
+
const contactPhoneForCreate = this.getNodeParameter('contactPhone', i) as string;
|
|
711
|
+
const notesForCreate = this.getNodeParameter('scheduleNotes', i) as string;
|
|
712
|
+
const whatsappIdForCreate = this.getNodeParameter('whatsappId', i) as number;
|
|
713
|
+
const customMessageForCreate = this.getNodeParameter('customMessage', i) as string;
|
|
714
|
+
const remindersForCreate = this.getNodeParameter('reminders', i) as string;
|
|
715
|
+
const intervalDurationForCreate = this.getNodeParameter('intervalDuration', i) as number;
|
|
716
|
+
const closeTicketForCreate = this.getNodeParameter('closeTicket', i) as boolean;
|
|
717
|
+
|
|
718
|
+
// Converter string de lembretes para array
|
|
719
|
+
const remindersArray = remindersForCreate ? remindersForCreate.split(',').map(r => parseInt(r.trim())) : [60, 240];
|
|
720
|
+
|
|
721
|
+
body = {
|
|
722
|
+
serviceId: serviceIdForCreate,
|
|
723
|
+
userId: userIdForCreate,
|
|
724
|
+
date: dateForCreate,
|
|
725
|
+
time: timeForCreate,
|
|
726
|
+
contactName: contactNameForCreate,
|
|
727
|
+
contactPhone: contactPhoneForCreate,
|
|
728
|
+
notes: notesForCreate,
|
|
729
|
+
whatsappId: whatsappIdForCreate > 0 ? whatsappIdForCreate : undefined,
|
|
730
|
+
message: customMessageForCreate || undefined,
|
|
731
|
+
reminders: remindersArray,
|
|
732
|
+
intervalDuration: intervalDurationForCreate,
|
|
733
|
+
closeTicket: closeTicketForCreate
|
|
734
|
+
};
|
|
735
|
+
|
|
736
|
+
headers['Content-Type'] = 'application/json';
|
|
737
|
+
options = {
|
|
738
|
+
method,
|
|
739
|
+
headers,
|
|
740
|
+
body,
|
|
741
|
+
uri: `${baseUrl}${url}`,
|
|
742
|
+
json: true,
|
|
743
|
+
};
|
|
744
|
+
break;
|
|
745
|
+
|
|
746
|
+
case 'cancelSchedule':
|
|
747
|
+
url = '/typebot/cancelar_agendamento';
|
|
748
|
+
method = 'POST';
|
|
749
|
+
|
|
750
|
+
const scheduleIdForCancel = this.getNodeParameter('scheduleId', i) as number;
|
|
751
|
+
|
|
752
|
+
body = {
|
|
753
|
+
scheduleId: scheduleIdForCancel
|
|
754
|
+
};
|
|
755
|
+
|
|
756
|
+
headers['Content-Type'] = 'application/json';
|
|
757
|
+
options = {
|
|
758
|
+
method,
|
|
759
|
+
headers,
|
|
760
|
+
body,
|
|
761
|
+
uri: `${baseUrl}${url}`,
|
|
762
|
+
json: true,
|
|
763
|
+
};
|
|
764
|
+
break;
|
|
492
765
|
}
|
|
493
766
|
|
|
494
767
|
// Se as opções não foram definidas no switch, defina-as aqui para operações GET
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-digitalsac",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Izing Pro Digitalsac",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"n8n-core": "^1.0.0",
|
|
50
50
|
"n8n-workflow": "^1.0.0",
|
|
51
51
|
"prettier": "^2.8.8",
|
|
52
|
-
"typescript": "^5.
|
|
52
|
+
"typescript": "^5.9.2"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"axios": "^1.9.0"
|