QnAMakerDialog class
A dialog that supports multi-step and adaptive-learning QnA Maker services.
- Extends
-
WaterfallDialog
Constructors
Properties
| $kind | |
| active |
Gets or sets the card title to use when showing active learning options to the user. Note: If suggestionsActivityFactory is passed in, this member is unused. |
| card |
Gets or sets the template to send to the user if they select the no match option on an active learning card. |
| card |
Gets or sets the button text to use with active learning options, allowing a user to indicate non of the options are applicable. Note: If suggestionsActivityFactory is passed in, this member is required. |
| display |
Gets or sets a value indicating whether the dialog response should display only precise answers. |
| enable |
Gets or sets a value indicating whether to include precise answer in response. |
| endpoint |
Gets or sets the QnA Maker endpoint key to use to query the knowledge base. |
| filters | Gets or sets the metadata and sources used to filter results. |
| hostname | Gets or sets the QnA Maker host URL for the knowledge base. |
| include |
Gets or sets a value indicating whether to include unstructured sources in search for answers. |
| is |
Gets or sets a value indicating whether gets or sets environment of knowledgebase to be called. |
| knowledge |
Gets or sets the QnA Maker knowledge base ID to query. |
| log |
Gets or sets the flag to determine if personal information should be logged in telemetry. |
| no |
Gets or sets the template to send to the user when QnA Maker does not find an answer. |
| qna |
Question answering service type - qnaMaker or language |
| ranker |
Gets or sets the QnA Maker ranker type to use. |
| strict |
Gets or sets the QnA Maker metadata with which to filter or boost queries to the knowledge base, or null to apply none. |
| strict |
Gets or sets a value - AND or OR - logical operation on list of metadata |
| threshold | Gets or sets the threshold for answers returned, based on score. |
| top | Gets or sets the maximum number of answers to return from the knowledge base. |
Inherited Properties
| End |
Gets a default end-of-turn result. |
| id | |
| telemetry |
Methods
| begin |
Called when the dialog is started and pushed onto the dialog stack. |
| continue |
Called when the dialog is continued, where it is the active dialog and the user replies with a new Activity. |
| get |
Inherited Methods
| add |
Adds a new step to the waterfall. |
| configure(Record<string, unknown>) | Fluent method for configuring the object. |
| end |
Called when the dialog is ending. |
| get |
Gets the dialog version, composed of the ID and number of steps. |
| on |
Called when an event has been raised, using |
| reprompt |
When overridden in a derived class, reprompts the user for input. |
| resume |
Called when a child WaterfallDialog completed its turn, returning control to this dialog. |
Constructor Details
QnAMakerDialog(string, string, string, Activity, number, QnASuggestionsActivityFactory, string, number, Activity, RankerTypes, QnAMakerMetadata[], string, JoinOperator, boolean, boolean, ServiceType)
Initializes a new instance of the QnAMakerDialog class.
new QnAMakerDialog(knowledgeBaseId?: string, endpointKey?: string, hostname?: string, noAnswer?: Activity, threshold?: number, suggestionsActivityFactory?: QnASuggestionsActivityFactory, cardNoMatchText?: string, top?: number, cardNoMatchResponse?: Activity, rankerType?: RankerTypes, strictFilters?: QnAMakerMetadata[], dialogId?: string, strictFiltersJoinOperator?: JoinOperator, enablePreciseAnswer?: boolean, displayPreciseAnswerOnly?: boolean, qnaServiceType?: ServiceType)
Parameters
- knowledgeBaseId
-
string
The ID of the QnA Maker knowledge base to query.
- endpointKey
-
string
The QnA Maker endpoint key to use to query the knowledge base.
- hostname
-
string
The QnA Maker host URL for the knowledge base, starting with "https://" and ending with "/qnamaker".
- noAnswer
-
Activity
(Optional) The activity to send the user when QnA Maker does not find an answer.
- threshold
-
number
(Optional) The threshold above which to treat answers found from the knowledgebase as a match.
- suggestionsActivityFactory
- QnASuggestionsActivityFactory
(xref:botbuilder-ai.QnASuggestionsActivityFactory) used for custom Activity formatting.
- cardNoMatchText
-
string
(Optional) The button text to use with active learning options, allowing a user to indicate none of the options are applicable.
- top
-
number
(Optional) Maximum number of answers to return from the knowledge base.
- cardNoMatchResponse
-
Activity
(Optional) The activity to send the user if they select the no match option on an active learning card.
- rankerType
- RankerTypes
- strictFilters
(Optional) QnA Maker metadata with which to filter or boost queries to the knowledge base; or null to apply none.
- dialogId
-
string
(Optional) Id of the created dialog. Default is 'QnAMakerDialog'.
- strictFiltersJoinOperator
- JoinOperator
join operator for strict filters
- enablePreciseAnswer
-
boolean
- displayPreciseAnswerOnly
-
boolean
- qnaServiceType
- ServiceType
QnAMakerDialog(string, string, string, Activity, number, string, string, number, Activity, RankerTypes, QnAMakerMetadata[], string, JoinOperator, boolean, boolean, ServiceType)
Initializes a new instance of the QnAMakerDialog class.
new QnAMakerDialog(knowledgeBaseId?: string, endpointKey?: string, hostname?: string, noAnswer?: Activity, threshold?: number, activeLearningCardTitle?: string, cardNoMatchText?: string, top?: number, cardNoMatchResponse?: Activity, rankerType?: RankerTypes, strictFilters?: QnAMakerMetadata[], dialogId?: string, strictFiltersJoinOperator?: JoinOperator, enablePreciseAnswer?: boolean, displayPreciseAnswerOnly?: boolean, qnaServiceType?: ServiceType)
Parameters
- knowledgeBaseId
-
string
The ID of the QnA Maker knowledge base to query.
- endpointKey
-
string
The QnA Maker endpoint key to use to query the knowledge base.
- hostname
-
string
The QnA Maker host URL for the knowledge base, starting with "https://" and ending with "/qnamaker".
- noAnswer
-
Activity
(Optional) The activity to send the user when QnA Maker does not find an answer.
- threshold
-
number
(Optional) The threshold above which to treat answers found from the knowledgebase as a match.
- activeLearningCardTitle
-
string
(Optional) The card title to use when showing active learning options to the user, if active learning is enabled.
- cardNoMatchText
-
string
(Optional) The button text to use with active learning options, allowing a user to indicate none of the options are applicable.
- top
-
number
(Optional) Maximum number of answers to return from the knowledge base.
- cardNoMatchResponse
-
Activity
(Optional) The activity to send the user if they select the no match option on an active learning card.
- rankerType
- RankerTypes
- strictFilters
(Optional) QnA Maker metadata with which to filter or boost queries to the knowledge base; or null to apply none.
- dialogId
-
string
(Optional) Id of the created dialog. Default is 'QnAMakerDialog'.
- strictFiltersJoinOperator
- JoinOperator
join operator for strict filters
- enablePreciseAnswer
-
boolean
- displayPreciseAnswerOnly
-
boolean
- qnaServiceType
- ServiceType
Property Details
$kind
static $kind: string
Property Value
string
activeLearningCardTitle
Gets or sets the card title to use when showing active learning options to the user. Note: If suggestionsActivityFactory is passed in, this member is unused.
activeLearningCardTitle: StringExpression
Property Value
StringExpression
cardNoMatchResponse
Gets or sets the template to send to the user if they select the no match option on an active learning card.
cardNoMatchResponse: TemplateInterface<Partial<Activity>, DialogStateManager>
Property Value
TemplateInterface<Partial<Activity>, DialogStateManager>
cardNoMatchText
Gets or sets the button text to use with active learning options, allowing a user to indicate non of the options are applicable. Note: If suggestionsActivityFactory is passed in, this member is required.
cardNoMatchText: StringExpression
Property Value
StringExpression
displayPreciseAnswerOnly
Gets or sets a value indicating whether the dialog response should display only precise answers.
displayPreciseAnswerOnly: boolean
Property Value
boolean
enablePreciseAnswer
Gets or sets a value indicating whether to include precise answer in response.
enablePreciseAnswer: boolean
Property Value
boolean
endpointKey
Gets or sets the QnA Maker endpoint key to use to query the knowledge base.
endpointKey: StringExpression
Property Value
StringExpression
filters
Gets or sets the metadata and sources used to filter results.
filters: Filters
Property Value
hostname
Gets or sets the QnA Maker host URL for the knowledge base.
hostname: StringExpression
Property Value
StringExpression
includeUnstructuredSources
Gets or sets a value indicating whether to include unstructured sources in search for answers.
includeUnstructuredSources: boolean
Property Value
boolean
isTest
Gets or sets a value indicating whether gets or sets environment of knowledgebase to be called.
isTest: boolean
Property Value
boolean
knowledgeBaseId
Gets or sets the QnA Maker knowledge base ID to query.
knowledgeBaseId: StringExpression
Property Value
StringExpression
logPersonalInformation
Gets or sets the flag to determine if personal information should be logged in telemetry.
logPersonalInformation: BoolExpression
Property Value
BoolExpression
noAnswer
Gets or sets the template to send to the user when QnA Maker does not find an answer.
noAnswer: TemplateInterface<Partial<Activity>, DialogStateManager>
Property Value
TemplateInterface<Partial<Activity>, DialogStateManager>
qnaServiceType
Question answering service type - qnaMaker or language
qnaServiceType: ServiceType
Property Value
rankerType
Gets or sets the QnA Maker ranker type to use.
rankerType: EnumExpression<RankerTypes>
Property Value
EnumExpression<RankerTypes>
strictFilters
Gets or sets the QnA Maker metadata with which to filter or boost queries to the knowledge base, or null to apply none.
strictFilters: QnAMakerMetadata[]
Property Value
strictFiltersJoinOperator
Gets or sets a value - AND or OR - logical operation on list of metadata
strictFiltersJoinOperator: JoinOperator
Property Value
threshold
Gets or sets the threshold for answers returned, based on score.
threshold: NumberExpression
Property Value
NumberExpression
top
Gets or sets the maximum number of answers to return from the knowledge base.
top: IntExpression
Property Value
IntExpression
Inherited Property Details
EndOfTurn
Gets a default end-of-turn result.
static EndOfTurn: DialogTurnResult
Property Value
DialogTurnResult
Remarks
This result indicates that a dialog (or a logical step within a dialog) has completed processing for the current turn, is still active, and is waiting for more input.
Inherited From Dialog.EndOfTurn
id
id: string
Property Value
string
Inherited From Dialog.id
telemetryClient
telemetryClient: BotTelemetryClient
Property Value
BotTelemetryClient
Inherited From Dialog.telemetryClient
Method Details
beginDialog(DialogContext, object)
Called when the dialog is started and pushed onto the dialog stack.
function beginDialog(dc: DialogContext, options?: object): Promise<DialogTurnResult>
Parameters
- dc
-
DialogContext
The DialogContext for the current turn of conversation.
- options
-
object
(Optional) Initial information to pass to the dialog.
Returns
Promise<DialogTurnResult>
A promise resolving to the turn result
continueDialog(DialogContext)
Called when the dialog is continued, where it is the active dialog and the user replies with a new Activity.
function continueDialog(dc: DialogContext): Promise<DialogTurnResult>
Parameters
- dc
-
DialogContext
The DialogContext for the current turn of conversation.
Returns
Promise<DialogTurnResult>
A Promise representing the asynchronous operation.
getConverter(Object)
function getConverter(property: Object): Converter | ConverterFactory
Parameters
- property
-
Object
Properties that extend QnAMakerDialogConfiguration.
Returns
Converter | ConverterFactory
The expression converter.
Inherited Method Details
addStep(WaterfallStep<O>)
Adds a new step to the waterfall.
function addStep(step: WaterfallStep<O>): this
Parameters
- step
-
WaterfallStep<O>
Asynchronous step function to call.
Returns
this
Waterfall dialog for fluent calls to addStep().
Remarks
All step functions should be asynchronous and return a DialogTurnResult. The
WaterfallStepContext passed into your function derives from DialogContext and contains
numerous stack manipulation methods which return a DialogTurnResult so you can typically
just return the result from the DialogContext method you call.
The step function itself can be either an asynchronous closure:
const helloDialog = new WaterfallDialog('hello');
helloDialog.addStep(async (step) => {
await step.context.sendActivity(`Hello World!`);
return await step.endDialog();
});
A named async function:
async function helloWorldStep(step) {
await step.context.sendActivity(`Hello World!`);
return await step.endDialog();
}
helloDialog.addStep(helloWorldStep);
Or a class method that's been bound to its this pointer:
helloDialog.addStep(this.helloWorldStep.bind(this));
Inherited From WaterfallDialog.addStep
configure(Record<string, unknown>)
Fluent method for configuring the object.
function configure(config: Record<string, unknown>): this
Parameters
- config
-
Record<string, unknown>
Configuration settings to apply.
Returns
this
The Configurable after the operation is complete.
Inherited From Configurable.configure
endDialog(TurnContext, DialogInstance, DialogReason)
Called when the dialog is ending.
function endDialog(context: TurnContext, instance: DialogInstance, reason: DialogReason): Promise<void>
Parameters
- context
-
TurnContext
Context for the current turn of conversation.
- instance
-
DialogInstance
The instance of the current dialog.
- reason
-
DialogReason
The reason the dialog is ending.
Returns
Promise<void>
Inherited From WaterfallDialog.endDialog
getVersion()
Gets the dialog version, composed of the ID and number of steps.
function getVersion(): string
Returns
string
Dialog version, composed of the ID and number of steps.
Inherited From WaterfallDialog.getVersion
onDialogEvent(DialogContext, DialogEvent)
Called when an event has been raised, using DialogContext.emitEvent(), by either the current dialog or a dialog that the current dialog started.
function onDialogEvent(dc: DialogContext, e: DialogEvent): Promise<boolean>
Parameters
- dc
-
DialogContext
The dialog context for the current turn of conversation.
- e
-
DialogEvent
The event being raised.
Returns
Promise<boolean>
True if the event is handled by the current dialog and bubbling should stop.
Inherited From Dialog.onDialogEvent
repromptDialog(TurnContext, DialogInstance)
When overridden in a derived class, reprompts the user for input.
function repromptDialog(_context: TurnContext, _instance: DialogInstance): Promise<void>
Parameters
- _context
-
TurnContext
The context object for the turn.
- _instance
-
DialogInstance
Current state information for this dialog.
Returns
Promise<void>
Remarks
Derived dialogs that support validation and re-prompt logic should override this method. By default, this method has no effect.
The DialogContext calls this method when the current dialog should re-request input from the user. This method is implemented for prompt dialogs.
See also
Inherited From Dialog.repromptDialog
resumeDialog(DialogContext, DialogReason, any)
Called when a child WaterfallDialog completed its turn, returning control to this dialog.
function resumeDialog(dc: DialogContext, reason: DialogReason, result?: any): Promise<DialogTurnResult>
Parameters
- dc
-
DialogContext
The DialogContext for the current turn of the conversation.
- reason
-
DialogReason
(xref:botbuilder-dialogs.DialogReason) why the dialog resumed.
- result
-
any
Optional, value returned from the dialog that was called. The type of the value returned is dependent on the child dialog.
Returns
Promise<DialogTurnResult>
A Promise representing the asynchronous operation.
Inherited From WaterfallDialog.resumeDialog