forked from rvinothrajendran/BotTutorialSample
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
35 lines (26 loc) · 1.66 KB
/
Copy pathbot.py
File metadata and controls
35 lines (26 loc) · 1.66 KB
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
35
from botbuilder.core import TurnContext,ActivityHandler,ConversationState,MessageFactory
from botbuilder.dialogs import DialogSet,WaterfallDialog,WaterfallStepContext
from botbuilder.dialogs.prompts import ChoicePrompt,PromptOptions
from botbuilder.dialogs.choices import Choice
class BotDialog(ActivityHandler):
def __init__(self,conversation:ConversationState):
self.con_statea = conversation
self.state_prop = self.con_statea.create_property("dialog_set")
self.dialog_set = DialogSet(self.state_prop)
self.dialog_set.add(ChoicePrompt(ChoicePrompt.__name__))
self.dialog_set.add(WaterfallDialog("main_dialog",[self.DisplayChoiceList,self.ReadResult]))
async def DisplayChoiceList(self,waterfall_step:WaterfallStepContext):
listofchoice = [Choice("MTech"),Choice("BTech"),Choice("MCA"),Choice("PhD")]
return await waterfall_step.prompt((ChoicePrompt.__name__),
PromptOptions(prompt=MessageFactory.text("Please select the your education"),choices=listofchoice))
async def ReadResult(self,waterfall_step:WaterfallStepContext):
choiceoption = waterfall_step.result.value
await waterfall_step._turn_context.send_activity(MessageFactory.text(choiceoption))
return await waterfall_step.end_dialog()
async def on_turn(self,turn_context:TurnContext):
dialog_context = await self.dialog_set.create_context(turn_context)
if(dialog_context.active_dialog is not None):
await dialog_context.continue_dialog()
else:
await dialog_context.begin_dialog("main_dialog")
await self.con_statea.save_changes(turn_context)