I have problems in custom action responsing - Getting Started with Rasa / Tutorials, Resources & Videos - Rasa Community Forum

👋 Introducing the Rasa Playground

I have problems in custom action responsing

post by Evergyu on May 10, 2021

Hello I’m new to RASA and trying to make chatbot for foreigner in my school. I want to get dictionary in txt file and if I find same key, print the value of the key example:

Your Input : Where is N14?

Bot : Here’s N14’s link.

Bot : link

I don’t know why this don’t work. Thanks

building.txt (9.7 KB)

actions.py

from typing import Any, Text, Dict, List

from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
import ast #딕셔너리 읽는 것

class ActionResponseMap(Action):
    def name(self) -> Text:
        return "action_response_map"

def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
        building=tracker.latest_message['entities'][0]['value']
        building_file=open("./data/building.txt","r")
        dispatcher.utter_message(text="Here is the map of the {}".format("building"))
        dictionay_building=ast.literal_eval(contents)
        for key,value in dictionay_building:
            if(key==building):
                print(key," : ",value)
        building_file.close()
        return []

post by Dustyposa on May 10, 2021

You should past the error msg of action server.