diff --git a/.travis.yml b/.travis.yml index 505ebf2..9686e44 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,11 +16,11 @@ before_script: - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin script: - - docker build -t joffreybvn/resa-chatbot:latest . + - docker build -t paradous/resa-chatbot:latest . deploy: provider: script script: - docker push joffreybvn/resa-chatbot:latest; + docker push paradous/resa-chatbot:latest; on: branch: master \ No newline at end of file diff --git a/README.md b/README.md index 63faaef..e0a3c78 100644 --- a/README.md +++ b/README.md @@ -55,4 +55,4 @@ As of today, the bot is available on: This project was completed in 5 days by two Machine Learning students from BeCode: - **Vincent Leurs**: [Twitter](https://twitter.com/VincentLeurs) - [Github](https://github.com/paradous) - - **Joffrey Bienvenu**: [Website](https://joffreybvn.be/) - [Twitter](https://twitter.com/Joffreybvn) - [Github](https://github.com/joffreybvn) + - **Joffrey Bienvenu**: [Website](https://joffreybvn.be/) - [Twitter](https://twitter.com/Joffreybvn) - [Github](https://github.com/joffreybvn) \ No newline at end of file diff --git a/assets/conversation_simple.svg b/assets/conversation_simple.svg new file mode 100644 index 0000000..4bc7af6 --- /dev/null +++ b/assets/conversation_simple.svg @@ -0,0 +1,3 @@ + + +
Bonjour, je voudrais réserver une chambre
Bonjour, je voudrais réserver une chambre
Bonjour, combien de personnes ?
Bonjour, combien de personnes ?
3
3
Combien de nuits ?
Combien de nuits ?
2
2
Reservation effectuée, bonne journée !
Reservation effectuée, bonne journée !
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/src/bot/dialog.py b/src/bot/dialog.py new file mode 100644 index 0000000..0efb20c --- /dev/null +++ b/src/bot/dialog.py @@ -0,0 +1,49 @@ + +from botbuilder.core import ActivityHandler, ConversationState, TurnContext, UserState +from botbuilder.dialogs import Dialog +from helpers.dialog_helper import DialogHelper + + +class DialogBot(ActivityHandler): + """ + This Bot implementation can run any type of Dialog. The use of type parameterization is to allows multiple + different bots to be run at different endpoints within the same project. This can be achieved by defining distinct + Controller types each with dependency on distinct Bot types. The ConversationState is used by the Dialog system. The + UserState isn't, however, it might have been used in a Dialog implementation, and the requirement is that all + BotState objects are saved at the end of a turn. + """ + + def __init__( + self, + conversation_state: ConversationState, + user_state: UserState, + dialog: Dialog, + ): + if conversation_state is None: + raise TypeError( + "[DialogBot]: Missing parameter. conversation_state is required but None was given" + ) + if user_state is None: + raise TypeError( + "[DialogBot]: Missing parameter. user_state is required but None was given" + ) + if dialog is None: + raise Exception("[DialogBot]: Missing parameter. dialog is required") + + self.conversation_state = conversation_state + self.user_state = user_state + self.dialog = dialog + + async def on_turn(self, turn_context: TurnContext): + await super().on_turn(turn_context) + + # Save any state changes that might have ocurred during the turn. + await self.conversation_state.save_changes(turn_context) + await self.user_state.save_changes(turn_context) + + async def on_message_activity(self, turn_context: TurnContext): + await DialogHelper.run_dialog( + self.dialog, + turn_context, + self.conversation_state.create_property("DialogState"), + ) \ No newline at end of file