fix(core.gbapp): Several fixes and translator swicher.
This commit is contained in:
parent
5a99ef09aa
commit
cca148818e
6 changed files with 68 additions and 61 deletions
|
@ -538,7 +538,7 @@ export class GBConversationalService {
|
|||
const translatorEnabled = () => {
|
||||
if (min.instance.params) {
|
||||
const params = JSON.parse(min.instance.params);
|
||||
return params['Enable Worldwide Translator'] === "TRUE";
|
||||
return params ? params['Enable Worldwide Translator'] === "TRUE" : false;
|
||||
}
|
||||
return false;
|
||||
} // TODO: Encapsulate.
|
||||
|
|
|
@ -153,8 +153,9 @@ export class GBDeployer implements IGBDeployer {
|
|||
public async deployBlankBot(botId: string) {
|
||||
let instance = await this.importer.createBotInstance(botId);
|
||||
|
||||
const bootInstance = GBServer.globals.bootInstance;
|
||||
const accessToken = await GBServer.globals.minBoot.adminService
|
||||
.acquireElevatedToken(GBServer.globals.bootInstance.instanceId);
|
||||
.acquireElevatedToken(bootInstance.instanceId);
|
||||
|
||||
const service = new AzureDeployerService(this);
|
||||
let application = await service.createApplication(accessToken, botId);
|
||||
|
@ -168,6 +169,10 @@ export class GBDeployer implements IGBDeployer {
|
|||
instance.state = 'active';
|
||||
instance.nlpScore = 0.80; // TODO: Migrate to Excel Config.xlsx.
|
||||
instance.searchScore = 0.45;
|
||||
instance.whatsappServiceKey = bootInstance.whatsappServiceKey;
|
||||
instance.whatsappBotKey = bootInstance.whatsappBotKey;
|
||||
instance.whatsappServiceNumber = bootInstance.whatsappServiceNumber;
|
||||
instance.whatsappServiceUrl = bootInstance.whatsappServiceUrl;
|
||||
|
||||
await this.core.saveInstance(instance);
|
||||
|
||||
|
@ -281,8 +286,9 @@ export class GBDeployer implements IGBDeployer {
|
|||
let document = res.value.filter(m => {
|
||||
return m.name === "Config.xlsx"
|
||||
});
|
||||
if (document === undefined) {
|
||||
throw `Config.xlsx not found on .bot folder, check the package.`;
|
||||
if (document === undefined || document.length === 0) {
|
||||
GBLog.info(`Config.xlsx not found on .bot folder, check the package.`);
|
||||
return null;
|
||||
}
|
||||
|
||||
// Creates workbook session that will be discarded.
|
||||
|
|
|
@ -184,7 +184,7 @@ export class GBMinService {
|
|||
await (GBServer.globals.minBoot as any).whatsAppDirectLine.received(req, res);
|
||||
}
|
||||
} catch (error) {
|
||||
GBLog.error(`Error on Whatsapp callback: ${error}`);
|
||||
GBLog.error(`Error on Whatsapp callback: ${error.data ? error.data : error}`);
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -705,7 +705,7 @@ export class GBMinService {
|
|||
const translatorEnabled = () => {
|
||||
if (min.instance.params) {
|
||||
const params = JSON.parse(min.instance.params);
|
||||
return params['Enable Worldwide Translator'] === "TRUE";
|
||||
return params?params['Enable Worldwide Translator'] === "TRUE": false;
|
||||
}
|
||||
return false;
|
||||
} // TODO: Encapsulate.
|
||||
|
|
|
@ -37,9 +37,8 @@ import { GBLog, GBMinInstance, GBService, IGBCoreService } from 'botlib';
|
|||
import * as fs from 'fs';
|
||||
import { GBDeployer } from './GBDeployer';
|
||||
import { TSCompiler } from './TSCompiler';
|
||||
|
||||
import { CollectionUtil } from 'pragmatismo-io-framework';
|
||||
const walkPromise = require('walk-promise');
|
||||
|
||||
const vm = require('vm');
|
||||
import urlJoin = require('url-join');
|
||||
import { DialogClass } from './GBAPIService';
|
||||
|
@ -69,8 +68,11 @@ export class GBVMService extends GBService {
|
|||
const files = await walkPromise(folder);
|
||||
this.addHearDialog(min);
|
||||
|
||||
return Promise.all(
|
||||
files.map(async file => {
|
||||
await CollectionUtil.asyncForEach(files, async file => {
|
||||
if (!file) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let filename: string = file.name;
|
||||
|
||||
|
@ -124,8 +126,7 @@ export class GBVMService extends GBService {
|
|||
}
|
||||
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
private async getTextFromWord(folder: string, filename: string) {
|
||||
|
|
|
@ -103,7 +103,7 @@ export class AskDialog extends IGBDialog {
|
|||
const translatorEnabled = () => {
|
||||
if (min.instance.params) {
|
||||
const params = JSON.parse(min.instance.params);
|
||||
return params['Enable Worldwide Translator'] === "TRUE";
|
||||
return params?params['Enable Worldwide Translator'] === "TRUE": false;
|
||||
}
|
||||
return false;
|
||||
} // TODO: Encapsulate.
|
||||
|
|
|
@ -129,7 +129,7 @@ export class WhatsappDirectLine extends GBService {
|
|||
}
|
||||
}
|
||||
|
||||
public resetConversationId(number) {
|
||||
public async resetConversationId(number) {
|
||||
this.conversationIds[number] = undefined;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue