fix(whatsapp.gblib): Fix of missing mobile number.
This commit is contained in:
parent
1d316ef83b
commit
6306274db9
3 changed files with 25 additions and 18 deletions
|
@ -97,7 +97,8 @@ export class GBConversationalService {
|
|||
|
||||
if (step !== null) {
|
||||
if (!isNaN(step.context.activity.from.id as any)) {
|
||||
GBLog.info(`Sending file ${url} to ${step.context.activity.from.id}...`)
|
||||
mobile = step.context.activity.from.id;
|
||||
GBLog.info(`Sending file ${url} to ${mobile}...`)
|
||||
const filename = url.substring(url.lastIndexOf('/') + 1);
|
||||
await min.whatsAppDirectLine.sendFileToDevice(mobile, url, filename, caption);
|
||||
}
|
||||
|
@ -348,7 +349,7 @@ export class GBConversationalService {
|
|||
await step.context.sendActivity(currentText);
|
||||
}
|
||||
else {
|
||||
this.sendToMobile(min, mobile, currentText);
|
||||
await this.sendToMobile(min, mobile, currentText);
|
||||
}
|
||||
await sleep(3000);
|
||||
currentText = '';
|
||||
|
@ -371,7 +372,7 @@ export class GBConversationalService {
|
|||
await step.context.sendActivity(currentText);
|
||||
}
|
||||
else {
|
||||
this.sendToMobile(min, mobile, currentText);
|
||||
await this.sendToMobile(min, mobile, currentText);
|
||||
}
|
||||
await sleep(3000);
|
||||
}
|
||||
|
@ -404,9 +405,9 @@ export class GBConversationalService {
|
|||
await step.context.sendActivity(currentText);
|
||||
}
|
||||
else {
|
||||
this.sendToMobile(min, mobile, currentText);
|
||||
await this.sendToMobile(min, mobile, currentText);
|
||||
}
|
||||
await sleep(3000);
|
||||
await sleep(2900);
|
||||
}
|
||||
currentText = '';
|
||||
state = State.InImageCaption;
|
||||
|
@ -435,7 +436,7 @@ export class GBConversationalService {
|
|||
let url = urlJoin(GBServer.globals.publicAddress, currentImage);
|
||||
await this.sendFile(min, step, mobile, url, currentCaption);
|
||||
currentCaption = '';
|
||||
await sleep(5000);
|
||||
await sleep(4500);
|
||||
currentImage = '';
|
||||
}
|
||||
else {
|
||||
|
@ -451,7 +452,7 @@ export class GBConversationalService {
|
|||
|
||||
}
|
||||
else {
|
||||
this.sendToMobile(min, mobile, currentText);
|
||||
await this.sendToMobile(min, mobile, currentText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -590,7 +591,7 @@ export class GBConversationalService {
|
|||
const user = await sec.ensureUser(min.instance.instanceId, member.id,
|
||||
member.name, "", "web", member.name);
|
||||
if (text !== null) {
|
||||
text = await min.conversationalService.translate(min,
|
||||
text = await min.conversationalService.translate(min,
|
||||
min.instance.translatorKey ? min.instance.translatorKey : minBoot.instance.translatorKey,
|
||||
min.instance.translatorEndpoint ? min.instance.translatorEndpoint : minBoot.instance.translatorEndpoint,
|
||||
text,
|
||||
|
@ -606,7 +607,7 @@ export class GBConversationalService {
|
|||
const user = await min.userProfile.get(step.context, {});
|
||||
if (user) {
|
||||
const minBoot = GBServer.globals.minBoot as any;
|
||||
text = await min.conversationalService.translate(min,
|
||||
text = await min.conversationalService.translate(min,
|
||||
min.instance.translatorKey ? min.instance.translatorKey : minBoot.instance.translatorKey,
|
||||
min.instance.translatorEndpoint ? min.instance.translatorEndpoint : minBoot.instance.translatorEndpoint,
|
||||
text,
|
||||
|
|
|
@ -380,7 +380,7 @@ export class KBService implements IGBKBService {
|
|||
|
||||
public async sendAnswer(min: GBMinInstance, channel: string, step: GBDialogStep, answer: GuaribasAnswer) {
|
||||
if (answer.content.endsWith('.mp4')) {
|
||||
await this.playVideo(min, min.conversationalService, step, answer);
|
||||
await this.playVideo(min, min.conversationalService, step, answer, channel);
|
||||
}
|
||||
else if (answer.format === '.md') {
|
||||
|
||||
|
@ -433,14 +433,14 @@ export class KBService implements IGBKBService {
|
|||
// MSFT Translator breaks markdown, so we need to fix it:
|
||||
|
||||
text = text.replace('! [', '![').replace('] (', '](');
|
||||
text = text.replace(`[[embed url=`, process.env.BOT_URL + '/').replace(']]', ''); // TODO: Improve it.
|
||||
|
||||
const html = marked(text);
|
||||
let html = text.replace(`[[embed url=`, process.env.BOT_URL + '/').replace(']]', ''); // TODO: Improve it.
|
||||
|
||||
// According to the channel, formats the output optimized to it.
|
||||
|
||||
if (channel === 'webchat' &&
|
||||
GBConfigService.get('DISABLE_WEB') !== 'true') {
|
||||
html = marked(text);
|
||||
await this.sendMarkdownToWeb(min, step, conversationalService, html, answer);
|
||||
}
|
||||
else if (channel === 'whatsapp') {
|
||||
|
@ -448,6 +448,7 @@ export class KBService implements IGBKBService {
|
|||
await conversationalService.sendMarkdownToMobile(min, step, user.userSystemId, text);
|
||||
}
|
||||
else {
|
||||
html = marked(text);
|
||||
await min.conversationalService.sendText(min, step, html);
|
||||
}
|
||||
}
|
||||
|
@ -481,11 +482,16 @@ export class KBService implements IGBKBService {
|
|||
}
|
||||
|
||||
|
||||
private async playVideo(min, conversationalService: IGBConversationalService, step: GBDialogStep, answer: GuaribasAnswer) {
|
||||
await conversationalService.sendEvent(min, step, 'play', {
|
||||
playerType: 'video',
|
||||
data: answer.content
|
||||
});
|
||||
private async playVideo(min, conversationalService: IGBConversationalService,
|
||||
step: GBDialogStep, answer: GuaribasAnswer, channel: string) {
|
||||
if (channel === "whatsapp") {
|
||||
await min.conversationalService.sendFile(min, step, null, answer.content, "");
|
||||
} else {
|
||||
await conversationalService.sendEvent(min, step, 'play', {
|
||||
playerType: 'video',
|
||||
data: answer.content
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public async importKbPackage(
|
||||
|
|
|
@ -428,7 +428,7 @@ export class WhatsappDirectLine extends GBService {
|
|||
|
||||
}
|
||||
|
||||
public async sendToDevice(to, msg) {
|
||||
public async sendToDevice(to: string, msg: string) {
|
||||
|
||||
const cmd = '/audio ';
|
||||
if (msg.startsWith(cmd)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue