|
| 1 | +**[Bot Builder SDK - AI](../README.md)** |
| 2 | + |
| 3 | +> [Globals](undefined) / [botbuilder-ai](../README.md) / CustomQuestionAnswering |
| 4 | +
|
| 5 | +# Class: CustomQuestionAnswering |
| 6 | + |
| 7 | +Query a Custom Question Answering knowledge base for answers and provide feedbacks. |
| 8 | + |
| 9 | +**`summary`** |
| 10 | +This class is used to make queries to a single QnA Maker knowledge base and return the result. |
| 11 | + |
| 12 | +Use this to process incoming messages with the [getAnswers()](#getAnswers) method. |
| 13 | + |
| 14 | +## Hierarchy |
| 15 | + |
| 16 | +* **CustomQuestionAnswering** |
| 17 | + |
| 18 | +## Implements |
| 19 | + |
| 20 | +* [QnAMakerClient](../interfaces/botbuilder_ai.qnamakerclient-1.md) |
| 21 | +* [QnAMakerTelemetryClient](../interfaces/botbuilder_ai.qnamakertelemetryclient-1.md) |
| 22 | + |
| 23 | +## Index |
| 24 | + |
| 25 | +### Constructors |
| 26 | + |
| 27 | +* [constructor](botbuilder_ai.customquestionanswering.md#constructor) |
| 28 | + |
| 29 | +### Accessors |
| 30 | + |
| 31 | +* [logPersonalInformation](botbuilder_ai.customquestionanswering.md#logpersonalinformation) |
| 32 | +* [telemetryClient](botbuilder_ai.customquestionanswering.md#telemetryclient) |
| 33 | + |
| 34 | +### Methods |
| 35 | + |
| 36 | +* [callTrain](botbuilder_ai.customquestionanswering.md#calltrain) |
| 37 | +* [fillQnAEvent](botbuilder_ai.customquestionanswering.md#fillqnaevent) |
| 38 | +* [getAnswers](botbuilder_ai.customquestionanswering.md#getanswers) |
| 39 | +* [getAnswersRaw](botbuilder_ai.customquestionanswering.md#getanswersraw) |
| 40 | +* [getKnowledgebaseAnswersRaw](botbuilder_ai.customquestionanswering.md#getknowledgebaseanswersraw) |
| 41 | +* [getLowScoreVariation](botbuilder_ai.customquestionanswering.md#getlowscorevariation) |
| 42 | +* [onQnaResults](botbuilder_ai.customquestionanswering.md#onqnaresults) |
| 43 | + |
| 44 | +## Constructors |
| 45 | + |
| 46 | +### constructor |
| 47 | + |
| 48 | +\+ **new CustomQuestionAnswering**(`endpoint`: QnAMakerEndpoint, `options?`: QnAMakerOptions, `telemetryClient?`: BotTelemetryClient, `logPersonalInformation?`: boolean): [CustomQuestionAnswering](botbuilder_ai.customquestionanswering.md) |
| 49 | + |
| 50 | +*Defined in libraries/botbuilder-ai/lib/customQuestionAnswering.d.ts:98* |
| 51 | + |
| 52 | +Creates a new CustomQuestionAnswering instance. |
| 53 | + |
| 54 | +#### Parameters: |
| 55 | + |
| 56 | +Name | Type | Description | |
| 57 | +------ | ------ | ------ | |
| 58 | +`endpoint` | QnAMakerEndpoint | The endpoint of the knowledge base to query. | |
| 59 | +`options?` | QnAMakerOptions | (Optional) additional settings used to configure the instance. | |
| 60 | +`telemetryClient?` | BotTelemetryClient | The BotTelemetryClient used for logging telemetry events. | |
| 61 | +`logPersonalInformation?` | boolean | Set to true to include personally indentifiable information in telemetry events. | |
| 62 | + |
| 63 | +**Returns:** [CustomQuestionAnswering](botbuilder_ai.customquestionanswering.md) |
| 64 | + |
| 65 | +## Accessors |
| 66 | + |
| 67 | +### logPersonalInformation |
| 68 | + |
| 69 | +• get **logPersonalInformation**(): boolean |
| 70 | + |
| 71 | +*Defined in libraries/botbuilder-ai/lib/customQuestionAnswering.d.ts:113* |
| 72 | + |
| 73 | +Gets a value indicating whether determines whether to log personal information that came from the user. |
| 74 | + |
| 75 | +**Returns:** boolean |
| 76 | + |
| 77 | +True to determine whether to log personal information that came from the user; otherwise, false. |
| 78 | + |
| 79 | +___ |
| 80 | + |
| 81 | +### telemetryClient |
| 82 | + |
| 83 | +• get **telemetryClient**(): BotTelemetryClient |
| 84 | + |
| 85 | +*Defined in libraries/botbuilder-ai/lib/customQuestionAnswering.d.ts:119* |
| 86 | + |
| 87 | +Gets the currently configured BotTelemetryClient that logs the events. |
| 88 | + |
| 89 | +**Returns:** BotTelemetryClient |
| 90 | + |
| 91 | +Currently configured BotTelemetryClient that logs the events. |
| 92 | + |
| 93 | +## Methods |
| 94 | + |
| 95 | +### callTrain |
| 96 | + |
| 97 | +▸ **callTrain**(`feedbackRecords`: FeedbackRecords): Promise\<void> |
| 98 | + |
| 99 | +*Implementation of [QnAMakerClient](../interfaces/botbuilder_ai.qnamakerclient-1.md)* |
| 100 | + |
| 101 | +*Defined in libraries/botbuilder-ai/lib/customQuestionAnswering.d.ts:183* |
| 102 | + |
| 103 | +Send feedback to the knowledge base. |
| 104 | + |
| 105 | +#### Parameters: |
| 106 | + |
| 107 | +Name | Type | Description | |
| 108 | +------ | ------ | ------ | |
| 109 | +`feedbackRecords` | FeedbackRecords | FeedbackRecords for Active Learning. | |
| 110 | + |
| 111 | +**Returns:** Promise\<void> |
| 112 | + |
| 113 | +A promise representing the async operation. |
| 114 | + |
| 115 | +___ |
| 116 | + |
| 117 | +### fillQnAEvent |
| 118 | + |
| 119 | +▸ `Protected`**fillQnAEvent**(`qnaResults`: QnAMakerResult[], `turnContext`: TurnContext, `telemetryProperties?`: Record\<string, string>, `telemetryMetrics?`: Record\<string, number>): Promise\<[Record\<string, string>, Record\<string, number>]> |
| 120 | + |
| 121 | +*Defined in libraries/botbuilder-ai/lib/customQuestionAnswering.d.ts:208* |
| 122 | + |
| 123 | +Fills the event properties for QnaMessage event for telemetry. |
| 124 | +These properties are logged when the recognizer is called. |
| 125 | + |
| 126 | +#### Parameters: |
| 127 | + |
| 128 | +Name | Type | Description | |
| 129 | +------ | ------ | ------ | |
| 130 | +`qnaResults` | QnAMakerResult[] | Last activity sent from user. | |
| 131 | +`turnContext` | TurnContext | Context object containing information for a single turn of conversation with a user. | |
| 132 | +`telemetryProperties?` | Record\<string, string> | Additional properties to be logged to telemetry with the QnaMessage event. | |
| 133 | +`telemetryMetrics?` | Record\<string, number> | Additional properties to be logged to telemetry with the QnaMessage event. | |
| 134 | + |
| 135 | +**Returns:** Promise\<[Record\<string, string>, Record\<string, number>]> |
| 136 | + |
| 137 | +A dictionary that is sent as properties to BotTelemetryClient.trackEvent method for the QnaMessage event. |
| 138 | + |
| 139 | +___ |
| 140 | + |
| 141 | +### getAnswers |
| 142 | + |
| 143 | +▸ **getAnswers**(`context`: TurnContext, `options?`: QnAMakerOptions, `telemetryProperties?`: { [key:string]: string; }, `telemetryMetrics?`: { [key:string]: number; }): Promise\<QnAMakerResult[]> |
| 144 | + |
| 145 | +*Defined in libraries/botbuilder-ai/lib/customQuestionAnswering.d.ts:135* |
| 146 | + |
| 147 | +Calls the Language service to generate answer(s) for a question. |
| 148 | + |
| 149 | +**`summary`** |
| 150 | +Returns an array of answers sorted by score with the top scoring answer returned first. |
| 151 | + |
| 152 | +In addition to returning the results from Language service, [getAnswers()](#getAnswers) will also |
| 153 | +emit a trace activity that contains the query results. |
| 154 | + |
| 155 | +#### Parameters: |
| 156 | + |
| 157 | +Name | Type | Description | |
| 158 | +------ | ------ | ------ | |
| 159 | +`context` | TurnContext | The Turn Context that contains the user question to be queried against your knowledge base. | |
| 160 | +`options?` | QnAMakerOptions | (Optional) The options for the Custom Question Answering knowledge base. If null, constructor option is used for this instance. | |
| 161 | +`telemetryProperties?` | { [key:string]: string; } | Additional properties to be logged to telemetry with the QnaMessage event. | |
| 162 | +`telemetryMetrics?` | { [key:string]: number; } | Additional metrics to be logged to telemetry with the QnaMessage event. | |
| 163 | + |
| 164 | +**Returns:** Promise\<QnAMakerResult[]> |
| 165 | + |
| 166 | +A promise resolving to the QnAMaker result |
| 167 | + |
| 168 | +___ |
| 169 | + |
| 170 | +### getAnswersRaw |
| 171 | + |
| 172 | +▸ **getAnswersRaw**(`context`: TurnContext, `options`: QnAMakerOptions, `telemetryProperties`: { [key:string]: string; }, `telemetryMetrics`: { [key:string]: number; }): Promise\<QnAMakerResults> |
| 173 | + |
| 174 | +*Defined in libraries/botbuilder-ai/lib/customQuestionAnswering.d.ts:149* |
| 175 | + |
| 176 | +Generates an answer from the knowledge base. |
| 177 | + |
| 178 | +#### Parameters: |
| 179 | + |
| 180 | +Name | Type | Description | |
| 181 | +------ | ------ | ------ | |
| 182 | +`context` | TurnContext | The [TurnContext](xref:botbuilder-core.TurnContext) that contains the user question to be queried against your knowledge base. | |
| 183 | +`options` | QnAMakerOptions | Optional. The [QnAMakerOptions](xref:botbuilder-ai.QnAMakerOptions) for the Custom Question Answering knowledge base. If null, constructor option is used for this instance. | |
| 184 | +`telemetryProperties` | { [key:string]: string; } | Optional. Additional properties to be logged to telemetry with the QnaMessage event. | |
| 185 | +`telemetryMetrics` | { [key:string]: number; } | Optional. Additional metrics to be logged to telemetry with the QnaMessage event. | |
| 186 | + |
| 187 | +**Returns:** Promise\<QnAMakerResults> |
| 188 | + |
| 189 | +A list of answers for the user query, sorted in decreasing order of ranking score. |
| 190 | + |
| 191 | +___ |
| 192 | + |
| 193 | +### getKnowledgebaseAnswersRaw |
| 194 | + |
| 195 | +▸ **getKnowledgebaseAnswersRaw**(`context`: TurnContext, `options`: QnAMakerOptions, `telemetryProperties`: { [key:string]: string; }, `telemetryMetrics`: { [key:string]: number; }): Promise\<QnAMakerResults> |
| 196 | + |
| 197 | +*Defined in libraries/botbuilder-ai/lib/customQuestionAnswering.d.ts:163* |
| 198 | + |
| 199 | +Queries for answers from the Language Service project's knowledge base. |
| 200 | + |
| 201 | +#### Parameters: |
| 202 | + |
| 203 | +Name | Type | Description | |
| 204 | +------ | ------ | ------ | |
| 205 | +`context` | TurnContext | The [TurnContext](xref:botbuilder-core.TurnContext) that contains the user question to be queried against your knowledge base. | |
| 206 | +`options` | QnAMakerOptions | Optional. The [QnAMakerOptions](xref:botbuilder-ai.QnAMakerOptions) for the Language Service project's knowledge base. If null, constructor option is used for this instance. | |
| 207 | +`telemetryProperties` | { [key:string]: string; } | Optional. Additional properties to be logged to telemetry with the QnaMessage event. | |
| 208 | +`telemetryMetrics` | { [key:string]: number; } | Optional. Additional metrics to be logged to telemetry with the QnaMessage event. | |
| 209 | + |
| 210 | +**Returns:** Promise\<QnAMakerResults> |
| 211 | + |
| 212 | +A list of answers for the user query, sorted in decreasing order of ranking score. |
| 213 | + |
| 214 | +___ |
| 215 | + |
| 216 | +### getLowScoreVariation |
| 217 | + |
| 218 | +▸ **getLowScoreVariation**(`queryResult`: QnAMakerResult[]): QnAMakerResult[] |
| 219 | + |
| 220 | +*Implementation of [QnAMakerClient](../interfaces/botbuilder_ai.qnamakerclient-1.md)* |
| 221 | + |
| 222 | +*Defined in libraries/botbuilder-ai/lib/customQuestionAnswering.d.ts:176* |
| 223 | + |
| 224 | +Filters the ambiguous question for active learning. |
| 225 | + |
| 226 | +**`summary`** Returns a filtered array of ambiguous question. |
| 227 | + |
| 228 | +#### Parameters: |
| 229 | + |
| 230 | +Name | Type | Description | |
| 231 | +------ | ------ | ------ | |
| 232 | +`queryResult` | QnAMakerResult[] | User query output. | |
| 233 | + |
| 234 | +**Returns:** QnAMakerResult[] |
| 235 | + |
| 236 | +the filtered results |
| 237 | + |
| 238 | +___ |
| 239 | + |
| 240 | +### onQnaResults |
| 241 | + |
| 242 | +▸ `Protected`**onQnaResults**(`qnaResults`: QnAMakerResult[], `turnContext`: TurnContext, `telemetryProperties?`: { [key:string]: string; }, `telemetryMetrics?`: { [key:string]: number; }): Promise\<void> |
| 243 | + |
| 244 | +*Defined in libraries/botbuilder-ai/lib/customQuestionAnswering.d.ts:193* |
| 245 | + |
| 246 | +Invoked prior to a QnaMessage Event being logged. |
| 247 | + |
| 248 | +#### Parameters: |
| 249 | + |
| 250 | +Name | Type | Description | |
| 251 | +------ | ------ | ------ | |
| 252 | +`qnaResults` | QnAMakerResult[] | The QnA Results for the call. | |
| 253 | +`turnContext` | TurnContext | Context object containing information for a single turn of conversation with a user. | |
| 254 | +`telemetryProperties?` | { [key:string]: string; } | Additional properties to be logged to telemetry with the QnaMessage event. | |
| 255 | +`telemetryMetrics?` | { [key:string]: number; } | Additional metrics to be logged to telemetry with the QnaMessage event. | |
| 256 | + |
| 257 | +**Returns:** Promise\<void> |
| 258 | + |
| 259 | +A promise representing the async operation |
0 commit comments