fix(whatsapp.gblib): Transfer bug fix.

This commit is contained in:
Rodrigo Rodriguez 2020-05-16 16:40:44 -03:00
parent 230a9e3cbc
commit ed15c856c5
3 changed files with 31 additions and 31 deletions

View file

@ -210,7 +210,7 @@ export class GBMinService {
const { min, adapter, conversationState } = await this.buildBotAdapter(instance, GBServer.globals.sysPackages);
GBServer.globals.minInstances.push(min);
await this.deployer.deployPackage(min, 'packages/default.gbdialog');
// TODO: await this.deployer.deployPackage(min, 'packages/default.gbdialog');
await this.deployer.deployPackage(min, 'packages/default.gbtheme');
// Install per bot deployed packages.

View file

@ -183,17 +183,11 @@ export class AskDialog extends IGBDialog {
private static async handleAnswer(service: KBService, min: GBMinInstance, step: any, answer: GuaribasAnswer) {
const dialogSufix = 'dialog:';
const urlSufix = 'url:';
const scriptSufix = 'script:';
if (answer.content.startsWith(dialogSufix)) {
let dialogName = answer.content.substring(dialogSufix.length);
return await step.replaceDialog(`/${dialogName}`, { isReturning: true });
} else if (answer.content.startsWith(scriptSufix)) {
let scriptName = answer.content.substring(scriptSufix.length);
return await GBMinService.callVM(scriptName, min, step);
if (answer.content.endsWith('.docx')) {
const mainName = answer.content.replace(/\s|\-/g, '').split('.')[0];
return await GBMinService.callVM(mainName, min, step);
} else {
await service.sendAnswer(min, AskDialog.getChannel(step), step, answer);

View file

@ -135,7 +135,7 @@ export class WhatsappDirectLine extends GBService {
GBLog.info(`GBWhatsapp: Checking server...`);
const options = {
url: urlJoin(this.whatsappServiceUrl, 'status') + `?token=${this.min.instance.whatsappServiceKey}` ,
url: urlJoin(this.whatsappServiceUrl, 'status') + `?token=${this.min.instance.whatsappServiceKey}`,
method: 'GET',
};
@ -195,6 +195,11 @@ export class WhatsappDirectLine extends GBService {
if (user.agentMode === "self") {
let manualUser = await sec.getUserFromAgentSystemId(id);
if (manualUser === null) {
await sec.updateCurrentAgent(id, this.min.instance.instanceId, null);
}
else {
const cmd = '/reply ';
if (text.startsWith(cmd)) {
let filename = text.substr(cmd.length);
@ -214,7 +219,8 @@ export class WhatsappDirectLine extends GBService {
}
else {
GBLog.info(`HUMAN AGENT (${id}) TO USER ${manualUser.userSystemId}: ${text}`);
this.sendToDevice(manualUser.userSystemId, `${manualUser.userSystemId}: ${text}`);
this.sendToDevice(manualUser.userSystemId, `${manualUser.agentSystemId}: ${text}`);
}
}
}
else if (user.agentMode === "human") {
@ -222,7 +228,7 @@ export class WhatsappDirectLine extends GBService {
if (text === '/t') {
await this.sendToDevice(user.userSystemId, `Você já está sendo atendido por ${agent.userSystemId}.`);
}
else if (text === '/qt') {
else if (text === '/qt' || text === "Sair" || text === "Fechar" ) {
// TODO: Transfers only in pt-br for now.
await this.sendToDevice(id, Messages[this.locale].notify_end_transfer(this.min.instance.botId));
await this.sendToDevice(user.agentSystemId, Messages[this.locale].notify_end_transfer(this.min.instance.botId));
@ -230,7 +236,7 @@ export class WhatsappDirectLine extends GBService {
await sec.updateCurrentAgent(id, this.min.instance.instanceId, null);
}
else {
GBLog.info(`USER (${id}) TO AGENT ${agent.userSystemId}: ${text}`);
GBLog.info(`USER (${id}) TO AGENT ${user.userSystemId}: ${text}`);
this.sendToDevice(user.agentSystemId, `${id}: ${text}`);
}