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
|
||||
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');
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<IGBInstance> {
|
||||
public async deployBot(localPath: string, proxyAddress: string): Promise<void> {
|
||||
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<GuaribasPackage> {
|
||||
|
@ -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...`);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue