Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.

Commit 6e24910

Browse files
authored
Small QnA sample style change (#1025)
1 parent f84e1da commit 6e24910

File tree

1 file changed

+9
-15
lines changed
  • samples/11.qnamaker/src/main/java/com/microsoft/bot/sample/qnamaker

1 file changed

+9
-15
lines changed

samples/11.qnamaker/src/main/java/com/microsoft/bot/sample/qnamaker/QnABot.java

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,22 @@ public QnABot(Configuration withConfiguration) {
2222

2323
@Override
2424
protected CompletableFuture<Void> onMessageActivity(TurnContext turnContext) {
25-
QnAMakerEndpoint qnAMakerEndpoint = new QnAMakerEndpoint() {
26-
{
27-
setKnowledgeBaseId(configuration.getProperty("QnAKnowledgebaseId"));
28-
setEndpointKey(configuration.getProperty("QnAEndpointKey"));
29-
setHost(configuration.getProperty("QnAEndpointHostName"));
30-
}
31-
};
25+
QnAMakerEndpoint qnAMakerEndpoint = new QnAMakerEndpoint() {{
26+
setKnowledgeBaseId(configuration.getProperty("QnAKnowledgebaseId"));
27+
setEndpointKey(configuration.getProperty("QnAEndpointKey"));
28+
setHost(configuration.getProperty("QnAEndpointHostName"));
29+
}};
3230

3331
QnAMaker qnaMaker = new QnAMaker(qnAMakerEndpoint, null);
3432

3533
LoggerFactory.getLogger(QnABot.class).info("Calling QnA Maker");
3634

37-
QnAMakerOptions options = new QnAMakerOptions() {
38-
{
39-
setTop(1);
40-
}
41-
};
35+
QnAMakerOptions options = new QnAMakerOptions() {{
36+
setTop(1);
37+
}};
4238

4339
// The actual call to the QnA Maker service.
44-
qnaMaker.getAnswers(turnContext, options)
40+
return qnaMaker.getAnswers(turnContext, options)
4541
.thenCompose(response -> {
4642
if (response != null && response.length > 0) {
4743
return turnContext.sendActivity(MessageFactory.text(response[0].getAnswer()))
@@ -52,7 +48,5 @@ protected CompletableFuture<Void> onMessageActivity(TurnContext turnContext) {
5248
.thenApply(sendResult -> null);
5349
}
5450
});
55-
56-
return CompletableFuture.completedFuture(null);
5751
}
5852
}

0 commit comments

Comments
 (0)