new(all): TRUE multicloud.
This commit is contained in:
parent
3f9e3b040e
commit
3299683268
12 changed files with 1397 additions and 143 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -29,3 +29,4 @@ package-lock.json
|
||||||
yarn-lock.json
|
yarn-lock.json
|
||||||
logo.svg
|
logo.svg
|
||||||
screenshot.png
|
screenshot.png
|
||||||
|
data.db
|
||||||
|
|
1248
directline-3.0-local.json
Normal file
1248
directline-3.0-local.json
Normal file
File diff suppressed because one or more lines are too long
|
@ -39,6 +39,7 @@ import { GBAdminService } from '../../admin.gbapp/services/GBAdminService.js';
|
||||||
import urlJoin from 'url-join';
|
import urlJoin from 'url-join';
|
||||||
import { GBServer } from '../../../src/app.js';
|
import { GBServer } from '../../../src/app.js';
|
||||||
import { GBLogEx } from '../../core.gbapp/services/GBLogEx.js';
|
import { GBLogEx } from '../../core.gbapp/services/GBLogEx.js';
|
||||||
|
import sharp from 'sharp';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Image processing services of conversation to be called by BASIC.
|
* Image processing services of conversation to be called by BASIC.
|
||||||
|
|
|
@ -341,6 +341,7 @@ export class GBConversationalService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async sendEvent(min: GBMinInstance, step: GBDialogStep, name: string, value: Object): Promise<any> {
|
public async sendEvent(min: GBMinInstance, step: GBDialogStep, name: string, value: Object): Promise<any> {
|
||||||
|
|
||||||
if (step.context.activity.channelId !== 'msteams' && step.context.activity.channelId !== 'omnichannel') {
|
if (step.context.activity.channelId !== 'msteams' && step.context.activity.channelId !== 'omnichannel') {
|
||||||
GBLogEx.info(
|
GBLogEx.info(
|
||||||
min,
|
min,
|
||||||
|
|
|
@ -140,10 +140,7 @@ export class GBMinService {
|
||||||
this.deployer = deployer;
|
this.deployer = deployer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async enableAPI(min: GBMinInstance) {}
|
||||||
public async enableAPI(min: GBMinInstance) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new minimal instance for each bot.
|
* Constructs a new minimal instance for each bot.
|
||||||
|
@ -175,7 +172,7 @@ export class GBMinService {
|
||||||
instances,
|
instances,
|
||||||
(async instance => {
|
(async instance => {
|
||||||
try {
|
try {
|
||||||
GBLog.info(`Mounting ${instance.botId}...`)
|
GBLog.info(`Mounting ${instance.botId}...`);
|
||||||
await this['mountBot'](instance);
|
await this['mountBot'](instance);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
GBLog.error(`Error mounting bot ${instance.botId}: ${error.message}\n${error.stack}`);
|
GBLog.error(`Error mounting bot ${instance.botId}: ${error.message}\n${error.stack}`);
|
||||||
|
@ -234,7 +231,7 @@ export class GBMinService {
|
||||||
/**
|
/**
|
||||||
* Unmounts the bot web site (default.gbui) secure domain, if any.
|
* Unmounts the bot web site (default.gbui) secure domain, if any.
|
||||||
*/
|
*/
|
||||||
public async unloadDomain(instance: IGBInstance) { }
|
public async unloadDomain(instance: IGBInstance) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mount the instance by creating an BOT Framework bot object,
|
* Mount the instance by creating an BOT Framework bot object,
|
||||||
|
@ -242,7 +239,6 @@ export class GBMinService {
|
||||||
* installing all BASIC artifacts from .gbdialog and OAuth2.
|
* installing all BASIC artifacts from .gbdialog and OAuth2.
|
||||||
*/
|
*/
|
||||||
public async mountBot(instance: IGBInstance) {
|
public async mountBot(instance: IGBInstance) {
|
||||||
|
|
||||||
// Build bot adapter.
|
// Build bot adapter.
|
||||||
|
|
||||||
const { min, adapter, conversationState } = await this.buildBotAdapter(
|
const { min, adapter, conversationState } = await this.buildBotAdapter(
|
||||||
|
@ -331,7 +327,9 @@ export class GBMinService {
|
||||||
const receiver = async (req, res) => {
|
const receiver = async (req, res) => {
|
||||||
await this.receiver(req, res, conversationState, min, instance, GBServer.globals.appPackages);
|
await this.receiver(req, res, conversationState, min, instance, GBServer.globals.appPackages);
|
||||||
};
|
};
|
||||||
const url = `/api/messages/${instance.botId}`;
|
let url = `/api/messages/${instance.botId}`;
|
||||||
|
GBServer.globals.server.post(url, receiver);
|
||||||
|
url = `/api/messages`;
|
||||||
GBServer.globals.server.post(url, receiver);
|
GBServer.globals.server.post(url, receiver);
|
||||||
GBServer.globals.server.get(url, (req, res) => {
|
GBServer.globals.server.get(url, (req, res) => {
|
||||||
if (req.query['hub.mode'] === 'subscribe') {
|
if (req.query['hub.mode'] === 'subscribe') {
|
||||||
|
@ -426,35 +424,35 @@ export class GBMinService {
|
||||||
|
|
||||||
// Setups official handler for WhatsApp.
|
// Setups official handler for WhatsApp.
|
||||||
|
|
||||||
GBServer.globals.server.all(`/${min.instance.botId}/whatsapp`, async (req, res) => {
|
GBServer.globals.server
|
||||||
|
.all(`/${min.instance.botId}/whatsapp`, async (req, res) => {
|
||||||
|
if (req.query['hub.mode'] === 'subscribe') {
|
||||||
|
const val = req.query['hub.verify_token'];
|
||||||
|
|
||||||
|
if (val === process.env.META_CHALLENGE) {
|
||||||
|
res.send(req.query['hub.challenge']);
|
||||||
|
res.status(200);
|
||||||
|
GBLogEx.info(min, `Meta callback OK. ${JSON.stringify(req.query)}`);
|
||||||
|
} else {
|
||||||
|
res.status(401);
|
||||||
|
}
|
||||||
|
res.end();
|
||||||
|
|
||||||
if (req.query['hub.mode'] === 'subscribe') {
|
return;
|
||||||
const val = req.query['hub.verify_token'];
|
|
||||||
|
|
||||||
if (val === process.env.META_CHALLENGE) {
|
|
||||||
res.send(req.query['hub.challenge']);
|
|
||||||
res.status(200);
|
|
||||||
GBLogEx.info(min, `Meta callback OK. ${JSON.stringify(req.query)}`);
|
|
||||||
} else {
|
|
||||||
res.status(401);
|
|
||||||
}
|
}
|
||||||
res.end();
|
|
||||||
|
|
||||||
return;
|
let whatsAppDirectLine = min.whatsAppDirectLine;
|
||||||
}
|
|
||||||
|
|
||||||
let whatsAppDirectLine = min.whatsAppDirectLine;
|
// Not meta, multiples bots on root bot.
|
||||||
|
|
||||||
// Not meta, multiples bots on root bot.
|
if (!req.body.object) {
|
||||||
|
const to = req.body.To.replace(/whatsapp\:\+/gi, '');
|
||||||
|
whatsAppDirectLine = WhatsappDirectLine.botsByNumber[to];
|
||||||
|
}
|
||||||
|
|
||||||
if (!req.body.object) {
|
await whatsAppDirectLine.WhatsAppCallback(req, res, whatsAppDirectLine.botId);
|
||||||
const to = req.body.To.replace(/whatsapp\:\+/gi, '');
|
})
|
||||||
whatsAppDirectLine = WhatsappDirectLine.botsByNumber[to];
|
.bind(min);
|
||||||
}
|
|
||||||
|
|
||||||
await whatsAppDirectLine.WhatsAppCallback(req, res, whatsAppDirectLine.botId);
|
|
||||||
}).bind(min);
|
|
||||||
|
|
||||||
GBDeployer.mountGBKBAssets(`${botId}.gbkb`, botId, `${botId}.gbkb`);
|
GBDeployer.mountGBKBAssets(`${botId}.gbkb`, botId, `${botId}.gbkb`);
|
||||||
}
|
}
|
||||||
|
@ -510,9 +508,7 @@ export class GBMinService {
|
||||||
* on https://<gbhost>/<BotId>/token URL.
|
* on https://<gbhost>/<BotId>/token URL.
|
||||||
*/
|
*/
|
||||||
private handleOAuthTokenRequests(server: any, min: GBMinInstance, instance: IGBInstance) {
|
private handleOAuthTokenRequests(server: any, min: GBMinInstance, instance: IGBInstance) {
|
||||||
|
|
||||||
server.get(`/${min.instance.botId}/token`, async (req, res) => {
|
server.get(`/${min.instance.botId}/token`, async (req, res) => {
|
||||||
|
|
||||||
let tokenName = req.query['value'];
|
let tokenName = req.query['value'];
|
||||||
if (!tokenName) {
|
if (!tokenName) {
|
||||||
tokenName = '';
|
tokenName = '';
|
||||||
|
@ -535,9 +531,7 @@ export class GBMinService {
|
||||||
if (tokenName) {
|
if (tokenName) {
|
||||||
const code = req?.query?.code;
|
const code = req?.query?.code;
|
||||||
|
|
||||||
let url = urlJoin(
|
let url = urlJoin(host, tenant, 'oauth/token');
|
||||||
host,
|
|
||||||
tenant, 'oauth/token');
|
|
||||||
let buff = new Buffer(`${clientId}:${clientSecret}`);
|
let buff = new Buffer(`${clientId}:${clientSecret}`);
|
||||||
const base64 = buff.toString('base64');
|
const base64 = buff.toString('base64');
|
||||||
|
|
||||||
|
@ -549,14 +543,14 @@ export class GBMinService {
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
},
|
},
|
||||||
body: new URLSearchParams({
|
body: new URLSearchParams({
|
||||||
'grant_type': 'authorization_code',
|
grant_type: 'authorization_code',
|
||||||
'code': code
|
code: code
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
const result = await fetch(url, options);
|
const result = await fetch(url, options);
|
||||||
|
|
||||||
if (result.status != 200) {
|
if (result.status != 200) {
|
||||||
throw new Error(`handleOAuthTokenRequests error: ${result.status}: ${result.statusText}.`)
|
throw new Error(`handleOAuthTokenRequests error: ${result.status}: ${result.statusText}.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const text = await result.text();
|
const text = await result.text();
|
||||||
|
@ -564,24 +558,31 @@ export class GBMinService {
|
||||||
|
|
||||||
// Saves token to the database.
|
// Saves token to the database.
|
||||||
|
|
||||||
await this.adminService.setValue(instance.instanceId,
|
await this.adminService.setValue(
|
||||||
`${tokenName}accessToken`, token['accessToken'] ? token['accessToken'] : token['access_token']);
|
instance.instanceId,
|
||||||
await this.adminService.setValue(instance.instanceId,
|
`${tokenName}accessToken`,
|
||||||
`${tokenName}refreshToken`, token['refreshToken'] ? token['refreshToken'] : token['refresh_token']);
|
token['accessToken'] ? token['accessToken'] : token['access_token']
|
||||||
|
);
|
||||||
|
await this.adminService.setValue(
|
||||||
|
instance.instanceId,
|
||||||
|
`${tokenName}refreshToken`,
|
||||||
|
token['refreshToken'] ? token['refreshToken'] : token['refresh_token']
|
||||||
|
);
|
||||||
|
|
||||||
await this.adminService.setValue(instance.instanceId,
|
await this.adminService.setValue(
|
||||||
`${tokenName}expiresOn`, token['expiresOn'] ?
|
instance.instanceId,
|
||||||
token['expiresOn'].toString() :
|
`${tokenName}expiresOn`,
|
||||||
new Date(Date.now() + (token['expires_in'] * 1000)).toString());
|
token['expiresOn']
|
||||||
|
? token['expiresOn'].toString()
|
||||||
|
: new Date(Date.now() + token['expires_in'] * 1000).toString()
|
||||||
|
);
|
||||||
await this.adminService.setValue(instance.instanceId, `${tokenName}AntiCSRFAttackState`, null);
|
await this.adminService.setValue(instance.instanceId, `${tokenName}AntiCSRFAttackState`, null);
|
||||||
|
} else {
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
const authenticationContext = new AuthenticationContext.AuthenticationContext(
|
const authenticationContext = new AuthenticationContext.AuthenticationContext(
|
||||||
urlJoin(
|
urlJoin(
|
||||||
tokenName ? host : min.instance.authenticatorAuthorityHostUrl,
|
tokenName ? host : min.instance.authenticatorAuthorityHostUrl,
|
||||||
tokenName ? tenant : min.instance.authenticatorTenant)
|
tokenName ? tenant : min.instance.authenticatorTenant
|
||||||
|
)
|
||||||
);
|
);
|
||||||
const resource = 'https://graph.microsoft.com';
|
const resource = 'https://graph.microsoft.com';
|
||||||
|
|
||||||
|
@ -595,26 +596,24 @@ export class GBMinService {
|
||||||
tokenName ? clientSecret : instance.marketplacePassword,
|
tokenName ? clientSecret : instance.marketplacePassword,
|
||||||
async (err, token) => {
|
async (err, token) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
||||||
const msg = `handleOAuthTokenRequests: Error acquiring token: ${err}`;
|
const msg = `handleOAuthTokenRequests: Error acquiring token: ${err}`;
|
||||||
|
|
||||||
GBLog.error(msg);
|
GBLog.error(msg);
|
||||||
res.send(msg);
|
res.send(msg);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Saves token to the database.
|
// Saves token to the database.
|
||||||
|
|
||||||
await this.adminService.setValue(instance.instanceId, `${tokenName}accessToken`, token['accessToken']);
|
await this.adminService.setValue(instance.instanceId, `${tokenName}accessToken`, token['accessToken']);
|
||||||
await this.adminService.setValue(instance.instanceId, `${tokenName}refreshToken`, token['refreshToken']);
|
await this.adminService.setValue(instance.instanceId, `${tokenName}refreshToken`, token['refreshToken']);
|
||||||
await this.adminService.setValue(instance.instanceId, `${tokenName}expiresOn`, token['expiresOn'].toString());
|
await this.adminService.setValue(
|
||||||
|
instance.instanceId,
|
||||||
|
`${tokenName}expiresOn`,
|
||||||
|
token['expiresOn'].toString()
|
||||||
|
);
|
||||||
await this.adminService.setValue(instance.instanceId, `${tokenName}AntiCSRFAttackState`, null);
|
await this.adminService.setValue(instance.instanceId, `${tokenName}AntiCSRFAttackState`, null);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// Inform the home for default .gbui after finishing token retrival.
|
// Inform the home for default .gbui after finishing token retrival.
|
||||||
|
|
||||||
|
@ -633,8 +632,9 @@ export class GBMinService {
|
||||||
min.instance.authenticatorTenant,
|
min.instance.authenticatorTenant,
|
||||||
'/oauth2/authorize'
|
'/oauth2/authorize'
|
||||||
);
|
);
|
||||||
authorizationUrl = `${authorizationUrl}?response_type=code&client_id=${min.instance.marketplaceId
|
authorizationUrl = `${authorizationUrl}?response_type=code&client_id=${
|
||||||
}&redirect_uri=${urlJoin(process.env.BOT_URL, min.instance.botId, 'token')}`;
|
min.instance.marketplaceId
|
||||||
|
}&redirect_uri=${urlJoin(process.env.BOT_URL, min.instance.botId, 'token')}`;
|
||||||
GBLogEx.info(min, `HandleOAuthRequests: ${authorizationUrl}.`);
|
GBLogEx.info(min, `HandleOAuthRequests: ${authorizationUrl}.`);
|
||||||
res.redirect(authorizationUrl);
|
res.redirect(authorizationUrl);
|
||||||
});
|
});
|
||||||
|
@ -651,7 +651,6 @@ export class GBMinService {
|
||||||
botId = GBConfigService.get('BOT_ID');
|
botId = GBConfigService.get('BOT_ID');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Loads by the botId itself or by the activationCode field.
|
// Loads by the botId itself or by the activationCode field.
|
||||||
|
|
||||||
let instance = await this.core.loadInstanceByBotId(botId);
|
let instance = await this.core.loadInstanceByBotId(botId);
|
||||||
|
@ -678,7 +677,8 @@ export class GBMinService {
|
||||||
instanceId: instance.instanceId,
|
instanceId: instance.instanceId,
|
||||||
botId: botId,
|
botId: botId,
|
||||||
theme: theme,
|
theme: theme,
|
||||||
webchatToken: webchatTokenContainer.token,
|
//webchatToken: webchatTokenContainer.token,
|
||||||
|
domain: 'http://localhost:3978/directline',
|
||||||
speechToken: speechToken,
|
speechToken: speechToken,
|
||||||
conversationId: webchatTokenContainer.conversationId,
|
conversationId: webchatTokenContainer.conversationId,
|
||||||
authenticatorTenant: instance.authenticatorTenant,
|
authenticatorTenant: instance.authenticatorTenant,
|
||||||
|
@ -690,10 +690,7 @@ export class GBMinService {
|
||||||
paramLogoImageType: this.core.getParam(instance, 'Logo Image Type', null),
|
paramLogoImageType: this.core.getParam(instance, 'Logo Image Type', null),
|
||||||
logo: this.core.getParam(instance, 'Logo', null),
|
logo: this.core.getParam(instance, 'Logo', null),
|
||||||
color1: this.core.getParam(instance, 'Color1', null),
|
color1: this.core.getParam(instance, 'Color1', null),
|
||||||
color2: this.core.getParam(instance, 'Color2', null),
|
color2: this.core.getParam(instance, 'Color2', null)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -752,8 +749,10 @@ export class GBMinService {
|
||||||
*/
|
*/
|
||||||
private async buildBotAdapter(instance: any, sysPackages: IGBPackage[], appPackages: IGBPackage[]) {
|
private async buildBotAdapter(instance: any, sysPackages: IGBPackage[], appPackages: IGBPackage[]) {
|
||||||
// MSFT stuff.
|
// MSFT stuff.
|
||||||
|
const uri = 'http://localhost:3978';
|
||||||
|
|
||||||
const adapter = new BotFrameworkAdapter({
|
const adapter = new BotFrameworkAdapter({
|
||||||
|
clientOptions: { baseUri: uri },
|
||||||
appId: instance.marketplaceId ? instance.marketplaceId : GBConfigService.get('MARKETPLACE_ID'),
|
appId: instance.marketplaceId ? instance.marketplaceId : GBConfigService.get('MARKETPLACE_ID'),
|
||||||
appPassword: instance.marketplacePassword
|
appPassword: instance.marketplacePassword
|
||||||
? instance.marketplacePassword
|
? instance.marketplacePassword
|
||||||
|
@ -802,7 +801,6 @@ export class GBMinService {
|
||||||
GBServer.globals.minBoot = min;
|
GBServer.globals.minBoot = min;
|
||||||
GBServer.globals.minBoot.instance.marketplaceId = GBConfigService.get('MARKETPLACE_ID');
|
GBServer.globals.minBoot.instance.marketplaceId = GBConfigService.get('MARKETPLACE_ID');
|
||||||
GBServer.globals.minBoot.instance.marketplacePassword = GBConfigService.get('MARKETPLACE_SECRET');
|
GBServer.globals.minBoot.instance.marketplacePassword = GBConfigService.get('MARKETPLACE_SECRET');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (min.instance.facebookWorkplaceVerifyToken) {
|
if (min.instance.facebookWorkplaceVerifyToken) {
|
||||||
|
@ -860,8 +858,7 @@ export class GBMinService {
|
||||||
|
|
||||||
await min.whatsAppDirectLine.setup(true);
|
await min.whatsAppDirectLine.setup(true);
|
||||||
} else {
|
} else {
|
||||||
if (min !== minBoot && minBoot.instance.whatsappServiceKey
|
if (min !== minBoot && minBoot.instance.whatsappServiceKey && min.instance.webchatKey) {
|
||||||
&& min.instance.webchatKey) {
|
|
||||||
min.whatsAppDirectLine = new WhatsappDirectLine(
|
min.whatsAppDirectLine = new WhatsappDirectLine(
|
||||||
min,
|
min,
|
||||||
min.botId,
|
min.botId,
|
||||||
|
@ -1087,7 +1084,10 @@ export class GBMinService {
|
||||||
const startDialog = min.core.getParam(min.instance, 'Start Dialog', null);
|
const startDialog = min.core.getParam(min.instance, 'Start Dialog', null);
|
||||||
if (startDialog) {
|
if (startDialog) {
|
||||||
await sec.setParam(userId, 'welcomed', 'true');
|
await sec.setParam(userId, 'welcomed', 'true');
|
||||||
GBLogEx.info(min, `Auto start (teams) dialog is now being called: ${startDialog} for ${min.instance.botId}...`);
|
GBLogEx.info(
|
||||||
|
min,
|
||||||
|
`Auto start (teams) dialog is now being called: ${startDialog} for ${min.instance.botId}...`
|
||||||
|
);
|
||||||
await GBVMService.callVM(startDialog.toLowerCase(), min, step, pid);
|
await GBVMService.callVM(startDialog.toLowerCase(), min, step, pid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1095,7 +1095,8 @@ export class GBMinService {
|
||||||
|
|
||||||
// Required for F0 handling of persisted conversations.
|
// Required for F0 handling of persisted conversations.
|
||||||
|
|
||||||
GBLogEx.info(min,
|
GBLogEx.info(
|
||||||
|
min,
|
||||||
`Input> ${context.activity.text} (type: ${context.activity.type}, name: ${context.activity.name}, channelId: ${context.activity.channelId})`
|
`Input> ${context.activity.text} (type: ${context.activity.type}, name: ${context.activity.name}, channelId: ${context.activity.channelId})`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1104,7 +1105,6 @@ export class GBMinService {
|
||||||
|
|
||||||
const startDialog = min.core.getParam(min.instance, 'Start Dialog', null);
|
const startDialog = min.core.getParam(min.instance, 'Start Dialog', null);
|
||||||
|
|
||||||
|
|
||||||
if (context.activity.type === 'installationUpdate') {
|
if (context.activity.type === 'installationUpdate') {
|
||||||
GBLogEx.info(min, `Bot installed on Teams.`);
|
GBLogEx.info(min, `Bot installed on Teams.`);
|
||||||
} else if (context.activity.type === 'conversationUpdate' && context.activity.membersAdded.length > 0) {
|
} else if (context.activity.type === 'conversationUpdate' && context.activity.membersAdded.length > 0) {
|
||||||
|
@ -1133,7 +1133,8 @@ export class GBMinService {
|
||||||
) {
|
) {
|
||||||
min['conversationWelcomed'][step.context.activity.conversation.id] = true;
|
min['conversationWelcomed'][step.context.activity.conversation.id] = true;
|
||||||
|
|
||||||
GBLogEx.info(min,
|
GBLogEx.info(
|
||||||
|
min,
|
||||||
`Auto start (web 1) dialog is now being called: ${startDialog} for ${min.instance.instanceId}...`
|
`Auto start (web 1) dialog is now being called: ${startDialog} for ${min.instance.instanceId}...`
|
||||||
);
|
);
|
||||||
await GBVMService.callVM(startDialog.toLowerCase(), min, step, pid);
|
await GBVMService.callVM(startDialog.toLowerCase(), min, step, pid);
|
||||||
|
@ -1147,7 +1148,6 @@ export class GBMinService {
|
||||||
} else if (context.activity.type === 'message') {
|
} else if (context.activity.type === 'message') {
|
||||||
// Processes messages activities.
|
// Processes messages activities.
|
||||||
|
|
||||||
|
|
||||||
await this.processMessageActivity(context, min, step, pid);
|
await this.processMessageActivity(context, min, step, pid);
|
||||||
} else if (context.activity.type === 'event') {
|
} else if (context.activity.type === 'event') {
|
||||||
// Processes events activities.
|
// Processes events activities.
|
||||||
|
@ -1155,8 +1155,9 @@ export class GBMinService {
|
||||||
await this.processEventActivity(min, user, context, step);
|
await this.processEventActivity(min, user, context, step);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const msg = `ERROR: ${error.message} ${error.stack} ${error.error ? error.error.body : ''} ${error.error ? (error.error.stack ? error.error.stack : '') : ''
|
const msg = `ERROR: ${error.message} ${error.stack} ${error.error ? error.error.body : ''} ${
|
||||||
}`;
|
error.error ? (error.error.stack ? error.error.stack : '') : ''
|
||||||
|
}`;
|
||||||
GBLog.error(msg);
|
GBLog.error(msg);
|
||||||
|
|
||||||
await min.conversationalService.sendText(
|
await min.conversationalService.sendText(
|
||||||
|
@ -1170,7 +1171,17 @@ export class GBMinService {
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await adapter['processActivity'](req, res, handler);
|
if (process.env.STORAGE_FILE) {
|
||||||
|
const context = adapter['createContext'](req);
|
||||||
|
context['_activity'] = context.activity.body;
|
||||||
|
await handler(context);
|
||||||
|
// Return status
|
||||||
|
res.status(200);
|
||||||
|
|
||||||
|
res.end();
|
||||||
|
} else {
|
||||||
|
await adapter['processActivity'](req, res, handler);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.code === 401) {
|
if (error.code === 401) {
|
||||||
GBLog.error('Calling processActivity due to Signing Key could not be retrieved error.');
|
GBLog.error('Calling processActivity due to Signing Key could not be retrieved error.');
|
||||||
|
@ -1209,7 +1220,10 @@ export class GBMinService {
|
||||||
const startDialog = min.core.getParam(min.instance, 'Start Dialog', null);
|
const startDialog = min.core.getParam(min.instance, 'Start Dialog', null);
|
||||||
if (startDialog && !min['conversationWelcomed'][step.context.activity.conversation.id]) {
|
if (startDialog && !min['conversationWelcomed'][step.context.activity.conversation.id]) {
|
||||||
user.welcomed = true;
|
user.welcomed = true;
|
||||||
GBLogEx.info(min, `Auto start (web 2) dialog is now being called: ${startDialog} for ${min.instance.instanceId}...`);
|
GBLogEx.info(
|
||||||
|
min,
|
||||||
|
`Auto start (web 2) dialog is now being called: ${startDialog} for ${min.instance.instanceId}...`
|
||||||
|
);
|
||||||
await GBVMService.callVM(startDialog.toLowerCase(), min, step, pid);
|
await GBVMService.callVM(startDialog.toLowerCase(), min, step, pid);
|
||||||
}
|
}
|
||||||
} else if (context.activity.name === 'updateToken') {
|
} else if (context.activity.name === 'updateToken') {
|
||||||
|
@ -1263,7 +1277,6 @@ export class GBMinService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async handleUploads(min, step, user, params, autoSave) {
|
private async handleUploads(min, step, user, params, autoSave) {
|
||||||
|
|
||||||
// Prepare Promises to download each attachment and then execute each Promise.
|
// Prepare Promises to download each attachment and then execute each Promise.
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -1294,7 +1307,6 @@ export class GBMinService {
|
||||||
GBServer.globals.files[handle] = gbfile;
|
GBServer.globals.files[handle] = gbfile;
|
||||||
|
|
||||||
if (!min.cbMap[user.userId] && autoSave) {
|
if (!min.cbMap[user.userId] && autoSave) {
|
||||||
|
|
||||||
const result = await t['internalAutoSave']({ min: min, handle: handle });
|
const result = await t['internalAutoSave']({ min: min, handle: handle });
|
||||||
await min.conversationalService.sendText(
|
await min.conversationalService.sendText(
|
||||||
min,
|
min,
|
||||||
|
@ -1303,12 +1315,9 @@ export class GBMinService {
|
||||||
);
|
);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return gbfile;
|
return gbfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
await this.sendActivity('Error uploading file. Please,start again.');
|
await this.sendActivity('Error uploading file. Please,start again.');
|
||||||
}
|
}
|
||||||
|
@ -1399,10 +1408,8 @@ export class GBMinService {
|
||||||
const userId = user.userId;
|
const userId = user.userId;
|
||||||
const params = user.params ? JSON.parse(user.params) : {};
|
const params = user.params ? JSON.parse(user.params) : {};
|
||||||
|
|
||||||
|
|
||||||
let message: GuaribasConversationMessage;
|
let message: GuaribasConversationMessage;
|
||||||
if (process.env.PRIVACY_STORE_MESSAGES === 'true') {
|
if (process.env.PRIVACY_STORE_MESSAGES === 'true') {
|
||||||
|
|
||||||
// Adds message to the analytics layer.
|
// Adds message to the analytics layer.
|
||||||
|
|
||||||
const analytics = new AnalyticsService();
|
const analytics = new AnalyticsService();
|
||||||
|
@ -1420,7 +1427,6 @@ export class GBMinService {
|
||||||
userId,
|
userId,
|
||||||
context.activity.text
|
context.activity.text
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1439,7 +1445,8 @@ export class GBMinService {
|
||||||
) {
|
) {
|
||||||
await sec.setParam(userId, 'welcomed', 'true');
|
await sec.setParam(userId, 'welcomed', 'true');
|
||||||
min['conversationWelcomed'][step.context.activity.conversation.id] = true;
|
min['conversationWelcomed'][step.context.activity.conversation.id] = true;
|
||||||
GBLogEx.info(min,
|
GBLogEx.info(
|
||||||
|
min,
|
||||||
`Auto start (4) dialog is now being called: ${startDialog} for ${min.instance.instanceId}...`
|
`Auto start (4) dialog is now being called: ${startDialog} for ${min.instance.instanceId}...`
|
||||||
);
|
);
|
||||||
await GBVMService.callVM(startDialog.toLowerCase(), min, step, pid);
|
await GBVMService.callVM(startDialog.toLowerCase(), min, step, pid);
|
||||||
|
@ -1500,21 +1507,18 @@ export class GBMinService {
|
||||||
} else {
|
} else {
|
||||||
// Removes unwanted chars in input text.
|
// Removes unwanted chars in input text.
|
||||||
|
|
||||||
|
|
||||||
step.context.activity['originalText'] = context.activity.text;
|
step.context.activity['originalText'] = context.activity.text;
|
||||||
const text = await GBConversationalService.handleText(min, user, step, context.activity.text);
|
const text = await GBConversationalService.handleText(min, user, step, context.activity.text);
|
||||||
step.context.activity['originalText']
|
step.context.activity['originalText'];
|
||||||
step.context.activity['text'] = text;
|
step.context.activity['text'] = text;
|
||||||
|
|
||||||
|
if (notes && text && text !== '') {
|
||||||
if (notes && text && text !== "") {
|
|
||||||
const sys = new SystemKeywords();
|
const sys = new SystemKeywords();
|
||||||
await sys.note({ pid, text });
|
await sys.note({ pid, text });
|
||||||
await step.context.sendActivity('OK.');
|
await step.context.sendActivity('OK.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Checks for bad words on input text.
|
// Checks for bad words on input text.
|
||||||
|
|
||||||
const hasBadWord = wash.check(step.context.activity.locale, text);
|
const hasBadWord = wash.check(step.context.activity.locale, text);
|
||||||
|
@ -1549,7 +1553,7 @@ export class GBMinService {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (min.cbMap[userId] && min.cbMap[userId].promise === '!GBHEAR') {
|
if (min.cbMap[userId] && min.cbMap[userId].promise === '!GBHEAR') {
|
||||||
min.cbMap[userId].promise = step.context.activity['originalText'];;
|
min.cbMap[userId].promise = step.context.activity['originalText'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is a dialog in course, continue to the next step.
|
// If there is a dialog in course, continue to the next step.
|
||||||
|
@ -1557,8 +1561,9 @@ export class GBMinService {
|
||||||
try {
|
try {
|
||||||
await step.continueDialog();
|
await step.continueDialog();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const msg = `ERROR: ${error.message} ${error.stack} ${error.error ? error.error.body : ''} ${error.error ? (error.error.stack ? error.error.stack : '') : ''
|
const msg = `ERROR: ${error.message} ${error.stack} ${error.error ? error.error.body : ''} ${
|
||||||
}`;
|
error.error ? (error.error.stack ? error.error.stack : '') : ''
|
||||||
|
}`;
|
||||||
GBLog.error(msg);
|
GBLog.error(msg);
|
||||||
await min.conversationalService.sendText(
|
await min.conversationalService.sendText(
|
||||||
min,
|
min,
|
||||||
|
@ -1601,7 +1606,6 @@ export class GBMinService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async ensureAPI() {
|
public async ensureAPI() {
|
||||||
|
|
||||||
const mins = GBServer.globals.minInstances;
|
const mins = GBServer.globals.minInstances;
|
||||||
|
|
||||||
function getRemoteId(ctx: Koa.Context) {
|
function getRemoteId(ctx: Koa.Context) {
|
||||||
|
@ -1611,14 +1615,11 @@ export class GBMinService {
|
||||||
const close = async () => {
|
const close = async () => {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
if (GBServer.globals.server.apiServer) {
|
if (GBServer.globals.server.apiServer) {
|
||||||
GBServer.globals.server.apiServer.close(
|
GBServer.globals.server.apiServer.close(cb => {
|
||||||
cb => {
|
resolve(true);
|
||||||
resolve(true);
|
GBLogEx.info(0, 'Reloading General Bots API...');
|
||||||
GBLogEx.info(0, 'Reloading General Bots API...');
|
});
|
||||||
}
|
} else {
|
||||||
);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
resolve(true);
|
resolve(true);
|
||||||
GBLogEx.info(0, 'Loading General Bots API...');
|
GBLogEx.info(0, 'Loading General Bots API...');
|
||||||
}
|
}
|
||||||
|
@ -1629,11 +1630,9 @@ export class GBMinService {
|
||||||
|
|
||||||
let proxies = {};
|
let proxies = {};
|
||||||
await CollectionUtil.asyncForEach(mins, async min => {
|
await CollectionUtil.asyncForEach(mins, async min => {
|
||||||
|
|
||||||
let dialogs = {};
|
let dialogs = {};
|
||||||
await CollectionUtil.asyncForEach(Object.values(min.scriptMap), async script => {
|
await CollectionUtil.asyncForEach(Object.values(min.scriptMap), async script => {
|
||||||
|
dialogs[script] = async data => {
|
||||||
dialogs[script] = async (data) => {
|
|
||||||
let sec = new SecService();
|
let sec = new SecService();
|
||||||
const user = await sec.ensureUser(
|
const user = await sec.ensureUser(
|
||||||
min,
|
min,
|
||||||
|
@ -1649,7 +1648,6 @@ export class GBMinService {
|
||||||
if (script === 'start') {
|
if (script === 'start') {
|
||||||
pid = GBVMService.createProcessInfo(user, min, 'api', null);
|
pid = GBVMService.createProcessInfo(user, min, 'api', null);
|
||||||
|
|
||||||
|
|
||||||
const client = await new SwaggerClient({
|
const client = await new SwaggerClient({
|
||||||
spec: JSON.parse(Fs.readFileSync('directline-3.0.json', 'utf8')),
|
spec: JSON.parse(Fs.readFileSync('directline-3.0.json', 'utf8')),
|
||||||
requestInterceptor: req => {
|
requestInterceptor: req => {
|
||||||
|
@ -1668,7 +1666,7 @@ export class GBMinService {
|
||||||
ret = pid;
|
ret = pid;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const proxy = {
|
const proxy = {
|
||||||
|
@ -1686,10 +1684,10 @@ export class GBMinService {
|
||||||
pingSendTimeout: null,
|
pingSendTimeout: null,
|
||||||
keepAliveTimeout: null,
|
keepAliveTimeout: null,
|
||||||
listeners: {
|
listeners: {
|
||||||
unsubscribed(subscriptions: number): void { },
|
unsubscribed(subscriptions: number): void {},
|
||||||
subscribed(subscriptions: number): void { },
|
subscribed(subscriptions: number): void {},
|
||||||
disconnected(remoteId: string, connections: number): void { },
|
disconnected(remoteId: string, connections: number): void {},
|
||||||
connected(remoteId: string, connections: number): void { },
|
connected(remoteId: string, connections: number): void {},
|
||||||
messageIn(...params): void {
|
messageIn(...params): void {
|
||||||
params.shift();
|
params.shift();
|
||||||
},
|
},
|
||||||
|
@ -1699,16 +1697,8 @@ export class GBMinService {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
GBServer.globals.server.apiServer = createKoaHttpServer(
|
GBServer.globals.server.apiServer = createKoaHttpServer(GBVMService.API_PORT, getRemoteId, { prefix: `api/v3` });
|
||||||
GBVMService.API_PORT,
|
|
||||||
getRemoteId, { prefix: `api/v3` });
|
|
||||||
|
|
||||||
createRpcServer(
|
|
||||||
proxies,
|
|
||||||
GBServer.globals.server.apiServer,
|
|
||||||
opts
|
|
||||||
);
|
|
||||||
|
|
||||||
|
createRpcServer(proxies, GBServer.globals.server.apiServer, opts);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
<link rel="stylesheet" type="text/css" href="/themes/{theme}/css/App.css" />
|
<link rel="stylesheet" type="text/css" href="/themes/{theme}/css/App.css" />
|
||||||
<link rel="stylesheet" type="text/css" href="/themes/{theme}/css/SideBarMenu.css" />
|
<link rel="stylesheet" type="text/css" href="/themes/{theme}/css/SideBarMenu.css" />
|
||||||
|
|
||||||
<script src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>
|
<script src="./js/webchat.js"></script>
|
||||||
<title>{title} - General Bots Community Edition</title>
|
<title>{title} - General Bots Community Edition</title>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
2
packages/default.gbui/public/js/webchat.js
Normal file
2
packages/default.gbui/public/js/webchat.js
Normal file
File diff suppressed because one or more lines are too long
|
@ -168,9 +168,18 @@ class GBUIApp extends React.Component {
|
||||||
let _this_ = this;
|
let _this_ = this;
|
||||||
window['botchatDebug'] = true;
|
window['botchatDebug'] = true;
|
||||||
|
|
||||||
const line = new DirectLine({
|
const line = instanceClient.webchatToken ?
|
||||||
|
new DirectLine({
|
||||||
token: instanceClient.webchatToken
|
token: instanceClient.webchatToken
|
||||||
});
|
}):
|
||||||
|
new DirectLine({
|
||||||
|
domain: instanceClient.domain,
|
||||||
|
secret: null,
|
||||||
|
token: null,
|
||||||
|
webSocket: false // defaults to true
|
||||||
|
});
|
||||||
|
|
||||||
|
;
|
||||||
_this_.setState({ line: line });
|
_this_.setState({ line: line });
|
||||||
|
|
||||||
line.connectionStatus$.subscribe(connectionStatus => {
|
line.connectionStatus$.subscribe(connectionStatus => {
|
||||||
|
|
|
@ -36,6 +36,7 @@ class ChatPane extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<Chat
|
<Chat
|
||||||
|
|
||||||
ref={(chat) => { this.chat = chat; }}
|
ref={(chat) => { this.chat = chat; }}
|
||||||
botConnection={this.props.botConnection}
|
botConnection={this.props.botConnection}
|
||||||
user={{ id: "webUser@gb", name: "You" }}
|
user={{ id: "webUser@gb", name: "You" }}
|
||||||
|
|
|
@ -31,7 +31,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { GBMinInstance } from 'botlib';
|
import { GBMinInstance } from 'botlib';
|
||||||
import { OpenAIClient } from '@azure/openai';
|
import OpenAI from 'openai';
|
||||||
|
|
||||||
import { AzureKeyCredential } from '@azure/core-auth';
|
import { AzureKeyCredential } from '@azure/core-auth';
|
||||||
import { DialogKeywords } from '../../basic.gblib/services/DialogKeywords';
|
import { DialogKeywords } from '../../basic.gblib/services/DialogKeywords';
|
||||||
import Path from 'path';
|
import Path from 'path';
|
||||||
|
@ -45,7 +46,6 @@ import { GBLogEx } from '../../core.gbapp/services/GBLogEx';
|
||||||
* Image processing services of conversation to be called by BASIC.
|
* Image processing services of conversation to be called by BASIC.
|
||||||
*/
|
*/
|
||||||
export class ImageServices {
|
export class ImageServices {
|
||||||
|
|
||||||
public async getImageFromPrompt({ pid, prompt }) {
|
public async getImageFromPrompt({ pid, prompt }) {
|
||||||
const { min, user, params } = await DialogKeywords.getProcessInfo(pid);
|
const { min, user, params } = await DialogKeywords.getProcessInfo(pid);
|
||||||
|
|
||||||
|
@ -55,11 +55,12 @@ export class ImageServices {
|
||||||
|
|
||||||
if (azureOpenAIKey) {
|
if (azureOpenAIKey) {
|
||||||
// Initialize the Azure OpenAI client
|
// Initialize the Azure OpenAI client
|
||||||
const client = new OpenAIClient(azureOpenAIEndpoint, new AzureKeyCredential(azureOpenAIKey));
|
|
||||||
|
const client = new OpenAI({ apiKey: azureOpenAIKey, baseURL: azureOpenAIEndpoint });
|
||||||
|
|
||||||
// Make a request to the image generation endpoint
|
// Make a request to the image generation endpoint
|
||||||
|
|
||||||
const response = await client.getImageGeneration(azureOpenAIImageModel, {
|
const response = await client.images.generate({
|
||||||
prompt: prompt,
|
prompt: prompt,
|
||||||
n: 1,
|
n: 1,
|
||||||
size: '1024x1024'
|
size: '1024x1024'
|
||||||
|
@ -75,7 +76,7 @@ export class ImageServices {
|
||||||
|
|
||||||
GBLogEx.info(min, `BASIC: DALL-E image generated at ${url}.`);
|
GBLogEx.info(min, `BASIC: DALL-E image generated at ${url}.`);
|
||||||
|
|
||||||
return {localName, url};
|
return { localName, url };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,12 +85,10 @@ export class WhatsappDirectLine extends GBService {
|
||||||
public botId: string;
|
public botId: string;
|
||||||
public botNumber: string;
|
public botNumber: string;
|
||||||
public min: GBMinInstance;
|
public min: GBMinInstance;
|
||||||
private directLineSecret: string;
|
|
||||||
private locale: string = 'pt-BR';
|
private locale: string = 'pt-BR';
|
||||||
provider: any;
|
provider: any;
|
||||||
INSTANCE_URL = 'https://api.maytapi.com/api';
|
INSTANCE_URL = 'https://api.maytapi.com/api';
|
||||||
private customClient: any;
|
private customClient: any;
|
||||||
private groupId;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
min: GBMinInstance,
|
min: GBMinInstance,
|
||||||
|
@ -104,13 +102,12 @@ export class WhatsappDirectLine extends GBService {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.min = min;
|
this.min = min;
|
||||||
this.botId = botId;
|
this.botId = botId;
|
||||||
this.directLineSecret = directLineSecret;
|
|
||||||
this.whatsappServiceKey = whatsappServiceKey;
|
this.whatsappServiceKey = whatsappServiceKey;
|
||||||
this.whatsappServiceNumber = whatsappServiceNumber;
|
this.whatsappServiceNumber = whatsappServiceNumber;
|
||||||
this.whatsappServiceUrl = whatsappServiceUrl;
|
this.whatsappServiceUrl = whatsappServiceUrl;
|
||||||
this.provider = whatsappServiceKey === 'internal' ? 'GeneralBots' : 'meta';
|
this.provider = whatsappServiceKey === 'internal' ? 'GeneralBots' : 'meta';
|
||||||
this.groupId = groupId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async asyncForEach(array, callback) {
|
public static async asyncForEach(array, callback) {
|
||||||
|
@ -121,6 +118,7 @@ export class WhatsappDirectLine extends GBService {
|
||||||
|
|
||||||
public async setup(setUrl: boolean) {
|
public async setup(setUrl: boolean) {
|
||||||
const client = await new SwaggerClient({
|
const client = await new SwaggerClient({
|
||||||
|
url: 'http://127.0.0.1:3978/api/messages', // TODO:
|
||||||
spec: JSON.parse(Fs.readFileSync('directline-3.0.json', 'utf8')),
|
spec: JSON.parse(Fs.readFileSync('directline-3.0.json', 'utf8')),
|
||||||
requestInterceptor: req => {
|
requestInterceptor: req => {
|
||||||
req.headers['Authorization'] = `Bearer ${this.min.instance.webchatKey}`;
|
req.headers['Authorization'] = `Bearer ${this.min.instance.webchatKey}`;
|
||||||
|
|
12
src/app.ts
12
src/app.ts
|
@ -100,6 +100,7 @@ export class GBServer {
|
||||||
GBServer.globals.wwwroot = null;
|
GBServer.globals.wwwroot = null;
|
||||||
GBServer.globals.entryPointDialog = null;
|
GBServer.globals.entryPointDialog = null;
|
||||||
GBServer.globals.debuggers = [];
|
GBServer.globals.debuggers = [];
|
||||||
|
GBServer.globals.users = [];
|
||||||
GBServer.globals.indexSemaphore = new Mutex();
|
GBServer.globals.indexSemaphore = new Mutex();
|
||||||
|
|
||||||
server.use(bodyParser.json());
|
server.use(bodyParser.json());
|
||||||
|
@ -121,17 +122,16 @@ export class GBServer {
|
||||||
});
|
});
|
||||||
|
|
||||||
process.on('unhandledRejection', (err, p) => {
|
process.on('unhandledRejection', (err, p) => {
|
||||||
|
|
||||||
let bypass = false;
|
let bypass = false;
|
||||||
let res = err['response'];
|
let res = err['response'];
|
||||||
if (res) {
|
if (res) {
|
||||||
if (res?.body?.error?.message?.startsWith('Failed to send activity: bot timed out')){
|
if (res?.body?.error?.message?.startsWith('Failed to send activity: bot timed out')) {
|
||||||
bypass = true;
|
bypass = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!bypass){
|
if (!bypass) {
|
||||||
GBLogEx.error(0,`GBREJECTION: ${GBUtil.toYAML(err)} ${GBUtil.toYAML(p)}`);
|
GBLogEx.error(0, `GBREJECTION: ${GBUtil.toYAML(err)} ${GBUtil.toYAML(p)}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -179,6 +179,8 @@ export class GBServer {
|
||||||
if (GBConfigService.get('STORAGE_SERVER')) {
|
if (GBConfigService.get('STORAGE_SERVER')) {
|
||||||
azureDeployer = await AzureDeployerService.createInstance(deployer);
|
azureDeployer = await AzureDeployerService.createInstance(deployer);
|
||||||
await core.initStorage();
|
await core.initStorage();
|
||||||
|
} else if (GBConfigService.get('STORAGE_FILE')) {
|
||||||
|
await core.initStorage();
|
||||||
} else {
|
} else {
|
||||||
runOnce = true;
|
runOnce = true;
|
||||||
[GBServer.globals.bootInstance, azureDeployer] = await core['createBootInstanceEx'](
|
[GBServer.globals.bootInstance, azureDeployer] = await core['createBootInstanceEx'](
|
||||||
|
|
Loading…
Add table
Reference in a new issue