Skip to content

Commit 0ca0124

Browse files
committed
bot examples
1 parent 720741f commit 0ca0124

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

articles/cognitive-services/QnAMaker/How-To/metadata-generateanswer-usage.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ manager: nitinme
88
ms.service: cognitive-services
99
ms.subservice: qna-maker
1010
ms.topic: article
11-
ms.date: 05/30/2019
11+
ms.date: 06/17/2019
1212
ms.author: tulasim
1313
---
1414

@@ -140,6 +140,40 @@ A successful response returns a status of 200 and a JSON response.
140140
}
141141
```
142142

143+
## Use QnA Maker with a bot in C#
144+
145+
The bot framework provides access to the QnA Maker's properties:
146+
147+
```csharp
148+
using Microsoft.Bot.Builder.AI.QnA;
149+
var metadata = new Microsoft.Bot.Builder.AI.QnA.Metadata();
150+
var qnaOptions = new QnAMakerOptions();
151+
152+
qnaOptions.Top = Constants.DefaultTop;
153+
qnaOptions.ScoreThreshold = 0.3F;
154+
var response = await _services.QnAServices[QnAMakerKey].GetAnswersAsync(turnContext, qnaOptions);
155+
```
156+
157+
The Support bot has [an example](https://github.com/microsoft/BotBuilder-Samples/blob/master/experimental/qnamaker-support/csharp_dotnetcore/Service/SupportBotService.cs#L418) with this code.
158+
159+
## Use QnA Maker with a bot in Node.js
160+
161+
The bot framework provides access to the QnA Maker's properties:
162+
163+
```csharp
164+
const { QnAMaker } = require('botbuilder-ai');
165+
this.qnaMaker = new QnAMaker(endpoint);
166+
167+
// Default QnAMakerOptions
168+
var qnaMakerOptions = {
169+
ScoreThreshold: 0.03,
170+
Top: 3
171+
};
172+
var qnaResults = await this.qnaMaker.getAnswers(stepContext.context, qnaMakerOptions);
173+
```
174+
175+
The Support bot has [an example](https://github.com/microsoft/BotBuilder-Samples/blob/master/experimental/qnamaker-activelearning/javascript_nodejs/Helpers/dialogHelper.js#L36) with this code.
176+
143177
<a name="metadata-example"></a>
144178

145179
## Use metadata to filter answers by custom metadata tags

0 commit comments

Comments
 (0)