Merge branch 'master' of https://github.com/GeneralBots/BotServer
# Conflicts: # packages/core.gbapp/services/GBMinService.ts
This commit is contained in:
commit
8cb0fdb8b2
2 changed files with 30 additions and 30 deletions
|
@ -217,17 +217,11 @@ export class AskDialog extends IGBDialog {
|
||||||
|
|
||||||
private static async handleAnswer(service: KBService, min: GBMinInstance, step: any, answer: GuaribasAnswer) {
|
private static async handleAnswer(service: KBService, min: GBMinInstance, step: any, answer: GuaribasAnswer) {
|
||||||
|
|
||||||
const dialogSufix = 'dialog:';
|
|
||||||
const urlSufix = 'url:';
|
const urlSufix = 'url:';
|
||||||
const scriptSufix = 'script:';
|
|
||||||
|
|
||||||
if (answer.content.startsWith(dialogSufix)) {
|
if (answer.content.endsWith('.docx')) {
|
||||||
let dialogName = answer.content.substring(dialogSufix.length);
|
const mainName = answer.content.replace(/\s|\-/g, '').split('.')[0];
|
||||||
return await step.replaceDialog(`/${dialogName}`, { isReturning: true });
|
return await GBMinService.callVM(mainName, min, step);
|
||||||
} else if (answer.content.startsWith(scriptSufix)) {
|
|
||||||
let scriptName = answer.content.substring(scriptSufix.length);
|
|
||||||
|
|
||||||
return await GBMinService.callVM(scriptName, min, step);
|
|
||||||
} else {
|
} else {
|
||||||
await service.sendAnswer(min, AskDialog.getChannel(step), step, answer);
|
await service.sendAnswer(min, AskDialog.getChannel(step), step, answer);
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ export class WhatsappDirectLine extends GBService {
|
||||||
GBLog.info(`GBWhatsapp: Checking server...`);
|
GBLog.info(`GBWhatsapp: Checking server...`);
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
url: urlJoin(this.whatsappServiceUrl, 'status') + `?token=${this.min.instance.whatsappServiceKey}` ,
|
url: urlJoin(this.whatsappServiceUrl, 'status') + `?token=${this.min.instance.whatsappServiceKey}`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -195,6 +195,11 @@ export class WhatsappDirectLine extends GBService {
|
||||||
|
|
||||||
if (user.agentMode === "self") {
|
if (user.agentMode === "self") {
|
||||||
let manualUser = await sec.getUserFromAgentSystemId(id);
|
let manualUser = await sec.getUserFromAgentSystemId(id);
|
||||||
|
|
||||||
|
if (manualUser === null) {
|
||||||
|
await sec.updateCurrentAgent(id, this.min.instance.instanceId, null);
|
||||||
|
}
|
||||||
|
else {
|
||||||
const cmd = '/reply ';
|
const cmd = '/reply ';
|
||||||
if (text.startsWith(cmd)) {
|
if (text.startsWith(cmd)) {
|
||||||
let filename = text.substr(cmd.length);
|
let filename = text.substr(cmd.length);
|
||||||
|
@ -214,7 +219,8 @@ export class WhatsappDirectLine extends GBService {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
GBLog.info(`HUMAN AGENT (${id}) TO USER ${manualUser.userSystemId}: ${text}`);
|
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") {
|
else if (user.agentMode === "human") {
|
||||||
|
@ -222,7 +228,7 @@ export class WhatsappDirectLine extends GBService {
|
||||||
if (text === '/t') {
|
if (text === '/t') {
|
||||||
await this.sendToDevice(user.userSystemId, `Você já está sendo atendido por ${agent.userSystemId}.`);
|
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.
|
// 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(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));
|
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);
|
await sec.updateCurrentAgent(id, this.min.instance.instanceId, null);
|
||||||
}
|
}
|
||||||
else {
|
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}`);
|
this.sendToDevice(user.agentSystemId, `${id}: ${text}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue