How can I get Monogd collection data in custom Action

tracker_store:
   type: mongod
   url: mongodb://localhost:27017/
   db: sample
   collection: actions
   username:  
   password:

I want to access collection data into action.py file (in my custom action) can I get an example.

Thanks in advance

Hi @pkchoudhary1211,

you can establish a direct connection to your database using pymongo or mongoengine. However you need to write the query for the data yourself.

As far as I know you can use the trackers built in methods in your action, you can overwrite the trackers Implementation if you need other data or you can query the database directly as mentioned.

Tell me, if you need help with that! Regards

@JulianGerhard Thanks You For Your Response I will try this. what I did is I created Rest API in Node js That API I calling in rasa

import requests
import json
# import 
from typing import Any, Text, Dict, List
from pymongo.database import Database
from pymongo import MongoClient
from rasa_sdk import Action, Tracker 
from rasa_sdk.executor import CollectingDispatcher
url="http://localhost:3000/api"
class ActionHelloWorld(Action):
    def name(self):
        return "action_hello_world"
    def run(self, dispatcher, tracker, domain):
        request = requests.get('http://localhost:3000/api').json()  
        print("test URL :",url)
        print("this is test data",request[0]['text'])
        # buttons = []
        print("this is tracker :",tracker.get_slot('sample'))