Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,22 @@ public QnABot(Configuration withConfiguration) {

@Override
protected CompletableFuture<Void> onMessageActivity(TurnContext turnContext) {
QnAMakerEndpoint qnAMakerEndpoint = new QnAMakerEndpoint() {
{
setKnowledgeBaseId(configuration.getProperty("QnAKnowledgebaseId"));
setEndpointKey(configuration.getProperty("QnAEndpointKey"));
setHost(configuration.getProperty("QnAEndpointHostName"));
}
};
QnAMakerEndpoint qnAMakerEndpoint = new QnAMakerEndpoint() {{
setKnowledgeBaseId(configuration.getProperty("QnAKnowledgebaseId"));
setEndpointKey(configuration.getProperty("QnAEndpointKey"));
setHost(configuration.getProperty("QnAEndpointHostName"));
}};

QnAMaker qnaMaker = new QnAMaker(qnAMakerEndpoint, null);

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

QnAMakerOptions options = new QnAMakerOptions() {
{
setTop(1);
}
};
QnAMakerOptions options = new QnAMakerOptions() {{
setTop(1);
}};

// The actual call to the QnA Maker service.
qnaMaker.getAnswers(turnContext, options)
return qnaMaker.getAnswers(turnContext, options)
.thenCompose(response -> {
if (response != null && response.length > 0) {
return turnContext.sendActivity(MessageFactory.text(response[0].getAnswer()))
Expand All @@ -52,7 +48,5 @@ protected CompletableFuture<Void> onMessageActivity(TurnContext turnContext) {
.thenApply(sendResult -> null);
}
});

return CompletableFuture.completedFuture(null);
}
}