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

Commit cc50351

Browse files
David Favrettolauren-mills
authored andcommitted
Update populateStateFromSemanticAction method in Skill mainDialog (#2669)
1 parent 021e7b9 commit cc50351

File tree

2 files changed

+19
-16
lines changed
  • templates/Virtual-Assistant-Template/typescript
    • generator-botbuilder-assistant/generators/skill/templates/sample-skill/src/dialogs
    • samples/sample-skill/src/dialogs

2 files changed

+19
-16
lines changed

templates/Virtual-Assistant-Template/typescript/generator-botbuilder-assistant/generators/skill/templates/sample-skill/src/dialogs/_mainDialog.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -249,15 +249,16 @@ export class MainDialog extends RouterDialog {
249249
protected async populateStateFromSemanticAction(context: TurnContext): Promise<void> {
250250
// Example of populating local state with data passed through semanticAction out of Activity
251251
// const activity: Activity = context.activity;
252-
// const semanticAction: SemanticAction | undefined = activity.semanticAction;
253-
254-
// if (semanticAction != null && semanticAction.Entities.ContainsKey("location"))
255-
// {
256-
// var location = semanticAction.Entities["location"];
257-
// var locationObj = location.Properties["location"].ToString();
258-
// // Add to your local state
259-
// var state = await _stateAccessor.GetAsync(context, () => new SkillState());
260-
// state.CurrentCoordinates = locationObj;
252+
// const semanticAction: SemanticAction | undefined = activity.semanticAction;
253+
254+
// if (semanticAction !== undefined && Object.keys(semanticAction.entities)
255+
// .find((key: string) => key === "location")) {
256+
// // tslint:disable-next-line: no-explicit-any
257+
// const location: any = semanticAction.entities["location"];
258+
// const locationObj = location.properties["location"];
259+
// const state: SkillState = await this.stateAccessor.get(context, new SkillState());
260+
// state.location = locationObj !== undefined ? locationObj : location;
261+
// await this.stateAccessor.set(context, state);
261262
// }
262263
}
263264
}

templates/Virtual-Assistant-Template/typescript/samples/sample-skill/src/dialogs/mainDialog.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
RecognizerResult,
1212
// SemanticAction,
1313
StatePropertyAccessor,
14-
TurnContext} from 'botbuilder';
14+
TurnContext } from 'botbuilder';
1515
import { LuisRecognizer, LuisRecognizerTelemetryClient } from 'botbuilder-ai';
1616
import {
1717
Dialog,
@@ -251,12 +251,14 @@ export class MainDialog extends RouterDialog {
251251
// const activity: Activity = context.activity;
252252
// const semanticAction: SemanticAction | undefined = activity.semanticAction;
253253

254-
// if (semanticAction != null && semanticAction.Entities.ContainsKey("location"))
255-
// {
256-
// var location = semanticAction.Entities["location"];
257-
// var locationObj = location.Properties["location"].ToString();
258-
// var state = await _stateAccessor.GetAsync(context, () => new SkillState());
259-
// state.CurrentCoordinates = locationObj;
254+
// if (semanticAction !== undefined && Object.keys(semanticAction.entities)
255+
// .find((key: string) => key === "location")) {
256+
// // tslint:disable-next-line: no-explicit-any
257+
// const location: any = semanticAction.entities["location"];
258+
// const locationObj = location.properties["location"];
259+
// const state: SkillState = await this.stateAccessor.get(context, new SkillState());
260+
// state.location = locationObj !== undefined ? locationObj : location;
261+
// await this.stateAccessor.set(context, state);
260262
// }
261263
}
262264
}

0 commit comments

Comments
 (0)