diff --git a/.wwebjs_cache/2.3000.1017050905.html b/.wwebjs_cache/2.3000.1017050905.html
index 49778259..f36b4faa 100644
--- a/.wwebjs_cache/2.3000.1017050905.html
+++ b/.wwebjs_cache/2.3000.1017050905.html
@@ -1,16 +1,16 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
@@ -18,35 +18,35 @@
WhatsApp Web
-WhatsApp
Protegida com a criptografia de ponta a ponta
-
+WhatsApp
Protegida com a criptografia de ponta a ponta
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
+
diff --git a/.wwebjs_cache/2.3000.1017054665.html b/.wwebjs_cache/2.3000.1017054665.html
new file mode 100644
index 00000000..6b086812
--- /dev/null
+++ b/.wwebjs_cache/2.3000.1017054665.html
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+WhatsApp Web
+
+WhatsApp
Protegida com a criptografia de ponta a ponta
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/packages/core.gbapp/services/GBMinService.ts b/packages/core.gbapp/services/GBMinService.ts
index 67d3799b..26633131 100644
--- a/packages/core.gbapp/services/GBMinService.ts
+++ b/packages/core.gbapp/services/GBMinService.ts
@@ -1110,16 +1110,15 @@ export class GBMinService {
}
}
}
- GBMinService.pidsConversation[conversationId] = pid;
+ GBMinService.pidsConversation[conversationId] = pid;
step.context.activity['pid'] = pid;
const notes = min.core.getParam(min.instance, 'Notes', null);
- if (await this.handleUploads(min, step, user, params, notes != null))
- {
+ if (await this.handleUploads(min, step, user, params, notes != null)) {
return;
}
-
+
// Required for MSTEAMS handling of persisted conversations.
if (step.context.activity.channelId === 'msteams') {
@@ -1334,16 +1333,16 @@ export class GBMinService {
const base64Data = url.split(';base64,')[1];
buffer = Buffer.from(base64Data, 'base64');
} else {
- const options = {
- method: 'GET',
- encoding: 'binary'
- };
- const res = await fetch(url, options);
+ const options = {
+ method: 'GET',
+ encoding: 'binary'
+ };
+ const res = await fetch(url, options);
buffer = arrayBufferToBuffer(await res.arrayBuffer());
}
await fs.writeFile(localFileName, buffer);
-
+
return {
name: attachment.name,
filename: localFileName,
@@ -1363,19 +1362,18 @@ export class GBMinService {
private async handleUploads(min, step, user, params, autoSave) {
// Prepare Promises to download each attachment and then execute each Promise.
- let ret = false;
if (
step.context.activity.attachments &&
step.context.activity.attachments[0] &&
step.context.activity.attachments[0].contentType != 'text/html'
) {
const promises = step.context.activity.attachments.map(
- GBMinService.downloadAttachmentAndWrite.bind({ min, user, params })
+ GBMinService.downloadAttachmentAndWrite.bind({ min, user, params })
);
const successfulSaves = await Promise.all(promises);
async function replyForReceivedAttachments(attachmentData) {
if (attachmentData) {
-
+
// In case of not having HEAR activated before, it is
// a upload with no Dialog, so run Auto Save to .gbdrive.
@@ -1412,7 +1410,6 @@ export class GBMinService {
const replyPromises = successfulSaves.map(replyForReceivedAttachments.bind(step.context));
await Promise.all(replyPromises);
if (successfulSaves.length > 0) {
- ret = true;
class GBFile {
data: Buffer;
filename: string;
@@ -1436,13 +1433,11 @@ export class GBMinService {
throw new Error('It is only possible to upload one file per message, right now.');
}
min.cbMap[user.userId].promise = results[0];
- return;
- } else {
- return;
}
}
+ return successfulSaves.length > 0;
}
- return ret;
+ return false;
}
/**
diff --git a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts
index 0f1e2ce4..bdbb53d0 100644
--- a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts
+++ b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts
@@ -693,7 +693,7 @@ export class WhatsappDirectLine extends GBService {
break;
case 'image/png':
- await this.sendFileToDevice(to, attachment.contentUrl, attachment.name, attachment.name, 0, 0);
+ await this.sendFileToDevice(to, attachment.contentUrl, attachment.name, attachment.name, 0, false);
return;
@@ -710,7 +710,7 @@ export class WhatsappDirectLine extends GBService {
return `${attachment.content.title} - ${attachment.content.text}`;
}
- public async sendFileToDevice(to, url, filename, caption, chatId, viewOnce) {
+ public async sendFileToDevice(to, url, filename, caption, chatId, isViewOnce = false) {
let options;
switch (this.provider) {
case 'meta':
@@ -724,7 +724,7 @@ export class WhatsappDirectLine extends GBService {
whatsappServiceNumber = GBServer.globals.minBoot.instance.whatsappServiceNumber;
whatsappServiceKey = GBServer.globals.minBoot.instance.whatsappServiceKey;
}
- if (viewOnce) {
+ if (isViewOnce) {
await this.sendImageViewOnce(to, url, caption);
}
else {
@@ -744,7 +744,7 @@ export class WhatsappDirectLine extends GBService {
}
}
- await this.customClient.sendMessage(to, attachment, { caption: caption , viewOnce});
+ await this.customClient.sendMessage(to, attachment, { caption: caption, isViewOnce });
break;
}
@@ -923,7 +923,7 @@ export class WhatsappDirectLine extends GBService {
}
- public async sendToDevice(to: any, msg: string, conversationId, viewOnce= false) {
+ public async sendToDevice(to: any, msg: string, conversationId, isViewOnce = false) {
try {
const cmd = '/audio ';
let url;
@@ -947,7 +947,7 @@ export class WhatsappDirectLine extends GBService {
await CollectionUtil.asyncForEach(messages, async msg => {
await this.sendTextMessage(to, msg);
-
+
if (messages.length > 1) {
await GBUtil.sleep(3000);
}
@@ -984,7 +984,7 @@ export class WhatsappDirectLine extends GBService {
}
}
if ((await this.customClient.getState()) === WAState.CONNECTED) {
- await this.customClient.sendMessage(to, msg, { isViewOnce: isViewOnce });
+ await this.customClient.sendMessage(to, msg, { isViewOnce });
} else {
GBLogEx.info(this.min, `WhatsApp OFFLINE ${to}: ${msg}`);
}
@@ -1397,10 +1397,10 @@ export class WhatsappDirectLine extends GBService {
// Define the API base URL and endpoints
const baseUrl = 'https://graph.facebook.com/v20.0'; // API version 20.0
-
+
const accessToken = this.whatsappServiceKey;
const sendMessageEndpoint = `${baseUrl}/${this.whatsappServiceNumber}/messages`;
-
+
const messageData = {
messaging_product: 'whatsapp',
to: mobile,
@@ -1409,7 +1409,7 @@ export class WhatsappDirectLine extends GBService {
body: message,
}
};
-
+
const response = await fetch(sendMessageEndpoint, {
method: 'POST',
headers: {
@@ -1418,15 +1418,15 @@ export class WhatsappDirectLine extends GBService {
},
body: JSON.stringify(messageData)
});
-
+
if (!response.ok) {
const errorData = await response.json();
throw new Error(`Failed to send message: ${JSON.stringify(errorData)}`);
}
-
+
const result = await response.json();
GBLogEx.info(0, 'Message sent successfully:' + result);
return result;
}
-
+
}
diff --git a/templates/ai-search.gbai/ai-search.gbdialog/qr.bas b/templates/ai-search.gbai/ai-search.gbdialog/qr.bas
index b3770af1..61a945d9 100644
--- a/templates/ai-search.gbai/ai-search.gbdialog/qr.bas
+++ b/templates/ai-search.gbai/ai-search.gbdialog/qr.bas
@@ -1,7 +1,11 @@
TALK "Please, take a photo of the QR Code and send to me."
HEAR doc as QRCODE
-TALK "Reading document " + doc + "..."
-text = GET doc
+text = null
+
+IF doc THEN
+ TALK "Reading document " + doc + "..."
+ text = GET doc
+END IF
IF text THEN
@@ -9,7 +13,7 @@ IF text THEN
SET CONTEXT text
SET ANSWER MODE "document"
TALK "Document ${doc} loaded. You can ask me anything about it."
- TALK "I will also send it to you..."
+ TALK "Please, wait while I convert pages to images..."
SEND FILE doc
ELSE