fix(core.gbapp): Faster bot creation, fix on WhatsApp switcher.
This commit is contained in:
parent
cca148818e
commit
8c68332802
5 changed files with 65 additions and 70 deletions
|
@ -522,7 +522,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
||||||
msaAppId: appId,
|
msaAppId: appId,
|
||||||
msaAppPassword: appPassword,
|
msaAppPassword: appPassword,
|
||||||
enabledChannels: ['webchat', "skype"],//, "facebook"],
|
enabledChannels: ['webchat', "skype"],//, "facebook"],
|
||||||
configuredChannels: ['webchat' , "skype"]//, "facebook"]
|
configuredChannels: ['webchat', "skype"]//, "facebook"]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -539,7 +539,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(async () => {
|
|
||||||
try {
|
try {
|
||||||
//tslint:disable-next-line:max-line-length
|
//tslint:disable-next-line:max-line-length
|
||||||
query = `subscriptions/${subscriptionId}/resourceGroups/${group}/providers/Microsoft.BotService/botServices/${botId}/channels/WebChatChannel/listChannelWithKeys?api-version=${
|
query = `subscriptions/${subscriptionId}/resourceGroups/${group}/providers/Microsoft.BotService/botServices/${botId}/channels/WebChatChannel/listChannelWithKeys?api-version=${
|
||||||
|
@ -555,7 +555,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
reject(error);
|
reject(error);
|
||||||
}
|
}
|
||||||
}, 60000);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -459,7 +459,7 @@ export class GBConversationalService {
|
||||||
|
|
||||||
public async routeNLP(step: GBDialogStep, min: GBMinInstance, text: string): Promise<boolean> {
|
public async routeNLP(step: GBDialogStep, min: GBMinInstance, text: string): Promise<boolean> {
|
||||||
|
|
||||||
if (min.instance.nlpAppId === null) {
|
if (min.instance.nlpAppId === null || min.instance.nlpAppId === undefined) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -170,7 +170,6 @@ export class GBDeployer implements IGBDeployer {
|
||||||
instance.nlpScore = 0.80; // TODO: Migrate to Excel Config.xlsx.
|
instance.nlpScore = 0.80; // TODO: Migrate to Excel Config.xlsx.
|
||||||
instance.searchScore = 0.45;
|
instance.searchScore = 0.45;
|
||||||
instance.whatsappServiceKey = bootInstance.whatsappServiceKey;
|
instance.whatsappServiceKey = bootInstance.whatsappServiceKey;
|
||||||
instance.whatsappBotKey = bootInstance.whatsappBotKey;
|
|
||||||
instance.whatsappServiceNumber = bootInstance.whatsappServiceNumber;
|
instance.whatsappServiceNumber = bootInstance.whatsappServiceNumber;
|
||||||
instance.whatsappServiceUrl = bootInstance.whatsappServiceUrl;
|
instance.whatsappServiceUrl = bootInstance.whatsappServiceUrl;
|
||||||
|
|
||||||
|
@ -215,14 +214,12 @@ export class GBDeployer implements IGBDeployer {
|
||||||
instance.searchIndexer = bootInstance.searchIndexer;
|
instance.searchIndexer = bootInstance.searchIndexer;
|
||||||
instance.searchKey = bootInstance.searchKey;
|
instance.searchKey = bootInstance.searchKey;
|
||||||
instance.whatsappServiceKey = bootInstance.whatsappServiceKey;
|
instance.whatsappServiceKey = bootInstance.whatsappServiceKey;
|
||||||
instance.whatsappBotKey = bootInstance.whatsappBotKey;
|
|
||||||
instance.whatsappServiceNumber = bootInstance.whatsappServiceNumber;
|
instance.whatsappServiceNumber = bootInstance.whatsappServiceNumber;
|
||||||
instance.whatsappServiceUrl = bootInstance.whatsappServiceUrl;
|
instance.whatsappServiceUrl = bootInstance.whatsappServiceUrl;
|
||||||
instance.storageServer = bootInstance.storageServer;
|
instance.storageServer = bootInstance.storageServer;
|
||||||
instance.storageName = bootInstance.storageName;
|
instance.storageName = bootInstance.storageName;
|
||||||
instance.storageUsername = bootInstance.storageUsername;
|
instance.storageUsername = bootInstance.storageUsername;
|
||||||
instance.storagePassword = bootInstance.storagePassword;
|
instance.storagePassword = bootInstance.storagePassword;
|
||||||
instance.webchatKey = bootInstance.webchatKey;
|
|
||||||
instance.cloudLocation = bootInstance.cloudLocation;
|
instance.cloudLocation = bootInstance.cloudLocation;
|
||||||
instance.speechEndpoint = bootInstance.speechEndpoint;
|
instance.speechEndpoint = bootInstance.speechEndpoint;
|
||||||
instance.speechKey = bootInstance.speechKey;
|
instance.speechKey = bootInstance.speechKey;
|
||||||
|
|
|
@ -461,7 +461,7 @@ export class GBMinService {
|
||||||
min.adminService = this.adminService;
|
min.adminService = this.adminService;
|
||||||
min.deployService = this.deployer;
|
min.deployService = this.deployer;
|
||||||
min.kbService = new KBService(this.core.sequelize);
|
min.kbService = new KBService(this.core.sequelize);
|
||||||
min.instance = await this.core.loadInstanceByBotId(min.botId);
|
min.instance = instance;
|
||||||
min.cbMap = {};
|
min.cbMap = {};
|
||||||
min.scriptMap = {};
|
min.scriptMap = {};
|
||||||
min.sandBoxMap = {};
|
min.sandBoxMap = {};
|
||||||
|
@ -487,7 +487,7 @@ export class GBMinService {
|
||||||
new WhatsappDirectLine(
|
new WhatsappDirectLine(
|
||||||
min,
|
min,
|
||||||
min.botId,
|
min.botId,
|
||||||
min.instance.webchatKey,
|
min.instance.whatsappBotKey,
|
||||||
minBoot.instance.whatsappServiceKey,
|
minBoot.instance.whatsappServiceKey,
|
||||||
minBoot.instance.whatsappServiceNumber,
|
minBoot.instance.whatsappServiceNumber,
|
||||||
minBoot.instance.whatsappServiceUrl
|
minBoot.instance.whatsappServiceUrl
|
||||||
|
@ -690,22 +690,21 @@ export class GBMinService {
|
||||||
await step.beginDialog('/menu', JSON.parse(context.activity.text));
|
await step.beginDialog('/menu', JSON.parse(context.activity.text));
|
||||||
// Otherwise, continue to the active dialog in the stack.
|
// Otherwise, continue to the active dialog in the stack.
|
||||||
} else {
|
} else {
|
||||||
if (step.activeDialog !== undefined) {
|
|
||||||
await step.continueDialog();
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if (!await this.deployer.getStoragePackageByName(min.instance.instanceId, `${min.instance.botId}.gbkb`)) {
|
if (!await this.deployer.getStoragePackageByName(min.instance.instanceId, `${min.instance.botId}.gbkb`)) {
|
||||||
await step.context.sendActivity(`Oi, ainda não possuo pacotes de conhecimento publicados. Por favor, aguarde alguns segundos enquanto eu auto-publico alguns pacotes.`);
|
await step.context.sendActivity(`Oi, ainda não possuo pacotes de conhecimento publicados. Por favor, aguarde alguns segundos enquanto eu auto-publico alguns pacotes.`);
|
||||||
return await step.beginDialog('/publish', { confirm: true });
|
return await step.beginDialog('/publish', { confirm: true });
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
|
if (step.activeDialog !== undefined) {
|
||||||
|
await step.continueDialog();
|
||||||
|
} else {
|
||||||
|
|
||||||
let query = context.activity.text;
|
let query = context.activity.text;
|
||||||
|
|
||||||
const translatorEnabled = () => {
|
const translatorEnabled = () => {
|
||||||
if (min.instance.params) {
|
if (min.instance.params) {
|
||||||
const params = JSON.parse(min.instance.params);
|
const params = JSON.parse(min.instance.params);
|
||||||
return params?params['Enable Worldwide Translator'] === "TRUE": false;
|
return params ? params['Enable Worldwide Translator'] === "TRUE" : false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} // TODO: Encapsulate.
|
} // TODO: Encapsulate.
|
||||||
|
@ -740,7 +739,6 @@ export class GBMinService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static async callVM(text: string, min: GBMinInstance, step: GBDialogStep) {
|
public static async callVM(text: string, min: GBMinInstance, step: GBDialogStep) {
|
||||||
const mainMethod = text.toLowerCase();
|
const mainMethod = text.toLowerCase();
|
||||||
|
|
|
@ -58,7 +58,7 @@ export class WhatsappDirectLine extends GBService {
|
||||||
private directLineSecret: string;
|
private directLineSecret: string;
|
||||||
private locale: string = 'pt-BR';
|
private locale: string = 'pt-BR';
|
||||||
|
|
||||||
public conversationIds = {};
|
static conversationIds = {};
|
||||||
min: GBMinInstance;
|
min: GBMinInstance;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -130,7 +130,7 @@ export class WhatsappDirectLine extends GBService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async resetConversationId(number) {
|
public async resetConversationId(number) {
|
||||||
this.conversationIds[number] = undefined;
|
WhatsappDirectLine.conversationIds[number] = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async check() {
|
public async check() {
|
||||||
|
@ -200,7 +200,7 @@ export class WhatsappDirectLine extends GBService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const conversationId = this.conversationIds[from];
|
const conversationId = WhatsappDirectLine.conversationIds[from];
|
||||||
|
|
||||||
let client = await this.directLineClient;
|
let client = await this.directLineClient;
|
||||||
if (user.agentMode === "self") {
|
if (user.agentMode === "self") {
|
||||||
|
@ -254,12 +254,12 @@ export class WhatsappDirectLine extends GBService {
|
||||||
}
|
}
|
||||||
else if (user.agentMode === "bot" || user.agentMode === null) {
|
else if (user.agentMode === "bot" || user.agentMode === null) {
|
||||||
|
|
||||||
if (this.conversationIds[from] === undefined) {
|
if (WhatsappDirectLine.conversationIds[from] === undefined) {
|
||||||
GBLog.info(`GBWhatsapp: Starting new conversation on Bot.`);
|
GBLog.info(`GBWhatsapp: Starting new conversation on Bot.`);
|
||||||
const response = await client.Conversations.Conversations_StartConversation()
|
const response = await client.Conversations.Conversations_StartConversation();
|
||||||
const generatedConversationId = response.obj.conversationId;
|
const generatedConversationId = response.obj.conversationId;
|
||||||
|
|
||||||
this.conversationIds[from] = generatedConversationId;
|
WhatsappDirectLine.conversationIds[from] = generatedConversationId;
|
||||||
|
|
||||||
this.pollMessages(client, generatedConversationId, from, fromName);
|
this.pollMessages(client, generatedConversationId, from, fromName);
|
||||||
this.inputMessage(client, generatedConversationId, text, from, fromName);
|
this.inputMessage(client, generatedConversationId, text, from, fromName);
|
||||||
|
|
Loading…
Add table
Reference in a new issue