S: Hello, how can I help you?
U: Hi, I'd like to book a haircut.
S: Sure. What date and time are you looking for?
U: Tuesday at 2 PM.
S: Your appointment is set. See you!S: Hello, how can I help you?
U: Can I make an appointment for waxing?
S: Sorry, we do not provide that service.
U: OK then.
S: Goodbye.S: Hello, how can I help you?
U: Can I make an appointment for a perm?
S: Sure. What date and time are you looking for?
U: Saturday 10 AM.
S: Your appointment is set. See you!S: Hello, how can I help you?
U: Hi, I'd like to book a haircut.
S: Sure. What date and time are you looking for?
U: Saturday 10 AM.
S: Sorry, that slot is not available for a haircut.
U: OK.
S: Goodbye.transitions = {'state': 'start'}#5: the system responds to the user with "Glad to hear that ..." and recognizes that it is the final state end.S: Hello. How are you?
U: Good!
S: Glad to hear that you are doing well :)transitions = {
'state': 'start',
'`Hello. How are you?`': {
'good': {
'`Glad to hear that you are doing well :)`': 'end'
}
}
}from emora_stdm import DialogueFlow
df = DialogueFlow('start', end_state='end')df.load_transitions(transitions)if __name__ == '__main__':
df.run()transitions = {
'state': 'start',
'`Hello. How are you?`': {
'good': {
'`Glad to hear that you are doing well :)`': 'end'
},
'bad': {
'`I hope your day gets better soon :(`': 'end'
}
}
}S: Hello. How are you?
U: Good
S: Glad to hear that you are doing well :)S: Hello. How are you?
U: Bad
S: I hope your day gets better soon :(transitions = {
'state': 'start',
'`Hello. How are you?`': {
'good': {
'`Glad to hear that you are doing well :)`': 'end'
},
'bad': {
'`I hope your day gets better soon :(`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
}
}
}S: Hello. How are you?
U: It could be better.
S: Sorry, I didn't understand you.from emora_stdm import DialogueFlow
def state_transition() -> DialogueFlow:
transitions = {
'state': 'start',
'`Hello. How are you?`': {
'good': {
'`Glad to hear that you are doing well :)`': 'end'
},
'bad': {
'`I hope your day gets better soon :(`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
}
}
}
df = DialogueFlow('start', end_state='end')
df.load_transitions(transitions)
return df
if __name__ == '__main__':
state_transition().run()Introduce Emora State Transition Dialogue Manager.

Create a multi-turn dialogue flow.
transitions = {
'state': 'start',
'`Hello. How are you?`': {
'{good, fantastic}': {
'`Glad to hear that you are doing well :)`': 'end'
},
'{bad, could be better}': {
'`I hope your day gets better soon :(`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
}
}
}transitions = {
'state': 'start',
'`Hello. How are you?`': {
'[{good, fantastic}]': {
'`Glad to hear that you are doing well :)`': {
'[{how, and}, {you, going}]': {
'`I feel superb. Thank you!`': 'end'
}
}
},
'error': {
'`Got it; thanks for sharing.`': 'end'
},
}
}S: Hello. How are you?
U: Good!
S: Glad to hear that you are doing well :)
U: How are you doing?
S: I feel superb. Thank you!S: Hello. How are you?
U: Fantastic
S: Glad to hear that you are doing well :)
U: Thank you!
Traceback (most recent call last):
...S: Hello. How are you?
U: Fantastic!!
S: Glad to hear that you are doing well :)S: Hello. How are you?
U: Could be better..
S: I hope your day gets better soon :(transitions = {
'state': 'start',
'`Hello. How are you?`': {
'[good]': {
'`Glad to hear that you are doing well :)`': 'end'
},
'[could be better]': {
'`I hope your day gets better soon :(`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
},
}
}S: Hello. How are you?
U: I'm good!!
S: Glad to hear that you are doing well :)S: Hello. How are you?
U: It could be better..
S: I hope your day gets better soon :(S: Hello. How are you?
U: good
S: Sorry, I didn't understand you.S: Hello. How are you?
U: fantastic
S: Sorry, I didn't understand you.S: Hello. How are you?
U: good and fantastic!
S: Glad to hear that you are doing well :)transitions = {
'state': 'start',
'`Hello. How are you?`': {
'[{good, fantastic}]': {
'`Glad to hear that you are doing well :)`': 'end'
},
'[{bad, could be better}]': {
'`I hope your day gets better soon :(`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
},
}
}S: Hello. How are you?
U: I'm so good!
S: Glad to hear that you are doing well :)S: Hello. How are you?
U: It's fantastic!!
S: Glad to hear that you are doing well :)S: Hello. How are you?
U: Pretty bad..
S: I hope your day gets better soon :(S: Hello. How are you?
U: It could be better.
S: I hope your day gets better soon :(transitions = {
'state': 'start',
'`Hello. How are you?`': {
'[{good, fantastic}]': {
'`Glad to hear that you are doing well :)`': 'end'
},
'[{bad, could be better}]': {
'`I hope your day gets better soon :(`': 'end'
},
'[how, you]': {
'`I feel superb. Thank you!`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
},
}
}S: Hello. How are you?
U: Fine. How are you doing?
S: I feel superb. Thank you!S: Hello. How are you?
U: Fine. How is it going?
S: Sorry, I didn't understand you.S: Hello. How are you?
U: Fine, and you?
S: Sorry, I didn't understand you.transitions = {
'state': 'start',
'`Hello. How are you?`': {
'[{good, fantastic}]': {
'`Glad to hear that you are doing well :)`': 'end'
},
'[{bad, could be better}]': {
'`I hope your day gets better soon :(`': 'end'
},
'[{how, and}, {you, going}]': {
'`I feel superb. Thank you!`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
},
}
}S: Hello. How are you?
U: Fine. How is it going?
S: I feel superb. Thank you!S: Hello. How are you?
U: Fine, and you?
S: I feel superb. Thank you!S: Hello. How are you?
U: Good, how are you?
S: Glad to hear that you are doing well :)S: Hello. How are you?
U: Good, how are you?
S: I feel superb. Thank you!def matching_strategy() -> DialogueFlow:
transitions = {
'state': 'start',
'`Hello. How are you?`': {
'[{good, fantastic}]': {
'`Glad to hear that you are doing well :)`': 'end'
},
'[{bad, could be better}]': {
'`I hope your day gets better soon :(`': 'end'
},
'[{how, and}, {you, going}]': {
'`I feel superb. Thank you!`': 'end'
},
'error': {
'`Sorry, I didn\'t understand you.`': 'end'
},
}
}
df = DialogueFlow('start', end_state='end')
df.load_transitions(transitions)
return df
if __name__ == '__main__':
matching_strategy().run()def multiturn_dialogue() -> DialogueFlow:
transitions = {
'state': 'start',
'`Hello. How are you?`': {
'[{good, fantastic}]': {
'`Glad to hear that you are doing well :)`': {
'[{how, and}, {you, going}]': {
'`I feel superb. Thank you!`': 'end'
},
'error': {
'`You are the best!`': 'end'
}
}
},
'error': {
'`Got it; thanks for sharing.`': 'end'
},
}
}
df = DialogueFlow('start', end_state='end')
df.load_transitions(transitions)
return df
if __name__ == '__main__':
multiturn_dialogue().run()S: Hello. How are you?
U: Fantastic!
S: Glad to hear that you are doing well :)
U: Thank you!
S: You are the best!