diff --git a/bot/actions/Dockerfile b/bot/actions/Dockerfile new file mode 100644 index 0000000..bcedb9b --- /dev/null +++ b/bot/actions/Dockerfile @@ -0,0 +1,9 @@ +FROM rasa/rasa:1.9.4-full +WORKDIR /app +USER root +RUN python3 -m spacy download en_core_web_sm +RUN python3 -m spacy link -f en_core_web_sm en_core_web_sm + +COPY ./ /app/actions +EXPOSE 5055 +CMD ["run", "actions"] \ No newline at end of file diff --git a/bot/actions/__init__.py b/bot/actions/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bot/actions/__pycache__/actions.cpython-36.pyc b/bot/actions/__pycache__/actions.cpython-36.pyc new file mode 100644 index 0000000..df85071 Binary files /dev/null and b/bot/actions/__pycache__/actions.cpython-36.pyc differ diff --git a/bot/actions.py b/bot/actions/actions.py similarity index 88% rename from bot/actions.py rename to bot/actions/actions.py index 4b888e1..ab6748a 100644 --- a/bot/actions.py +++ b/bot/actions/actions.py @@ -11,6 +11,7 @@ from rasa_sdk.events import SlotSet import spacy import json +import os.path # # nlp = spacy.load('en_core_web_sm') @@ -83,18 +84,24 @@ def submit(self, dispatcher: CollectingDispatcher, def get_board_mapped(self, board): data = '' - with open('resources/boards.json') as boards_values: + dirname = os.path.dirname(__file__) + filename = os.path.join(dirname, 'resources/boards.json') + with open(filename) as boards_values: data = json.load(boards_values) return data[board] def get_medium_mapped(self,medium): data = '' - with open('resources/mediums.json') as mediums_values: + dirname = os.path.dirname(__file__) + filename = os.path.join(dirname, 'resources/mediums.json') + with open(filename) as mediums_values: data = json.load(mediums_values) return data[medium] def get_grade_mapped(self, grade): data = '' - with open('resources/grades.json') as grades_values: + dirname = os.path.dirname(__file__) + filename = os.path.join(dirname, 'resources/grades.json') + with open(filename) as grades_values: data = json.load(grades_values) return data[grade] \ No newline at end of file diff --git a/bot/resources/boards.json b/bot/actions/resources/boards.json similarity index 100% rename from bot/resources/boards.json rename to bot/actions/resources/boards.json diff --git a/bot/resources/grades.json b/bot/actions/resources/grades.json similarity index 100% rename from bot/resources/grades.json rename to bot/actions/resources/grades.json diff --git a/bot/resources/mediums.json b/bot/actions/resources/mediums.json similarity index 100% rename from bot/resources/mediums.json rename to bot/actions/resources/mediums.json diff --git a/bot/endpoints.yml b/bot/endpoints.yml index efefd89..37852ed 100644 --- a/bot/endpoints.yml +++ b/bot/endpoints.yml @@ -11,7 +11,7 @@ # https://rasa.com/docs/rasa/core/actions/#custom-actions/ action_endpoint: - url: "http://localhost:5055/webhook" + url: "http://action:5055/webhook" # Tracker store which is used to store the conversations. # By default the conversations are stored in memory. diff --git a/stack.yml b/stack.yml index cc71a7c..66e903a 100644 --- a/stack.yml +++ b/stack.yml @@ -10,6 +10,12 @@ services: - "5005:5005" environment: - TMP=TMP + action: + build: + dockerfile: Dockerfile + context: ./bot/actions/. + ports: + - "5055:5055" router: build: ./router/. ports: