Rasa action,py get specific bot utterance text programmatically

Hello, I need to get one of my bot utterances specified in the domain file programmatically. How would I do this?

Try this,

In domain:

responses: utter_greet_name:

  • text: Hi {name}!

in action:

dispatcher.utter_message(template = "utter_greet_name", name = "Aimee")

or

dispatcher.utter_template("utter_greet_name", tracker, name = "Aimee")

Does this only display text or does it get me the string I can manage through python. I may need to get more than one

@LaurentStar

domain.yml

responses: utter_show_detail:

  • text: Thanks {name}! for the Email id {email}. How can I help you!

actions: action_show_detail

action.py

class ActionDetailt(Action):

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

 def run(self, dispatcher: CollectingDispatcher,
         tracker: Tracker,
         domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
        
     name=tracker.get_slot("name")
     email=tracker.get_slot("email")

     dispatcher.utter_message(template="utter_show_detail")
     
     return []

You need to create the intent in nlu.yml, mention the Intent, Entities, Slots in domain.yml and create the story for the bot/user conversation.

You need to think now :wink: I know you can do this. I can’t post the complete code. Good luck. Do share the screenshot with us! Happy learning.

:unamused:

I checked the documentation. dispatcher.utter_message method does not return anything. None of the methods return anything. I don’t want to display a specific message, I want the string. If it can’t be done/ or shouldn’t be done just say so

@LaurentStar The process or code I shared with you should be done. There is no other method in my knowledge. For me, the above method fulfills the requirement which you want, try to follow Rasa · GitHub and see the examples. Hope it will help you more. Good Luck!