-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
SkillBot.java
34 lines (25 loc) · 1.07 KB
/
SkillBot.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MT License.
package com.microsoft.bot.sample.dialogskillbot.bots;
import java.util.concurrent.CompletableFuture;
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import com.microsoft.bot.builder.ActivityHandler;
import com.microsoft.bot.builder.ConversationState;
import com.microsoft.bot.builder.TurnContext;
import com.microsoft.bot.dialogs.Dialog;
public class SkillBot<T extends Dialog> extends ActivityHandler {
private ConversationState conversationState;
private Dialog dialog;
public SkillBot(ConversationState conversationState, T mainDialog) {
this.conversationState = conversationState;
this.dialog = mainDialog;
}
@Override
public CompletableFuture<Void> onTurn(TurnContext turnContext) {
return Dialog.run(dialog, turnContext, conversationState.createProperty("DialogState"))
.thenAccept(result -> {
conversationState.saveChanges(turnContext, false);
});
}
}