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) {
|
private invokeLoadBot(appPackages: any[], min: any, server: any) {
|
||||||
appPackages.forEach(e => {
|
appPackages.forEach(e => {
|
||||||
e.sysPackages = new Array<IGBPackage>()
|
e.sysPackages = new Array<IGBPackage>();
|
||||||
|
|
||||||
|
// NOTE: A semicolon is necessary before this line.
|
||||||
|
|
||||||
[
|
[
|
||||||
GBAdminPackage,
|
GBAdminPackage,
|
||||||
|
@ -310,6 +312,11 @@ export class GBMinService {
|
||||||
await dc.continue()
|
await dc.continue()
|
||||||
}
|
}
|
||||||
} else if (context.activity.type === "event") {
|
} else if (context.activity.type === "event") {
|
||||||
|
|
||||||
|
// Empties dialog stack before going to the target.
|
||||||
|
|
||||||
|
await dc.endAll()
|
||||||
|
|
||||||
if (context.activity.name === "whoAmI") {
|
if (context.activity.name === "whoAmI") {
|
||||||
await dc.begin("/whoAmI")
|
await dc.begin("/whoAmI")
|
||||||
} else if (context.activity.name === "showSubjects") {
|
} else if (context.activity.name === "showSubjects") {
|
||||||
|
|
|
@ -57,11 +57,6 @@ export class MenuDialog extends IGBDialog {
|
||||||
async (dc, args) => {
|
async (dc, args) => {
|
||||||
var rootSubjectId = null
|
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) {
|
if (args && args.data) {
|
||||||
var subject = args.data
|
var subject = args.data
|
||||||
|
|
||||||
|
@ -73,10 +68,15 @@ export class MenuDialog extends IGBDialog {
|
||||||
await dc.end()
|
await dc.end()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Adds to bot a perception of a new subject.
|
||||||
|
|
||||||
const user = min.userState.get(dc.context)
|
const user = min.userState.get(dc.context)
|
||||||
user.subjects.push(subject)
|
user.subjects.push(subject)
|
||||||
rootSubjectId = subject.subjectId
|
rootSubjectId = subject.subjectId
|
||||||
|
|
||||||
|
// Whenever a subject is selected, shows a faq about it.
|
||||||
|
|
||||||
if (user.subjects.length > 0) {
|
if (user.subjects.length > 0) {
|
||||||
let data = await service.getFaqBySubjectArray("menu", user.subjects)
|
let data = await service.getFaqBySubjectArray("menu", user.subjects)
|
||||||
await min.conversationalService.sendEvent(dc, "play", {
|
await min.conversationalService.sendEvent(dc, "play", {
|
||||||
|
@ -135,6 +135,7 @@ export class MenuDialog extends IGBDialog {
|
||||||
|
|
||||||
if (attachments.length == 0) {
|
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) {
|
if (user.subjects && user.subjects.length > 0) {
|
||||||
await dc.context.sendActivity(
|
await dc.context.sendActivity(
|
||||||
`Vamos pesquisar sobre ${KBService.getFormattedSubjectItems(
|
`Vamos pesquisar sobre ${KBService.getFormattedSubjectItems(
|
||||||
|
|
|
@ -601,15 +601,17 @@ export class KBService {
|
||||||
async deployKb(core: IGBCoreService, deployer: GBDeployer, localPath: string) {
|
async deployKb(core: IGBCoreService, deployer: GBDeployer, localPath: string) {
|
||||||
let packageType = Path.extname(localPath)
|
let packageType = Path.extname(localPath)
|
||||||
let packageName = Path.basename(localPath)
|
let packageName = Path.basename(localPath)
|
||||||
logger.info("[GBDeployer] Opening package: ", localPath)
|
logger.info(`[GBDeployer] Opening package: ${localPath}`)
|
||||||
let packageObject = JSON.parse(
|
let packageObject = JSON.parse(
|
||||||
Fs.readFileSync(UrlJoin(localPath, "package.json"), "utf8")
|
Fs.readFileSync(UrlJoin(localPath, "package.json"), "utf8")
|
||||||
)
|
)
|
||||||
|
|
||||||
let instance = await core.loadInstance(packageObject.botId)
|
let instance = await core.loadInstance(packageObject.botId)
|
||||||
|
logger.info(`[GBDeployer] Beginning importing: ${localPath}`)
|
||||||
let p = await deployer.deployPackageToStorage(
|
let p = await deployer.deployPackageToStorage(
|
||||||
instance.instanceId,
|
instance.instanceId,
|
||||||
packageName)
|
packageName)
|
||||||
await this.importKbPackage(localPath, p, instance)
|
await this.importKbPackage(localPath, p, instance)
|
||||||
|
logger.info(`[GBDeployer] Finished importing ${localPath}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,10 @@ export class GBServer {
|
||||||
// Build a minimal bot instance for each .gbot deployment.
|
// Build a minimal bot instance for each .gbot deployment.
|
||||||
|
|
||||||
let conversationalService = new GBConversationalService(core)
|
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,
|
[GBAdminPackage, GBAnalyticsPackage, GBCorePackage, GBSecurityPackage,
|
||||||
GBKBPackage, GBCustomerSatisfactionPackage, GBWhatsappPackage].forEach(e => {
|
GBKBPackage, GBCustomerSatisfactionPackage, GBWhatsappPackage].forEach(e => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue