Please How to get user message without using slot

I would like the user İ the bot convert to you I write that but not work class ReplacePronon(Action): def name(self):

    return 'action_replace_pronon'

def run(self, dispatcher, tracker, domain):
    #inp = next(tracker.get_latest_entity_values("inform"), None) not work
    #inp = tracker.latest_message.text
    #inp = rasa_sdk.Tracker.get_latest_input_channel
    #inp = tracker.latest_text
    inp = tracker.latest_message.text

    #if not inp:
        #dispatcher.utter_message("no match sentences")
        #return []

    #if 'me' in inp:
      #  dispatcher.utter_message(inp)
       # return re.sub('me','you',inp)

    # if 'my' in inp:
      #  dispatcher.utter_message(inp)
       # return re.sub('my','your',inp)

    #if 'your' in inp:
       # dispatcher.utter_message(inp)
       # return re.sub('your','my',inp)

    #if 'you' in inp:
    
    response = " Your product is ordered for you. It will be shipped to your address. Your confirmation number is {}".format(inp)
    dispatcher.utter_message("response")
        #return re.sub('you','me',inp)   
    return [response]

what always I found inp = tracker.latest_message.text

                AttributeError: 'dict' object has no attribute 'text'

please help me to solve I need that to contınu my study plz

Try this way: inp = tracker.latest_message['text']

2 Likes

thx that help Your action’s ‘action_replace_pronon’ run method returned an invalid event. Event will be ignored. Event: how can fix that ???

Hi @hajoura

the return type is simply wrong because it currently it is a string which is invalid. If you only want to utter something, use:

response = "Your product is ordered for you. It will be shipped to your address. Your confirmation number is {}".format(inp)
    dispatcher.utter_message(response)

    return []

Keep in mind that indentation is important in python.

1 Like