Now context is correctly reset when coming from menu.
This commit is contained in:
parent
81dafca36e
commit
18200e8ea1
4 changed files with 22 additions and 9 deletions
|
@ -226,7 +226,9 @@ export class GBMinService {
|
|||
|
||||
private invokeLoadBot(appPackages: any[], min: any, server: any) {
|
||||
appPackages.forEach(e => {
|
||||
e.sysPackages = new Array<IGBPackage>()
|
||||
e.sysPackages = new Array<IGBPackage>();
|
||||
|
||||
// NOTE: A semicolon is necessary before this line.
|
||||
|
||||
[
|
||||
GBAdminPackage,
|
||||
|
@ -310,6 +312,11 @@ export class GBMinService {
|
|||
await dc.continue()
|
||||
}
|
||||
} else if (context.activity.type === "event") {
|
||||
|
||||
// Empties dialog stack before going to the target.
|
||||
|
||||
await dc.endAll()
|
||||
|
||||
if (context.activity.name === "whoAmI") {
|
||||
await dc.begin("/whoAmI")
|
||||
} else if (context.activity.name === "showSubjects") {
|
||||
|
|
|
@ -57,11 +57,6 @@ export class MenuDialog extends IGBDialog {
|
|||
async (dc, args) => {
|
||||
var rootSubjectId = null
|
||||
|
||||
// var msg = dc.message TODO: message from Where in V4?
|
||||
// if (msg.attachments && msg.attachments.length > 0) {
|
||||
// var attachment = msg.attachments[0]
|
||||
// }
|
||||
|
||||
if (args && args.data) {
|
||||
var subject = args.data
|
||||
|
||||
|
@ -73,10 +68,15 @@ export class MenuDialog extends IGBDialog {
|
|||
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
|
||||
|
||||
// Whenever a subject is selected, shows a faq about it.
|
||||
|
||||
if (user.subjects.length > 0) {
|
||||
let data = await service.getFaqBySubjectArray("menu", user.subjects)
|
||||
await min.conversationalService.sendEvent(dc, "play", {
|
||||
|
@ -135,6 +135,7 @@ export class MenuDialog extends IGBDialog {
|
|||
|
||||
if (attachments.length == 0) {
|
||||
const user = min.userState.get(dc.context)
|
||||
|
||||
if (user.subjects && user.subjects.length > 0) {
|
||||
await dc.context.sendActivity(
|
||||
`Vamos pesquisar sobre ${KBService.getFormattedSubjectItems(
|
||||
|
|
|
@ -601,15 +601,17 @@ export class KBService {
|
|||
async deployKb(core: IGBCoreService, deployer: GBDeployer, localPath: string) {
|
||||
let packageType = Path.extname(localPath)
|
||||
let packageName = Path.basename(localPath)
|
||||
logger.info("[GBDeployer] Opening package: ", localPath)
|
||||
logger.info(`[GBDeployer] Opening package: ${localPath}`)
|
||||
let packageObject = JSON.parse(
|
||||
Fs.readFileSync(UrlJoin(localPath, "package.json"), "utf8")
|
||||
)
|
||||
|
||||
let instance = await core.loadInstance(packageObject.botId)
|
||||
logger.info(`[GBDeployer] Beginning importing: ${localPath}`)
|
||||
let p = await deployer.deployPackageToStorage(
|
||||
instance.instanceId,
|
||||
packageName)
|
||||
await this.importKbPackage(localPath, p, instance)
|
||||
logger.info(`[GBDeployer] Finished importing ${localPath}`)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,9 +96,12 @@ export class GBServer {
|
|||
let deployer = new GBDeployer(core, new GBImporter(core))
|
||||
|
||||
// Build a minimal bot instance for each .gbot deployment.
|
||||
|
||||
|
||||
let conversationalService = new GBConversationalService(core)
|
||||
let minService = new GBMinService(core, conversationalService, deployer)
|
||||
let minService = new GBMinService(core, conversationalService, deployer);
|
||||
|
||||
// NOTE: the semicolon is necessary before this line.
|
||||
// Loads all system packages.
|
||||
|
||||
[GBAdminPackage, GBAnalyticsPackage, GBCorePackage, GBSecurityPackage,
|
||||
GBKBPackage, GBCustomerSatisfactionPackage, GBWhatsappPackage].forEach(e => {
|
||||
|
|
Loading…
Add table
Reference in a new issue