Custom Action not working after adding external dependency

I’ve installed rasa x on a server using docker-compose. I added a custom action following rasa master class using docker-compose.override and it worked fine. Now I’ve updated my custom action and it uses pymongo (a python library) to connect to a mongoDB database and it doesn’t work as intended. The price slot is not being set. The logs display an error pymongo module not found .One point to note is that it works fine locally on rasa x.

from typing import Any, Text, Dict, List

from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
from import SlotSet
from pymongo import MongoClient

client = MongoClient(url)
db = client.floc

class ActionOrderSize(Action):

    def name(self) -> Text:
        return "action_order_size"

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

        items = tracker.get_slot("items")
        serving_size = tracker.get_slot("serving_size")
        price = 0
        for i in range(len(items)):
            item = items[i].lower().replace(" ", "")
            if serving_size[i]:
                size = serving_size[i].lower()
                size = "-"
            itemPrice ={"item":item,"size":size})
            price = price + itemPrice['price']
        return [SlotSet("price", price)]


FROM rasa/rasa-sdk:latest


USER root

RUN pip install pymongo

COPY ./actions /app/actions

USER 1001


version: '3.4'
    build: .
      - './actions:/app/actions'
      - '5055'
      - rasa-production
1 Like

Is there anyone who can fix this issue? Similar here with the external dependency problem