5
5
* Copyright (c) Microsoft Corporation. All rights reserved.
6
6
* Licensed under the MIT License.
7
7
*/
8
- import { SkillDialog , SkillDialogOptions , DialogContext , DialogTurnResult , DialogManager , BeginSkillDialogOptions } from 'botbuilder-dialogs' ;
8
+ import { SkillDialog , SkillDialogOptions , DialogContext , DialogTurnResult , BeginSkillDialogOptions } from 'botbuilder-dialogs' ;
9
9
import { BoolExpression , StringExpression } from 'adaptive-expressions' ;
10
+ import { Activity , ActivityTypes } from 'botbuilder-core' ;
10
11
import { TemplateInterface } from '../template' ;
11
- import { Activity , ActivityTypes , BotFrameworkClient , SkillConversationIdFactoryBase } from 'botbuilder-core' ;
12
-
13
- const SKILL_CLIENT = Symbol ( 'skillClient' ) ;
14
- const CONVERSATION_ID_FACTORY = Symbol ( 'conversationIdFactory' ) ;
12
+ import { skillClientKey , skillConversationIdFactoryKey } from '../skillExtensions' ;
15
13
16
14
export class BeginSkill extends SkillDialog {
17
15
@@ -87,14 +85,14 @@ export class BeginSkill extends SkillDialog {
87
85
// Setup the skill to call
88
86
const botId = this . botId . getValue ( dcState ) ;
89
87
const skillHostEndpoint = this . skillHostEndpoint . getValue ( dcState ) ;
90
- if ( botId ) { this . dialogOptions . botId = botId }
91
- if ( skillHostEndpoint ) { this . dialogOptions . skillHostEndpoint = skillHostEndpoint }
92
- if ( this . skillAppId ) { this . dialogOptions . skill . id = this . dialogOptions . skill . appId = this . skillAppId . getValue ( dcState ) }
93
- if ( this . skillEndpoint ) { this . dialogOptions . skill . skillEndpoint = this . skillEndpoint . getValue ( dcState ) }
94
- if ( this . connectionName ) { this . dialogOptions . connectionName = this . connectionName . getValue ( dcState ) }
95
- if ( ! this . dialogOptions . conversationState ) { this . dialogOptions . conversationState = dc . dialogManager . conversationState }
96
- if ( ! this . dialogOptions . skillClient ) { this . dialogOptions . skillClient = dc . context . turnState . get ( SKILL_CLIENT ) }
97
- if ( ! this . dialogOptions . conversationIdFactory ) { this . dialogOptions . conversationIdFactory = dc . context . turnState . get ( CONVERSATION_ID_FACTORY ) }
88
+ if ( botId ) { this . dialogOptions . botId = botId ; }
89
+ if ( skillHostEndpoint ) { this . dialogOptions . skillHostEndpoint = skillHostEndpoint ; }
90
+ if ( this . skillAppId ) { this . dialogOptions . skill . id = this . dialogOptions . skill . appId = this . skillAppId . getValue ( dcState ) ; }
91
+ if ( this . skillEndpoint ) { this . dialogOptions . skill . skillEndpoint = this . skillEndpoint . getValue ( dcState ) ; }
92
+ if ( this . connectionName ) { this . dialogOptions . connectionName = this . connectionName . getValue ( dcState ) ; }
93
+ if ( ! this . dialogOptions . conversationState ) { this . dialogOptions . conversationState = dc . dialogManager . conversationState ; }
94
+ if ( ! this . dialogOptions . skillClient ) { this . dialogOptions . skillClient = dc . context . turnState . get ( skillClientKey ) ; }
95
+ if ( ! this . dialogOptions . conversationIdFactory ) { this . dialogOptions . conversationIdFactory = dc . context . turnState . get ( skillConversationIdFactoryKey ) ; }
98
96
99
97
// Get the activity to send to the skill.
100
98
options = { } as BeginSkillDialogOptions ;
@@ -126,17 +124,6 @@ export class BeginSkill extends SkillDialog {
126
124
protected onComputeId ( ) : string {
127
125
const appId = this . skillAppId ? this . skillAppId . toString ( ) : '' ;
128
126
const activity = this . activity ? this . activity . toString ( ) : '<activity>' ;
129
- return `Skill[${ appId } :${ activity } ]` ;
130
- }
131
-
132
- /**
133
- * Configures the skill client and conversation ID factory to use.
134
- * @param dm DialogManager to configure.
135
- * @param skillClient Skill client instance to use.
136
- * @param conversationIdFactory Conversation ID factory to use.
137
- */
138
- static setSkillHostOptions ( dm : DialogManager , skillClient : BotFrameworkClient , conversationIdFactory : SkillConversationIdFactoryBase ) : void {
139
- dm . initialTurnState . set ( SKILL_CLIENT , skillClient ) ;
140
- dm . initialTurnState . set ( CONVERSATION_ID_FACTORY , conversationIdFactory ) ;
127
+ return `Skill[${ appId } :${ activity } ]` ;
141
128
}
142
129
}
0 commit comments