n8n-nodes-digitalsac 0.2.9 → 0.3.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 +18 -31
- package/dist/nodes/Digitalsac/Digitalsac.node.js +63 -14
- package/nodes/Digitalsac/Digitalsac.node.ts +69 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -110,30 +110,22 @@ Onde:
|
|
|
110
110
|
|
|
111
111
|
### Enviar Mensagem de Texto
|
|
112
112
|
1. Selecione a operação **Enviar Mensagem**
|
|
113
|
-
2. No campo **Parâmetro**, insira o UUID da conexão
|
|
114
|
-
3. No campo **
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
"body": "Sua mensagem aqui",
|
|
118
|
-
"number": "5511999999999",
|
|
119
|
-
"externalKey": "chave_opcional"
|
|
120
|
-
}
|
|
121
|
-
```
|
|
113
|
+
2. No campo **Parâmetro**, insira o UUID da conexão (ex: 999ab3a2-9f1f-4ffb-969a-bfb72234ece1)
|
|
114
|
+
3. No campo **Corpo da Mensagem**, insira o texto da mensagem
|
|
115
|
+
4. No campo **Número de Telefone**, insira o número no formato DDI+DDD+Número (ex: 5511999999999)
|
|
116
|
+
5. No campo **Chave Externa**, insira um identificador único opcional
|
|
122
117
|
|
|
123
118
|
### Enviar Arquivo
|
|
124
|
-
1. Conecte um nó que forneça dados binários (ex: HTTP Request
|
|
125
|
-
2.
|
|
126
|
-
3.
|
|
127
|
-
4. No campo **
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
```
|
|
136
|
-
Onde `data` é o nome da propriedade binária que contém o arquivo.
|
|
119
|
+
1. Conecte um nó que forneça dados binários (ex: **HTTP Request**, **Read Binary File**, **Google Drive**)
|
|
120
|
+
2. Conecte ao nó **Digitalsac**
|
|
121
|
+
3. Selecione a operação **Enviar Mensagem**
|
|
122
|
+
4. No campo **Parâmetro**, insira o UUID da conexão
|
|
123
|
+
5. Preencha os demais campos normalmente
|
|
124
|
+
6. O nó detectará automaticamente o arquivo binário e enviará via FormData
|
|
125
|
+
|
|
126
|
+
**Nota**: O nó detecta automaticamente se há dados binários conectados e escolhe o método correto:
|
|
127
|
+
- **Sem arquivo**: Envia como JSON (texto)
|
|
128
|
+
- **Com arquivo**: Envia como FormData (arquivo + texto)
|
|
137
129
|
|
|
138
130
|
### Listar Tags
|
|
139
131
|
1. Selecione a operação **Listar Tags**
|
|
@@ -263,15 +255,10 @@ Onde:
|
|
|
263
255
|
- Configure para ler um arquivo PDF
|
|
264
256
|
2. Conecte ao nó **Digitalsac**
|
|
265
257
|
- Operação: **Enviar Mensagem**
|
|
266
|
-
- Parâmetro: `
|
|
267
|
-
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
"body": "Segue o PDF solicitado",
|
|
271
|
-
"number": "5511999999999",
|
|
272
|
-
"binaryPropertyName": "data"
|
|
273
|
-
}
|
|
274
|
-
```
|
|
258
|
+
- Parâmetro: `999ab3a2-9f1f-4ffb-969a-bfb72234ece1` (seu UUID de conexão)
|
|
259
|
+
- Corpo da Mensagem: `Segue o PDF solicitado`
|
|
260
|
+
- Número de Telefone: `5511999999999`
|
|
261
|
+
- Chave Externa: `pdf_documento_123`
|
|
275
262
|
|
|
276
263
|
### Transferir ticket para uma fila específica
|
|
277
264
|
1. Adicione um nó **Digitalsac**
|
|
@@ -321,26 +321,75 @@ class Digitalsac {
|
|
|
321
321
|
};
|
|
322
322
|
break;
|
|
323
323
|
case 'sendMessage':
|
|
324
|
+
// Validar se o UUID foi fornecido
|
|
325
|
+
if (!param || param.trim() === '') {
|
|
326
|
+
throw new Error('UUID da conexão é obrigatório para enviar mensagem. Preencha o campo "Parâmetro" com o UUID da conexão.');
|
|
327
|
+
}
|
|
324
328
|
url = `/v1/api/external/${param}`;
|
|
325
329
|
method = 'POST';
|
|
326
330
|
// Usar campos separados em vez de JSON
|
|
327
331
|
const messageBody = this.getNodeParameter('messageBody', i);
|
|
328
332
|
const phoneNumber = this.getNodeParameter('phoneNumber', i);
|
|
329
333
|
const externalKey = this.getNodeParameter('externalKey', i);
|
|
330
|
-
//
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
334
|
+
// Verificar se há dados binários (para envio de arquivo)
|
|
335
|
+
let hasBinaryData = false;
|
|
336
|
+
let binaryData;
|
|
337
|
+
let binaryFileName;
|
|
338
|
+
let binaryContentType;
|
|
339
|
+
if (items[i].binary) {
|
|
340
|
+
const binary = items[i].binary;
|
|
341
|
+
// Procurar por qualquer propriedade binária disponível
|
|
342
|
+
const binaryKeys = Object.keys(binary);
|
|
343
|
+
if (binaryKeys.length > 0) {
|
|
344
|
+
const binaryPropertyName = binaryKeys[0]; // Usar a primeira propriedade binária encontrada
|
|
345
|
+
hasBinaryData = true;
|
|
346
|
+
const binaryProperty = binary[binaryPropertyName];
|
|
347
|
+
binaryData = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
|
348
|
+
binaryFileName = binaryProperty.fileName || 'file';
|
|
349
|
+
binaryContentType = binaryProperty.mimeType;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
if (hasBinaryData && binaryData) {
|
|
353
|
+
// Enviar como FormData (para arquivos)
|
|
354
|
+
const formData = {
|
|
355
|
+
body: messageBody,
|
|
356
|
+
number: phoneNumber,
|
|
357
|
+
externalKey: externalKey,
|
|
358
|
+
media: {
|
|
359
|
+
value: binaryData,
|
|
360
|
+
options: {
|
|
361
|
+
filename: binaryFileName,
|
|
362
|
+
contentType: binaryContentType,
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
};
|
|
366
|
+
options = {
|
|
367
|
+
method,
|
|
368
|
+
headers: {
|
|
369
|
+
Authorization: `Bearer ${token}`,
|
|
370
|
+
Accept: 'application/json',
|
|
371
|
+
},
|
|
372
|
+
formData: formData,
|
|
373
|
+
uri: `${baseUrl}${url}`,
|
|
374
|
+
json: true,
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
// Enviar como JSON (para texto)
|
|
379
|
+
body = {
|
|
380
|
+
body: messageBody,
|
|
381
|
+
number: phoneNumber,
|
|
382
|
+
externalKey: externalKey
|
|
383
|
+
};
|
|
384
|
+
headers['Content-Type'] = 'application/json';
|
|
385
|
+
options = {
|
|
386
|
+
method,
|
|
387
|
+
headers,
|
|
388
|
+
body,
|
|
389
|
+
uri: `${baseUrl}${url}`,
|
|
390
|
+
json: true,
|
|
391
|
+
};
|
|
392
|
+
}
|
|
344
393
|
break;
|
|
345
394
|
case 'listTags':
|
|
346
395
|
url = '/typebot/listar_tags';
|
|
@@ -4,6 +4,8 @@ import {
|
|
|
4
4
|
INodeType,
|
|
5
5
|
INodeTypeDescription,
|
|
6
6
|
NodeConnectionType,
|
|
7
|
+
IDataObject,
|
|
8
|
+
IBinaryKeyData,
|
|
7
9
|
} from 'n8n-workflow';
|
|
8
10
|
|
|
9
11
|
export class Digitalsac implements INodeType {
|
|
@@ -327,6 +329,11 @@ export class Digitalsac implements INodeType {
|
|
|
327
329
|
};
|
|
328
330
|
break;
|
|
329
331
|
case 'sendMessage':
|
|
332
|
+
// Validar se o UUID foi fornecido
|
|
333
|
+
if (!param || param.trim() === '') {
|
|
334
|
+
throw new Error('UUID da conexão é obrigatório para enviar mensagem. Preencha o campo "Parâmetro" com o UUID da conexão.');
|
|
335
|
+
}
|
|
336
|
+
|
|
330
337
|
url = `/v1/api/external/${param}`;
|
|
331
338
|
method = 'POST';
|
|
332
339
|
|
|
@@ -335,21 +342,69 @@ export class Digitalsac implements INodeType {
|
|
|
335
342
|
const phoneNumber = this.getNodeParameter('phoneNumber', i) as string;
|
|
336
343
|
const externalKey = this.getNodeParameter('externalKey', i) as string;
|
|
337
344
|
|
|
338
|
-
//
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
};
|
|
345
|
+
// Verificar se há dados binários (para envio de arquivo)
|
|
346
|
+
let hasBinaryData = false;
|
|
347
|
+
let binaryData: Buffer | undefined;
|
|
348
|
+
let binaryFileName: string | undefined;
|
|
349
|
+
let binaryContentType: string | undefined;
|
|
344
350
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
351
|
+
if (items[i].binary) {
|
|
352
|
+
const binary = items[i].binary as IBinaryKeyData;
|
|
353
|
+
// Procurar por qualquer propriedade binária disponível
|
|
354
|
+
const binaryKeys = Object.keys(binary);
|
|
355
|
+
if (binaryKeys.length > 0) {
|
|
356
|
+
const binaryPropertyName = binaryKeys[0]; // Usar a primeira propriedade binária encontrada
|
|
357
|
+
hasBinaryData = true;
|
|
358
|
+
|
|
359
|
+
const binaryProperty = binary[binaryPropertyName];
|
|
360
|
+
binaryData = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
|
361
|
+
binaryFileName = binaryProperty.fileName || 'file';
|
|
362
|
+
binaryContentType = binaryProperty.mimeType;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
if (hasBinaryData && binaryData) {
|
|
367
|
+
// Enviar como FormData (para arquivos)
|
|
368
|
+
const formData: IDataObject = {
|
|
369
|
+
body: messageBody,
|
|
370
|
+
number: phoneNumber,
|
|
371
|
+
externalKey: externalKey,
|
|
372
|
+
media: {
|
|
373
|
+
value: binaryData,
|
|
374
|
+
options: {
|
|
375
|
+
filename: binaryFileName,
|
|
376
|
+
contentType: binaryContentType,
|
|
377
|
+
},
|
|
378
|
+
},
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
options = {
|
|
382
|
+
method,
|
|
383
|
+
headers: {
|
|
384
|
+
Authorization: `Bearer ${token}`,
|
|
385
|
+
Accept: 'application/json',
|
|
386
|
+
},
|
|
387
|
+
formData: formData,
|
|
388
|
+
uri: `${baseUrl}${url}`,
|
|
389
|
+
json: true,
|
|
390
|
+
};
|
|
391
|
+
} else {
|
|
392
|
+
// Enviar como JSON (para texto)
|
|
393
|
+
body = {
|
|
394
|
+
body: messageBody,
|
|
395
|
+
number: phoneNumber,
|
|
396
|
+
externalKey: externalKey
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
headers['Content-Type'] = 'application/json';
|
|
400
|
+
options = {
|
|
401
|
+
method,
|
|
402
|
+
headers,
|
|
403
|
+
body,
|
|
404
|
+
uri: `${baseUrl}${url}`,
|
|
405
|
+
json: true,
|
|
406
|
+
};
|
|
407
|
+
}
|
|
353
408
|
break;
|
|
354
409
|
case 'listTags':
|
|
355
410
|
url = '/typebot/listar_tags';
|