Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.

Commit aca3941

Browse files
authored
[TypeScript][Virtual Assistant] Handle versionChanged event adding onDialogEvent method (#3417)
* Handle versionChanged event adding onDialogEVent method * Add comment explaining the version change default behavior
1 parent 6154a04 commit aca3941

File tree

2 files changed

+26
-2
lines changed
  • templates/typescript
    • generator-bot-virtualassistant/generators/app/templates/sample-assistant/src/dialogs
    • samples/sample-assistant/src/dialogs

2 files changed

+26
-2
lines changed

templates/typescript/generator-bot-virtualassistant/generators/app/templates/sample-assistant/src/dialogs/mainDialog.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ import {
2222
SkillDialog,
2323
PromptOptions,
2424
WaterfallDialog,
25-
BeginSkillDialogOptions} from 'botbuilder-dialogs';
25+
BeginSkillDialogOptions,
26+
DialogEvent,
27+
DialogEvents } from 'botbuilder-dialogs';
2628
import {
2729
DialogContextEx,
2830
ICognitiveModelSet,
@@ -100,6 +102,16 @@ export class MainDialog extends ComponentDialog {
100102
});
101103
}
102104

105+
public async onDialogEvent(dialogContext: DialogContext, event: DialogEvent): Promise<boolean> {
106+
// BF SDK now detects state changes in dialogs and surfaces them for confirmation.
107+
// Returning true as this is an expected situation due to dynamic dialog construction for QnA multi-locale scenarios.
108+
if(event.name === DialogEvents.versionChanged) {
109+
return true;
110+
}
111+
112+
return await super.onDialogEvent(dialogContext, event);
113+
}
114+
103115
protected async onBeginDialog(innerDc: DialogContext, options: Object): Promise<DialogTurnResult> {
104116
if (innerDc.context.activity.type === ActivityTypes.Message) {
105117
// Get cognitive models for the current locale.

templates/typescript/samples/sample-assistant/src/dialogs/mainDialog.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ import {
2222
SkillDialog,
2323
PromptOptions,
2424
WaterfallDialog,
25-
BeginSkillDialogOptions} from 'botbuilder-dialogs';
25+
BeginSkillDialogOptions,
26+
DialogEvent,
27+
DialogEvents } from 'botbuilder-dialogs';
2628
import {
2729
DialogContextEx,
2830
ICognitiveModelSet,
@@ -100,6 +102,16 @@ export class MainDialog extends ComponentDialog {
100102
});
101103
}
102104

105+
public async onDialogEvent(dialogContext: DialogContext, event: DialogEvent): Promise<boolean> {
106+
// BF SDK now detects state changes in dialogs and surfaces them for confirmation.
107+
// Returning true as this is an expected situation due to dynamic dialog construction for QnA multi-locale scenarios.
108+
if(event.name === DialogEvents.versionChanged) {
109+
return true;
110+
}
111+
112+
return await super.onDialogEvent(dialogContext, event);
113+
}
114+
103115
protected async onBeginDialog(innerDc: DialogContext, options: Object): Promise<DialogTurnResult> {
104116
if (innerDc.context.activity.type === ActivityTypes.Message) {
105117
// Get cognitive models for the current locale.

0 commit comments

Comments
 (0)