fix(all): MSTeams fixes.
This commit is contained in:
parent
6778f2eb59
commit
d6f8574ecb
5 changed files with 250 additions and 235 deletions
|
@ -255,7 +255,8 @@ 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 (!this.userMobile(step)) {
|
if (!this.userMobile(step) &&
|
||||||
|
step.context.activity.channelId !== 'msteams') {
|
||||||
GBLog.info(`Sending event ${name}:${typeof value === 'object' ? JSON.stringify(value) :
|
GBLog.info(`Sending event ${name}:${typeof value === 'object' ? JSON.stringify(value) :
|
||||||
value ? value : ''} to client...`);
|
value ? value : ''} to client...`);
|
||||||
const msg = MessageFactory.text('');
|
const msg = MessageFactory.text('');
|
||||||
|
|
|
@ -163,7 +163,7 @@ export class GBMinService {
|
||||||
setTimeout(resolve, ms);
|
setTimeout(resolve, ms);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
await sleep(10000);
|
await sleep(20000);
|
||||||
res.status(200);
|
res.status(200);
|
||||||
res.end();
|
res.end();
|
||||||
});
|
});
|
||||||
|
@ -889,8 +889,9 @@ export class GBMinService {
|
||||||
|
|
||||||
const sec = new SecService();
|
const sec = new SecService();
|
||||||
if (!user.loaded) {
|
if (!user.loaded) {
|
||||||
|
if (step.context.activity.channelId !== 'msteams') {
|
||||||
await min.conversationalService.sendEvent(min, step, 'loadInstance', {});
|
await min.conversationalService.sendEvent(min, step, 'loadInstance', {});
|
||||||
|
}
|
||||||
|
|
||||||
user.loaded = true;
|
user.loaded = true;
|
||||||
user.subjects = [];
|
user.subjects = [];
|
||||||
|
@ -925,12 +926,14 @@ export class GBMinService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (step.context.activity.channelId !== 'msteams') {
|
||||||
const service = new KBService(min.core.sequelize);
|
const service = new KBService(min.core.sequelize);
|
||||||
const data = await service.getFaqBySubjectArray(instance.instanceId, 'faq', undefined);
|
const data = await service.getFaqBySubjectArray(instance.instanceId, 'faq', undefined);
|
||||||
await min.conversationalService.sendEvent(min, step, 'play', {
|
await min.conversationalService.sendEvent(min, step, 'play', {
|
||||||
playerType: 'bullet',
|
playerType: 'bullet',
|
||||||
data: data.slice(0, 10)
|
data: data.slice(0, 10)
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Saves session user (persisted GuaribasUser is inside).
|
// Saves session user (persisted GuaribasUser is inside).
|
||||||
|
|
||||||
|
|
|
@ -34,21 +34,21 @@
|
||||||
* @fileoverview General Bots server core.
|
* @fileoverview General Bots server core.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { BotAdapter } from 'botbuilder';
|
import { BotAdapter } from 'botbuilder';
|
||||||
import { WaterfallDialog } from 'botbuilder-dialogs';
|
import { WaterfallDialog } from 'botbuilder-dialogs';
|
||||||
import { GBMinInstance, IGBDialog } from 'botlib';
|
import { GBMinInstance, IGBDialog } from 'botlib';
|
||||||
import { GBMinService } from '../../core.gbapp/services/GBMinService';
|
import { GBMinService } from '../../core.gbapp/services/GBMinService';
|
||||||
import { AnalyticsService } from '../../analytics.gblib/services/AnalyticsService';
|
import { AnalyticsService } from '../../analytics.gblib/services/AnalyticsService';
|
||||||
import { SecService } from '../../security.gbapp/services/SecService';
|
import { SecService } from '../../security.gbapp/services/SecService';
|
||||||
import { CSService } from '../services/CSService';
|
import { CSService } from '../services/CSService';
|
||||||
import { Messages } from '../strings';
|
import { Messages } from '../strings';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dialog for feedback collecting.
|
* Dialog for feedback collecting.
|
||||||
*/
|
*/
|
||||||
export class FeedbackDialog extends IGBDialog {
|
export class FeedbackDialog extends IGBDialog {
|
||||||
/**
|
/**
|
||||||
* Setup dialogs flows and define services call.
|
* Setup dialogs flows and define services call.
|
||||||
*
|
*
|
||||||
|
@ -87,7 +87,7 @@ export class FeedbackDialog extends IGBDialog {
|
||||||
let from = GBMinService.userMobile(step);
|
let from = GBMinService.userMobile(step);
|
||||||
|
|
||||||
await min.conversationalService.sendText(min, step, Messages[locale].please_wait_transfering);
|
await min.conversationalService.sendText(min, step, Messages[locale].please_wait_transfering);
|
||||||
const agentSystemId = await sec.assignHumanAgent(from, min.instance.instanceId);
|
const agentSystemId = await sec.assignHumanAgent(min, from);
|
||||||
|
|
||||||
const user = await min.userProfile.get(step.context, {});
|
const user = await min.userProfile.get(step.context, {});
|
||||||
user.systemUser = await sec.getUserFromAgentSystemId(agentSystemId);
|
user.systemUser = await sec.getUserFromAgentSystemId(agentSystemId);
|
||||||
|
@ -257,4 +257,5 @@ export class FeedbackDialog extends IGBDialog {
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,9 +188,9 @@ export class AskDialog extends IGBDialog {
|
||||||
const locale = step.context.activity.locale;
|
const locale = step.context.activity.locale;
|
||||||
|
|
||||||
// Stops any content on projector.
|
// Stops any content on projector.
|
||||||
|
if (step.context.activity.channelId !== 'msteams') {
|
||||||
await min.conversationalService.sendEvent(min, step, 'stop', undefined);
|
await min.conversationalService.sendEvent(min, step, 'stop', undefined);
|
||||||
|
}
|
||||||
// Handle extra text from FAQ.
|
// Handle extra text from FAQ.
|
||||||
|
|
||||||
if (step.options && step.options.query) {
|
if (step.options && step.options.query) {
|
||||||
|
|
|
@ -2,7 +2,7 @@ const Fs = require('fs');
|
||||||
const urlJoin = require('url-join');
|
const urlJoin = require('url-join');
|
||||||
|
|
||||||
import { ConversationReference } from 'botbuilder';
|
import { ConversationReference } from 'botbuilder';
|
||||||
import { GBLog, GBService, IGBInstance } from 'botlib';
|
import { GBLog, GBMinInstance, GBService, IGBInstance } from 'botlib';
|
||||||
import { CollectionUtil } from 'pragmatismo-io-framework';
|
import { CollectionUtil } from 'pragmatismo-io-framework';
|
||||||
import { GuaribasGroup, GuaribasUser, GuaribasUserGroup } from '../models';
|
import { GuaribasGroup, GuaribasUser, GuaribasUserGroup } from '../models';
|
||||||
import {FindOptions} from 'sequelize';
|
import {FindOptions} from 'sequelize';
|
||||||
|
@ -167,21 +167,31 @@ export class SecService extends GBService {
|
||||||
return user.agentMode === 'self';
|
return user.agentMode === 'self';
|
||||||
}
|
}
|
||||||
|
|
||||||
public async assignHumanAgent(userSystemId: string, instanceId: number): Promise<string> {
|
public async assignHumanAgent(min: GBMinInstance, userSystemId: string): Promise<string> {
|
||||||
let agentSystemId;
|
let agentSystemId;
|
||||||
const list = process.env.TRANSFER_TO.split(';');
|
|
||||||
|
let list = min.core.getParam<string>(
|
||||||
|
min.instance,
|
||||||
|
'Transfer To',
|
||||||
|
process.env.TRANSFER_TO
|
||||||
|
);
|
||||||
|
|
||||||
|
if (list){
|
||||||
|
list = list.split(';')
|
||||||
|
}
|
||||||
|
|
||||||
await CollectionUtil.asyncForEach(list, async item => {
|
await CollectionUtil.asyncForEach(list, async item => {
|
||||||
if (
|
if (
|
||||||
!(item !== undefined &&
|
item !== undefined &&
|
||||||
agentSystemId === undefined &&
|
agentSystemId === undefined &&
|
||||||
item !== userSystemId && await this.isAgentSystemId(item))
|
item !== userSystemId && !await this.isAgentSystemId(item)
|
||||||
) {
|
) {
|
||||||
// TODO: Optimize loop.
|
// TODO: Optimize loop.
|
||||||
agentSystemId = item;
|
agentSystemId = item;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
GBLog.info(`Selected agentId: ${agentSystemId}`);
|
GBLog.info(`Selected agentId: ${agentSystemId}`);
|
||||||
await this.updateHumanAgent(userSystemId, instanceId, agentSystemId);
|
await this.updateHumanAgent(userSystemId, min.instance.instanceId, agentSystemId);
|
||||||
GBLog.info(`Updated agentId to: ${agentSystemId}`);
|
GBLog.info(`Updated agentId to: ${agentSystemId}`);
|
||||||
|
|
||||||
return agentSystemId;
|
return agentSystemId;
|
||||||
|
|
Loading…
Add table
Reference in a new issue