diff --git a/packages/azuredeployer.gbapp/services/AzureDeployerService.ts b/packages/azuredeployer.gbapp/services/AzureDeployerService.ts index 8332a7cb..9db77874 100644 --- a/packages/azuredeployer.gbapp/services/AzureDeployerService.ts +++ b/packages/azuredeployer.gbapp/services/AzureDeployerService.ts @@ -225,8 +225,7 @@ export class AzureDeployerService implements IGBInstallationDeployer { // CHECK if (!JSON.parse(res.bodyAsText).id) { return false; - } - else { + } else { return true; } } @@ -292,7 +291,6 @@ export class AzureDeployerService implements IGBInstallationDeployer { GBLog.info(`Bot proxy updated at: ${endpoint}.`); } - public async openStorageFirewall(groupName, serverName) { const username = GBConfigService.get('CLOUD_USERNAME'); const password = GBConfigService.get('CLOUD_PASSWORD'); diff --git a/packages/core.gbapp/services/GBCoreService.ts b/packages/core.gbapp/services/GBCoreService.ts index 8bd85fc9..aa8cd443 100644 --- a/packages/core.gbapp/services/GBCoreService.ts +++ b/packages/core.gbapp/services/GBCoreService.ts @@ -347,8 +347,8 @@ STORAGE_SYNC=true GBCorePackage, GBSecurityPackage, GBKBPackage, - GBCustomerSatisfactionPackage - // GBWhatsappPackage + GBCustomerSatisfactionPackage, + GBWhatsappPackage ].forEach(e => { GBLog.info(`Loading sys package: ${e.name}...`); const p = Object.create(e.prototype) as IGBPackage; diff --git a/packages/core.gbapp/services/GBDeployer.ts b/packages/core.gbapp/services/GBDeployer.ts index dd0470ba..b673cf92 100644 --- a/packages/core.gbapp/services/GBDeployer.ts +++ b/packages/core.gbapp/services/GBDeployer.ts @@ -47,7 +47,7 @@ const graph = require('@microsoft/microsoft-graph-client'); import { GBError, GBLog, GBMinInstance, IGBCoreService, IGBInstance, IGBPackage } from 'botlib'; import { AzureSearch } from 'pragmatismo-io-framework'; import { GBServer } from '../../../src/app'; -import { GuaribasPackage } from '../models/GBModel'; +import { GuaribasPackage, GuaribasInstance } from '../models/GBModel'; import { GBAdminService } from './../../admin.gbapp/services/GBAdminService'; import { AzureDeployerService } from './../../azuredeployer.gbapp/services/AzureDeployerService'; import { KBService } from './../../kb.gbapp/services/KBService'; @@ -164,7 +164,7 @@ export class GBDeployer { * Deploys a bot to the storage. */ - public async deployBot(localPath: string, proxyAddress: string): Promise { + public async deployBot(localPath: string, proxyAddress: string): Promise { const packageName = Path.basename(localPath); const service = new AzureDeployerService(this); @@ -186,8 +186,7 @@ export class GBDeployer { '' ); - } - else { + } else { instance = await service.internalDeployBot( instance, @@ -205,8 +204,7 @@ export class GBDeployer { subscriptionId ); } - return instance; - + await this.core.saveInstance(instance); } public async deployPackageToStorage(instanceId: number, packageName: string): Promise { @@ -234,12 +232,12 @@ export class GBDeployer { switch (packageType) { case '.gbot': - return this.deployBot(localPath, min.proxyAddress); + await this.deployBot(localPath, min.proxyAddress); case '.gbkb': const service = new KBService(this.core.sequelize); - return service.deployKb(this.core, this, localPath); + await service.deployKb(this.core, this, localPath); case '.gbdialog': const vm = new GBVMService(); @@ -348,10 +346,10 @@ export class GBDeployer { // Deploys all .gbot files first. - botPackages.forEach(e => { + botPackages.forEach(async (e) => { if (e !== 'packages\\boot.gbot') { GBLog.info(`Deploying bot: ${e}...`); - _this.deployBot(e, GBServer.globals.proxyAddress); + await _this.deployBot(e, GBServer.globals.proxyAddress); GBLog.info(`Bot: ${e} deployed...`); } }); diff --git a/packages/core.gbapp/services/GBMinService.ts b/packages/core.gbapp/services/GBMinService.ts index 6326dc6b..a8fbd86b 100644 --- a/packages/core.gbapp/services/GBMinService.ts +++ b/packages/core.gbapp/services/GBMinService.ts @@ -235,8 +235,8 @@ export class GBMinService { botId = bootInstance.botId; } const instance = await this.core.loadInstance(botId); - if (instance !== undefined) { - const speechToken = await this.getSTSToken(instance); + if (instance !== null) { + const speechToken = instance.speechKey != null ? await this.getSTSToken(instance) : null; let theme = instance.theme; if (theme !== undefined) { theme = 'default.gbtheme'; @@ -355,8 +355,8 @@ export class GBMinService { GBAdminPackage, GBKBPackage, GBAnalyticsPackage, - GBCustomerSatisfactionPackage - // DISABLED: GBWhatsappPackage + GBCustomerSatisfactionPackage, + GBWhatsappPackage ].forEach(sysPackage => { const p = Object.create(sysPackage.prototype) as IGBPackage; p.loadBot(min); diff --git a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts index 444a8d82..8275b5f8 100644 --- a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts +++ b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts @@ -4,6 +4,7 @@ const Swagger = require('swagger-client'); const rp = require('request-promise'); import { GBLog, GBService } from 'botlib'; import * as request from 'request-promise-native'; +import { GBServer } from '../../../src/app'; /** * Support for Whatsapp. @@ -57,7 +58,7 @@ export class WhatsappDirectLine extends GBService { url: urlJoin(this.whatsappServiceUrl, 'webhook'), qs: { token: this.whatsappServiceKey, - webhookUrl: `${this.whatsappServiceWebhookUrl}/instances/${this.botId}/whatsapp`, + webhookUrl: `${GBServer.globals.proxyAddress}/instances/${this.botId}/whatsapp`, set: true }, headers: { @@ -150,7 +151,7 @@ export class WhatsappDirectLine extends GBService { .then(activities => { this.printMessages(activities, conversationId, from, fromName); }); - }, this.pollInterval); + }, this.pollInterval); } public printMessages(activities, conversationId, from, fromName) {