fix(whatsapp.lib): Enabling Whatsapp.
This commit is contained in:
parent
bc9c58828b
commit
85249e5f3f
5 changed files with 18 additions and 21 deletions
|
@ -225,8 +225,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
||||||
// CHECK
|
// CHECK
|
||||||
if (!JSON.parse(res.bodyAsText).id) {
|
if (!JSON.parse(res.bodyAsText).id) {
|
||||||
return false;
|
return false;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,7 +291,6 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
||||||
GBLog.info(`Bot proxy updated at: ${endpoint}.`);
|
GBLog.info(`Bot proxy updated at: ${endpoint}.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async openStorageFirewall(groupName, serverName) {
|
public async openStorageFirewall(groupName, serverName) {
|
||||||
const username = GBConfigService.get('CLOUD_USERNAME');
|
const username = GBConfigService.get('CLOUD_USERNAME');
|
||||||
const password = GBConfigService.get('CLOUD_PASSWORD');
|
const password = GBConfigService.get('CLOUD_PASSWORD');
|
||||||
|
|
|
@ -347,8 +347,8 @@ STORAGE_SYNC=true
|
||||||
GBCorePackage,
|
GBCorePackage,
|
||||||
GBSecurityPackage,
|
GBSecurityPackage,
|
||||||
GBKBPackage,
|
GBKBPackage,
|
||||||
GBCustomerSatisfactionPackage
|
GBCustomerSatisfactionPackage,
|
||||||
// GBWhatsappPackage
|
GBWhatsappPackage
|
||||||
].forEach(e => {
|
].forEach(e => {
|
||||||
GBLog.info(`Loading sys package: ${e.name}...`);
|
GBLog.info(`Loading sys package: ${e.name}...`);
|
||||||
const p = Object.create(e.prototype) as IGBPackage;
|
const p = Object.create(e.prototype) as IGBPackage;
|
||||||
|
|
|
@ -47,7 +47,7 @@ const graph = require('@microsoft/microsoft-graph-client');
|
||||||
import { GBError, GBLog, GBMinInstance, IGBCoreService, IGBInstance, IGBPackage } from 'botlib';
|
import { GBError, GBLog, GBMinInstance, IGBCoreService, IGBInstance, IGBPackage } from 'botlib';
|
||||||
import { AzureSearch } from 'pragmatismo-io-framework';
|
import { AzureSearch } from 'pragmatismo-io-framework';
|
||||||
import { GBServer } from '../../../src/app';
|
import { GBServer } from '../../../src/app';
|
||||||
import { GuaribasPackage } from '../models/GBModel';
|
import { GuaribasPackage, GuaribasInstance } from '../models/GBModel';
|
||||||
import { GBAdminService } from './../../admin.gbapp/services/GBAdminService';
|
import { GBAdminService } from './../../admin.gbapp/services/GBAdminService';
|
||||||
import { AzureDeployerService } from './../../azuredeployer.gbapp/services/AzureDeployerService';
|
import { AzureDeployerService } from './../../azuredeployer.gbapp/services/AzureDeployerService';
|
||||||
import { KBService } from './../../kb.gbapp/services/KBService';
|
import { KBService } from './../../kb.gbapp/services/KBService';
|
||||||
|
@ -164,7 +164,7 @@ export class GBDeployer {
|
||||||
* Deploys a bot to the storage.
|
* Deploys a bot to the storage.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public async deployBot(localPath: string, proxyAddress: string): Promise<IGBInstance> {
|
public async deployBot(localPath: string, proxyAddress: string): Promise<void> {
|
||||||
const packageName = Path.basename(localPath);
|
const packageName = Path.basename(localPath);
|
||||||
|
|
||||||
const service = new AzureDeployerService(this);
|
const service = new AzureDeployerService(this);
|
||||||
|
@ -186,8 +186,7 @@ export class GBDeployer {
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
|
|
||||||
instance = await service.internalDeployBot(
|
instance = await service.internalDeployBot(
|
||||||
instance,
|
instance,
|
||||||
|
@ -205,8 +204,7 @@ export class GBDeployer {
|
||||||
subscriptionId
|
subscriptionId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return instance;
|
await this.core.saveInstance(instance);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async deployPackageToStorage(instanceId: number, packageName: string): Promise<GuaribasPackage> {
|
public async deployPackageToStorage(instanceId: number, packageName: string): Promise<GuaribasPackage> {
|
||||||
|
@ -234,12 +232,12 @@ export class GBDeployer {
|
||||||
|
|
||||||
switch (packageType) {
|
switch (packageType) {
|
||||||
case '.gbot':
|
case '.gbot':
|
||||||
return this.deployBot(localPath, min.proxyAddress);
|
await this.deployBot(localPath, min.proxyAddress);
|
||||||
|
|
||||||
case '.gbkb':
|
case '.gbkb':
|
||||||
const service = new KBService(this.core.sequelize);
|
const service = new KBService(this.core.sequelize);
|
||||||
|
|
||||||
return service.deployKb(this.core, this, localPath);
|
await service.deployKb(this.core, this, localPath);
|
||||||
|
|
||||||
case '.gbdialog':
|
case '.gbdialog':
|
||||||
const vm = new GBVMService();
|
const vm = new GBVMService();
|
||||||
|
@ -348,10 +346,10 @@ export class GBDeployer {
|
||||||
|
|
||||||
// Deploys all .gbot files first.
|
// Deploys all .gbot files first.
|
||||||
|
|
||||||
botPackages.forEach(e => {
|
botPackages.forEach(async (e) => {
|
||||||
if (e !== 'packages\\boot.gbot') {
|
if (e !== 'packages\\boot.gbot') {
|
||||||
GBLog.info(`Deploying bot: ${e}...`);
|
GBLog.info(`Deploying bot: ${e}...`);
|
||||||
_this.deployBot(e, GBServer.globals.proxyAddress);
|
await _this.deployBot(e, GBServer.globals.proxyAddress);
|
||||||
GBLog.info(`Bot: ${e} deployed...`);
|
GBLog.info(`Bot: ${e} deployed...`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -235,8 +235,8 @@ export class GBMinService {
|
||||||
botId = bootInstance.botId;
|
botId = bootInstance.botId;
|
||||||
}
|
}
|
||||||
const instance = await this.core.loadInstance(botId);
|
const instance = await this.core.loadInstance(botId);
|
||||||
if (instance !== undefined) {
|
if (instance !== null) {
|
||||||
const speechToken = await this.getSTSToken(instance);
|
const speechToken = instance.speechKey != null ? await this.getSTSToken(instance) : null;
|
||||||
let theme = instance.theme;
|
let theme = instance.theme;
|
||||||
if (theme !== undefined) {
|
if (theme !== undefined) {
|
||||||
theme = 'default.gbtheme';
|
theme = 'default.gbtheme';
|
||||||
|
@ -355,8 +355,8 @@ export class GBMinService {
|
||||||
GBAdminPackage,
|
GBAdminPackage,
|
||||||
GBKBPackage,
|
GBKBPackage,
|
||||||
GBAnalyticsPackage,
|
GBAnalyticsPackage,
|
||||||
GBCustomerSatisfactionPackage
|
GBCustomerSatisfactionPackage,
|
||||||
// DISABLED: GBWhatsappPackage
|
GBWhatsappPackage
|
||||||
].forEach(sysPackage => {
|
].forEach(sysPackage => {
|
||||||
const p = Object.create(sysPackage.prototype) as IGBPackage;
|
const p = Object.create(sysPackage.prototype) as IGBPackage;
|
||||||
p.loadBot(min);
|
p.loadBot(min);
|
||||||
|
|
|
@ -4,6 +4,7 @@ const Swagger = require('swagger-client');
|
||||||
const rp = require('request-promise');
|
const rp = require('request-promise');
|
||||||
import { GBLog, GBService } from 'botlib';
|
import { GBLog, GBService } from 'botlib';
|
||||||
import * as request from 'request-promise-native';
|
import * as request from 'request-promise-native';
|
||||||
|
import { GBServer } from '../../../src/app';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Support for Whatsapp.
|
* Support for Whatsapp.
|
||||||
|
@ -57,7 +58,7 @@ export class WhatsappDirectLine extends GBService {
|
||||||
url: urlJoin(this.whatsappServiceUrl, 'webhook'),
|
url: urlJoin(this.whatsappServiceUrl, 'webhook'),
|
||||||
qs: {
|
qs: {
|
||||||
token: this.whatsappServiceKey,
|
token: this.whatsappServiceKey,
|
||||||
webhookUrl: `${this.whatsappServiceWebhookUrl}/instances/${this.botId}/whatsapp`,
|
webhookUrl: `${GBServer.globals.proxyAddress}/instances/${this.botId}/whatsapp`,
|
||||||
set: true
|
set: true
|
||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
|
|
Loading…
Add table
Reference in a new issue