Testing and rebase to en-us as default language.
This commit is contained in:
parent
7a33f6942e
commit
e7a7fcedbf
6 changed files with 76 additions and 73 deletions
|
@ -41,8 +41,6 @@ import { GBImporter } from '../../core.gbapp/services/GBImporter'
|
|||
import { GBConfigService } from '../../core.gbapp/services/GBConfigService'
|
||||
import { KBService } from './../../kb.gbapp/services/KBService'
|
||||
import { BotAdapter } from "botbuilder"
|
||||
import {messages} from "./Strings"
|
||||
import { reject } from "async"
|
||||
|
||||
/**
|
||||
* Dialogs for administration tasks.
|
||||
|
|
|
@ -39,6 +39,8 @@ import { IGBConversationalService } from "botlib";
|
|||
import { GBMinInstance } from "botlib";
|
||||
import { LuisRecognizer } from "botbuilder-ai";
|
||||
import { MessageFactory } from "botbuilder";
|
||||
import { Messages } from "../strings";
|
||||
import { AzureText } from "pragmatismo-io-framework";
|
||||
|
||||
export interface LanguagePickerSettings {
|
||||
defaultLocale?: string;
|
||||
|
@ -65,7 +67,6 @@ export class GBConversationalService implements IGBConversationalService {
|
|||
}
|
||||
|
||||
async routeNLP(dc: any, min: GBMinInstance, text: string): Promise<boolean> {
|
||||
|
||||
// Invokes LUIS.
|
||||
|
||||
const model = new LuisRecognizer({
|
||||
|
@ -99,4 +100,27 @@ export class GBConversationalService implements IGBConversationalService {
|
|||
return Promise.resolve(false);
|
||||
}
|
||||
}
|
||||
|
||||
async checkLanguage(dc, min, text) {
|
||||
let locale = await AzureText.getLocale(
|
||||
min.instance.textAnalyticsKey,
|
||||
min.instance.textAnalyticsServerUrl,
|
||||
text
|
||||
);
|
||||
if (locale != dc.context.activity.locale.split("-")[0]) {
|
||||
switch (locale) {
|
||||
case "pt":
|
||||
dc.context.activity.locale = "pt-BR";
|
||||
await dc.context.sendActivity(Messages[locale].changing_language);
|
||||
break;
|
||||
case "en":
|
||||
dc.context.activity.locale = "en-US";
|
||||
await dc.context.sendActivity(Messages[locale].changing_language);
|
||||
break;
|
||||
default:
|
||||
await dc.context.sendActivity(`Unknown language: ${locale}`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -272,7 +272,7 @@ export class GBMinService {
|
|||
return adapter.processActivity(req, res, async context => {
|
||||
const state = conversationState.get(context)
|
||||
const dc = min.dialogs.createContext(context, state)
|
||||
dc.context.activity.locale = "pt-BR"
|
||||
dc.context.activity.locale = "en-US"
|
||||
const user = min.userState.get(dc.context)
|
||||
|
||||
if (!user.loaded) {
|
||||
|
|
|
@ -80,14 +80,14 @@ class GBMarkdownPlayer extends Component {
|
|||
|
||||
var quality =
|
||||
<div className="gb-markdown-player-quality">
|
||||
<span ref={i => (this.quality = i)}>A resposta atende?</span>
|
||||
<span ref={i => (this.quality = i)}>Is the answer OK?</span>
|
||||
|
||||
<button className="gb-quality-button-yes" onClick={() => this.clickYes()} ref={i => (this.Yes = i)}>
|
||||
Sim
|
||||
Yes
|
||||
</button>
|
||||
|
|
||||
<button className="gb-quality-button-no" onClick={() => this.clickNo()} ref={i => (this.No = i)}>
|
||||
Não
|
||||
No
|
||||
</button>
|
||||
</div>;
|
||||
|
||||
|
|
|
@ -69,26 +69,7 @@ export class AskDialog extends IGBDialog {
|
|||
throw new Error(`/answer being called with no args.query text.`);
|
||||
}
|
||||
|
||||
let locale = await AzureText.getLocale(
|
||||
min.instance.textAnalyticsKey,
|
||||
min.instance.textAnalyticsServerUrl,
|
||||
text
|
||||
);
|
||||
if (locale != dc.context.activity.locale.split("-")[0]) {
|
||||
switch (locale) {
|
||||
case "pt":
|
||||
dc.context.activity.locale = "pt-BR";
|
||||
await dc.context.sendActivity(Messages[locale].changing_language);
|
||||
break;
|
||||
case "en":
|
||||
dc.context.activity.locale = "en-US";
|
||||
await dc.context.sendActivity(Messages[locale].changing_language);
|
||||
break;
|
||||
default:
|
||||
await dc.context.sendActivity(`Unknown language: ${locale}`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
let locale = dc.context.activity.locale
|
||||
|
||||
// Stops any content on projector.
|
||||
|
||||
|
|
|
@ -30,17 +30,17 @@
|
|||
| |
|
||||
\*****************************************************************************/
|
||||
|
||||
"use strict";
|
||||
"use strict"
|
||||
|
||||
const UrlJoin = require("url-join");
|
||||
const UrlJoin = require("url-join")
|
||||
|
||||
import { BotAdapter, CardFactory, MessageFactory } from "botbuilder";
|
||||
import { IGBDialog } from "botlib";
|
||||
import { GBMinInstance } from "botlib";
|
||||
import { GuaribasSubject } from "../models";
|
||||
import { KBService } from "../services/KBService";
|
||||
import { Messages } from "../strings";
|
||||
import { AzureText } from "pragmatismo-io-framework";
|
||||
import { BotAdapter, CardFactory, MessageFactory } from "botbuilder"
|
||||
import { IGBDialog } from "botlib"
|
||||
import { GBMinInstance } from "botlib"
|
||||
import { GuaribasSubject } from "../models"
|
||||
import { KBService } from "../services/KBService"
|
||||
import { Messages } from "../strings"
|
||||
import { AzureText } from "pragmatismo-io-framework"
|
||||
|
||||
export class MenuDialog extends IGBDialog {
|
||||
/**
|
||||
|
@ -50,30 +50,30 @@ export class MenuDialog extends IGBDialog {
|
|||
* @param min The minimal bot instance data.
|
||||
*/
|
||||
static setup(bot: BotAdapter, min: GBMinInstance) {
|
||||
var service = new KBService(min.core.sequelize);
|
||||
var service = new KBService(min.core.sequelize)
|
||||
|
||||
min.dialogs.add("/menu", [
|
||||
async (dc, args) => {
|
||||
const locale = dc.context.activity.locale;
|
||||
var rootSubjectId = null;
|
||||
const locale = dc.context.activity.locale
|
||||
var rootSubjectId = null
|
||||
|
||||
if (args && args.data) {
|
||||
var subject = args.data;
|
||||
var subject = args.data
|
||||
|
||||
// If there is a shortcut specified as subject destination, go there.
|
||||
|
||||
if (subject.to) {
|
||||
let dialog = subject.to.split(":")[1];
|
||||
await dc.replace("/" + dialog);
|
||||
await dc.end();
|
||||
return;
|
||||
let dialog = subject.to.split(":")[1]
|
||||
await dc.replace("/" + dialog)
|
||||
await dc.end()
|
||||
return
|
||||
}
|
||||
|
||||
// Adds to bot a perception of a new subject.
|
||||
|
||||
const user = min.userState.get(dc.context);
|
||||
user.subjects.push(subject);
|
||||
rootSubjectId = subject.subjectId;
|
||||
const user = min.userState.get(dc.context)
|
||||
user.subjects.push(subject)
|
||||
rootSubjectId = subject.subjectId
|
||||
|
||||
// Whenever a subject is selected, shows a faq about it.
|
||||
|
||||
|
@ -81,32 +81,32 @@ export class MenuDialog extends IGBDialog {
|
|||
let data = await service.getFaqBySubjectArray(
|
||||
"menu",
|
||||
user.subjects
|
||||
);
|
||||
)
|
||||
await min.conversationalService.sendEvent(dc, "play", {
|
||||
playerType: "bullet",
|
||||
data: data.slice(0, 6)
|
||||
});
|
||||
})
|
||||
}
|
||||
} else {
|
||||
const user = min.userState.get(dc.context);
|
||||
user.subjects = [];
|
||||
const user = min.userState.get(dc.context)
|
||||
user.subjects = []
|
||||
|
||||
await dc.context.sendActivity(Messages[locale].here_is_subjects); // TODO: Handle rnd.
|
||||
user.isAsking = false;
|
||||
await dc.context.sendActivity(Messages[locale].here_is_subjects) // TODO: Handle rnd.
|
||||
user.isAsking = false
|
||||
}
|
||||
|
||||
const msg = MessageFactory.text("");
|
||||
var attachments = [];
|
||||
const msg = MessageFactory.text("")
|
||||
var attachments = []
|
||||
|
||||
let data = await service.getSubjectItems(
|
||||
min.instance.instanceId,
|
||||
rootSubjectId
|
||||
);
|
||||
)
|
||||
|
||||
msg.attachmentLayout = "carousel";
|
||||
msg.attachmentLayout = "carousel"
|
||||
|
||||
data.forEach(function(item: GuaribasSubject) {
|
||||
var subject = item;
|
||||
var subject = item
|
||||
var card = CardFactory.heroCard(
|
||||
subject.title,
|
||||
CardFactory.images([
|
||||
|
@ -128,40 +128,40 @@ export class MenuDialog extends IGBDialog {
|
|||
})
|
||||
}
|
||||
])
|
||||
);
|
||||
)
|
||||
|
||||
attachments.push(card);
|
||||
});
|
||||
attachments.push(card)
|
||||
})
|
||||
|
||||
if (attachments.length == 0) {
|
||||
const user = min.userState.get(dc.context);
|
||||
const user = min.userState.get(dc.context)
|
||||
|
||||
if (user.subjects && user.subjects.length > 0) {
|
||||
await dc.context.sendActivity(
|
||||
Messages[locale].lets_search(
|
||||
KBService.getFormattedSubjectItems(user.subjects)
|
||||
)
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
await dc.replace("/ask", {});
|
||||
await dc.replace("/ask", {})
|
||||
} else {
|
||||
msg.attachments = attachments;
|
||||
await dc.context.sendActivity(msg);
|
||||
msg.attachments = attachments
|
||||
await dc.context.sendActivity(msg)
|
||||
}
|
||||
|
||||
const user = min.userState.get(dc.context);
|
||||
user.isAsking = true;
|
||||
const user = min.userState.get(dc.context)
|
||||
user.isAsking = true
|
||||
},
|
||||
async (dc, value) => {
|
||||
var text = value;
|
||||
const locale = dc.context.activity.locale;
|
||||
var text = value
|
||||
const locale = dc.context.activity.locale
|
||||
if (AzureText.isIntentNo(locale, text)) {
|
||||
await dc.replace("/feedback");
|
||||
await dc.replace("/feedback")
|
||||
} else {
|
||||
await dc.replace("/ask");
|
||||
await dc.replace("/ask")
|
||||
}
|
||||
}
|
||||
]);
|
||||
])
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue