new(whatsapp.gblib): New WhatsApp provider: Meta.
This commit is contained in:
parent
645af9acd4
commit
6518c9ca12
1 changed files with 23 additions and 20 deletions
|
@ -654,23 +654,23 @@ export class GBConversationalService {
|
||||||
|| text.toLowerCase().endsWith('.png');
|
|| text.toLowerCase().endsWith('.png');
|
||||||
|
|
||||||
let image = isMedia ?
|
let image = isMedia ?
|
||||||
/(.*)\n/gmi.exec(text)[0].trim():
|
/(.*)\n/gmi.exec(text)[0].trim() :
|
||||||
text;
|
text;
|
||||||
|
|
||||||
const gbaiName = DialogKeywords.getGBAIPath(min.botId);
|
const gbaiName = DialogKeywords.getGBAIPath(min.botId);
|
||||||
const fileUrl = urlJoin(process.env.BOT_URL,'kb', gbaiName, `${min.botId}.gbkb`, 'images', image);
|
const fileUrl = urlJoin(process.env.BOT_URL, 'kb', gbaiName, `${min.botId}.gbkb`, 'images', image);
|
||||||
|
|
||||||
let urlImage = image.startsWith('http')
|
let urlImage = image.startsWith('http')
|
||||||
? image
|
? image
|
||||||
: fileUrl;
|
: fileUrl;
|
||||||
|
|
||||||
if (!isMedia){
|
if (!isMedia) {
|
||||||
text = text.substring(image.length).trim();
|
text = text.substring(image.length).trim();
|
||||||
text = text.replace(/\n/g, "\\n");
|
text = text.replace(/\n/g, "\\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
let data = {
|
let data:any = {
|
||||||
name: isMedia?'broadcast_notext':'broadcast', components: [
|
name: isMedia ? 'broadcast_notext' : 'broadcast', components: [
|
||||||
{
|
{
|
||||||
type: "header",
|
type: "header",
|
||||||
parameters: [
|
parameters: [
|
||||||
|
@ -678,11 +678,15 @@ export class GBConversationalService {
|
||||||
type: "image",
|
type: "image",
|
||||||
image: {
|
image: {
|
||||||
link: urlImage,
|
link: urlImage,
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
}
|
||||||
{
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!isMedia) {
|
||||||
|
data.components.push({
|
||||||
type: "body",
|
type: "body",
|
||||||
parameters: [
|
parameters: [
|
||||||
{
|
{
|
||||||
|
@ -690,9 +694,8 @@ export class GBConversationalService {
|
||||||
text: text,
|
text: text,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
GBLogEx.info(min, `Sending answer file to mobile: ${mobile}. Header: ${urlImage}`);
|
GBLogEx.info(min, `Sending answer file to mobile: ${mobile}. Header: ${urlImage}`);
|
||||||
await this.sendToMobile(min, mobile, data, null);
|
await this.sendToMobile(min, mobile, data, null);
|
||||||
|
|
Loading…
Add table
Reference in a new issue