I deployed my chatbot to EC2 instance with docker-compose. I follow the steps that be shown in Rasa Masterclass. However, custom actions don’t work. (When I run the same chatbot in my local computer there is no problem). How can I make it run properly?
docker-compose.override.yml:
version: '3.4'
services:
app:
image: 'rasa/rasa-sdk:latest'
volumes:
- './actions:/app/actions'
expose:
- '5055'
depends_on:
- rasa-production
actions.py:
from typing import Any, Text, Dict, List, Union
from rasa_sdk import Tracker, Action
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk.forms import FormAction
PRODUCTS_DICT = {
'product_1: '---ANSWER FOR P1---',
'product_2': '---ANSWER FOR P2---',
'product_3': '---ANSWER FOR P3---',
'product_other': '---ANSWER FOR POTHER---.'
}
class ActionProducts(Action):
def name(self) -> Text:
return "action_products"
def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any]) -> List[Dict]:
prediction = tracker.latest_message
try:
ent = prediction['entities'][0]['entity']
except:
ent = None
buttons = [{"title": "Yes", "payload": "/customer_accept"},
{"title": "No", "payload": "/customer_deny"}]
str_contact_info = '---SOME ANSWER---'
try:
if ent == 'product_other':
dispatcher.utter_message(text=PRODUCTS_DICT.get(ent),
buttons=[{"title": "Agree", "payload": "/more_info"},
{"title": "Disagree", "payload": "/customer_deny"}])
else:
dispatcher.utter_message(text=PRODUCTS_DICT.get(ent) + str_contact_info,
buttons=buttons)
except Exception:
dispatcher.utter_message(
text="Please try again")
return []