Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Joffreybvn authored Feb 8, 2021
2 parents cc9f8c3 + 931a3ee commit 3ca845d
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 3 additions & 0 deletions assets/conversation_simple.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions src/bot/dialog.py
Original file line number Diff line number Diff line change
@@ -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"),
)

0 comments on commit 3ca845d

Please sign in to comment.