fix(core.gbapp): WebChat now can be made private.
This commit is contained in:
parent
c51ff7a78f
commit
99b5a4a2e9
3 changed files with 40 additions and 13 deletions
|
@ -286,7 +286,7 @@ export class GBMinService {
|
||||||
}
|
}
|
||||||
const instance = await this.core.loadInstance(botId);
|
const instance = await this.core.loadInstance(botId);
|
||||||
if (instance !== null) {
|
if (instance !== null) {
|
||||||
const webchatToken = await this.getWebchatToken(instance);
|
const webchatTokenContainer = await this.getWebchatToken(instance);
|
||||||
const speechToken = instance.speechKey != null ? await this.getSTSToken(instance) : null;
|
const speechToken = instance.speechKey != null ? await this.getSTSToken(instance) : null;
|
||||||
let theme = instance.theme;
|
let theme = instance.theme;
|
||||||
if (theme === undefined) {
|
if (theme === undefined) {
|
||||||
|
@ -297,9 +297,9 @@ export class GBMinService {
|
||||||
instanceId: instance.instanceId,
|
instanceId: instance.instanceId,
|
||||||
botId: botId,
|
botId: botId,
|
||||||
theme: theme,
|
theme: theme,
|
||||||
webchatToken: webchatToken,
|
webchatToken: webchatTokenContainer.token,
|
||||||
speechToken: speechToken,
|
speechToken: speechToken,
|
||||||
conversationId: webchatToken.conversationId,
|
conversationId: webchatTokenContainer.conversationId,
|
||||||
authenticatorTenant: instance.authenticatorTenant,
|
authenticatorTenant: instance.authenticatorTenant,
|
||||||
authenticatorClientId: instance.authenticatorClientId
|
authenticatorClientId: instance.authenticatorClientId
|
||||||
})
|
})
|
||||||
|
@ -541,9 +541,7 @@ export class GBMinService {
|
||||||
const isVMCall = Object.keys(min.scriptMap).find(key => min.scriptMap[key] === context.activity.text) !== undefined;
|
const isVMCall = Object.keys(min.scriptMap).find(key => min.scriptMap[key] === context.activity.text) !== undefined;
|
||||||
|
|
||||||
if (isVMCall) {
|
if (isVMCall) {
|
||||||
const mainMethod = context.activity.text;
|
await GBMinService.callVM(context.activity.text, min, step);
|
||||||
min.sandBoxMap[mainMethod][mainMethod].bind(min.sandBoxMap[mainMethod]);
|
|
||||||
await min.sandBoxMap[mainMethod][mainMethod](step);
|
|
||||||
} else if (context.activity.text.charAt(0) === '/') {
|
} else if (context.activity.text.charAt(0) === '/') {
|
||||||
await step.beginDialog(context.activity.text);
|
await step.beginDialog(context.activity.text);
|
||||||
|
|
||||||
|
@ -568,4 +566,10 @@ export class GBMinService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async callVM(text: string, min: GBMinInstance, step: GBDialogStep) {
|
||||||
|
const mainMethod = text;
|
||||||
|
min.sandBoxMap[mainMethod][mainMethod].bind(min.sandBoxMap[mainMethod]);
|
||||||
|
return await min.sandBoxMap[mainMethod][mainMethod](step);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,7 +173,7 @@ class GBUIApp extends React.Component {
|
||||||
window['botchatDebug'] = true;
|
window['botchatDebug'] = true;
|
||||||
|
|
||||||
const line = new DirectLine({
|
const line = new DirectLine({
|
||||||
token: this.state.instanceClient.token
|
token: this.state.instanceClient.webchatToken
|
||||||
});
|
});
|
||||||
|
|
||||||
line.connectionStatus$.subscribe(connectionStatus => {
|
line.connectionStatus$.subscribe(connectionStatus => {
|
||||||
|
|
|
@ -42,6 +42,8 @@ import { GBLog, GBMinInstance, IGBDialog } from 'botlib';
|
||||||
import { AzureText } from 'pragmatismo-io-framework';
|
import { AzureText } from 'pragmatismo-io-framework';
|
||||||
import { Messages } from '../strings';
|
import { Messages } from '../strings';
|
||||||
import { KBService } from './../services/KBService';
|
import { KBService } from './../services/KBService';
|
||||||
|
import { GuaribasAnswer } from '../models';
|
||||||
|
import { GBMinService } from '../../../packages/core.gbapp/services/GBMinService';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dialog arguments.
|
* Dialog arguments.
|
||||||
|
@ -144,10 +146,8 @@ export class AskDialog extends IGBDialog {
|
||||||
|
|
||||||
// Sends the answer to all outputs, including projector.
|
// Sends the answer to all outputs, including projector.
|
||||||
|
|
||||||
await service.sendAnswer(min, AskDialog.getChannel(step), step, resultsA.answer);
|
return await AskDialog.handleAnswer(service, min, step, resultsA.answer);
|
||||||
|
|
||||||
// Goes to ask loop, again.
|
|
||||||
return await step.replaceDialog('/ask', { isReturning: true });
|
|
||||||
} else {
|
} else {
|
||||||
// Second time running Search, now with no filter.
|
// Second time running Search, now with no filter.
|
||||||
const resultsB = await service.ask(min.instance, text, min.instance.searchScore, undefined);
|
const resultsB = await service.ask(min.instance, text, min.instance.searchScore, undefined);
|
||||||
|
@ -163,10 +163,12 @@ export class AskDialog extends IGBDialog {
|
||||||
if (user2.subjects.length > 0) {
|
if (user2.subjects.length > 0) {
|
||||||
await step.context.sendActivity(Messages[locale].wider_answer);
|
await step.context.sendActivity(Messages[locale].wider_answer);
|
||||||
}
|
}
|
||||||
// Sends the answer to all outputs, including projector.
|
|
||||||
await service.sendAnswer(min, AskDialog.getChannel(step), step, resultsB.answer);
|
|
||||||
|
|
||||||
return await step.replaceDialog('/ask', { isReturning: true });
|
if (resultsB.answer)
|
||||||
|
|
||||||
|
// Sends the answer to all outputs, including projector.
|
||||||
|
|
||||||
|
return await AskDialog.handleAnswer(service, min, step, resultsA.answer);
|
||||||
} else {
|
} else {
|
||||||
if (!(await min.conversationalService.routeNLP(step, min, text))) {
|
if (!(await min.conversationalService.routeNLP(step, min, text))) {
|
||||||
await step.context.sendActivity(Messages[locale].did_not_find);
|
await step.context.sendActivity(Messages[locale].did_not_find);
|
||||||
|
@ -179,6 +181,27 @@ export class AskDialog extends IGBDialog {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static async handleAnswer(service: KBService, min: GBMinInstance, step: any, answer: GuaribasAnswer) {
|
||||||
|
|
||||||
|
const dialogSufix = 'dialog:';
|
||||||
|
const urlSufix = 'url:';
|
||||||
|
const scriptSufix = 'script:';
|
||||||
|
|
||||||
|
if (answer.content.startsWith(dialogSufix)) {
|
||||||
|
let dialogName = answer.content.substring(dialogSufix.length);
|
||||||
|
return await step.replaceDialog(`/${dialogName}`, { isReturning: true });
|
||||||
|
} else if (answer.content.startsWith(scriptSufix)) {
|
||||||
|
let scriptName = answer.content.substring(scriptSufix.length);
|
||||||
|
|
||||||
|
return await GBMinService.callVM(scriptName, min, step);
|
||||||
|
} else {
|
||||||
|
await service.sendAnswer(min, AskDialog.getChannel(step), step, answer);
|
||||||
|
|
||||||
|
return await step.replaceDialog('/ask', { isReturning: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private static getChannel(step): string {
|
private static getChannel(step): string {
|
||||||
return !isNaN(step.context.activity.from.id) ? 'whatsapp' : step.context.activity.channelId;
|
return !isNaN(step.context.activity.from.id) ? 'whatsapp' : step.context.activity.channelId;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue