Issue rasa check ? or statement

if my customer action I would like to check if the user ask question or juste easy statement can you help me on that ? that my code but it is not working plz help me

class ActionQuestionMark(Action):

 def name(self):
     return "action_question_mark"
def run(self, dispatcher, tracker, domain):
    message = tracker.latest_message.text["text"]
    # dispatcher.utter_message("Hello World!")
    if message.endswith("?"):
    # Return a random question
        return dispatcher.utter_message("Question")
    else:
        return dispatcher.utter_message("statement")

May I know if you have run “rasa run actions” on a separate terminal?

To run “rasa run actions” you need to “pip install rasa-sdk”

yes I did it and I run my action also but not work

Could you give screenshot of your whole action file and also the method latest_message.text. I am not that skilled with rasa also but to access the latest message let’s say data={…} contains the tracker json readings, You could access the latest message with data[“tracker”][“latest_message”][“text”]

Also, you can run “rasa run actions -vv” to enter debug mode, then you can post your debug log here for us to view.

1 Like

thank you so much you help too much I wish for you best day thx

you can use

tracker.latest_message[“text”] instead of tracker.latest_message.text[“text”] I tried this and it works fine