How to get user entered text in custom action - Rasa Open Source - Rasa Community Forum

👋 Introducing the Rasa Playground

How to get user entered text in custom action

post by raghavendrav1210 on Aug 24, 2018

HI All,

I am trying to get the user entered text inside run method of a custom action. In which object I can get that


def run(self, dispatcher, tracker, domain):

post by akelad on Aug 24, 2018

You can get this with tracker.latest_message.text


post by raghavendrav1210 on Aug 24, 2018

Got it thanks


post by raghavendrav1210 on Aug 24, 2018

@akelad thanks for your answer. i have one more question how can I run multiple projects in a rasa core server instance.

I mean I have a FAQ Bot and Helpdesk bot How to run these at a time and how can I call them using REST API?


post by bhaarat on Sep 20, 2018

I am trying to do that but no success yet. I get the error as below:

rasa_core.actions.action - Failed to run custom action ‘action_help’. Action server responded with a non 200 status code of 500. Make sure your action server properly runs actions and returns a 200 once the action is executed. Error: 500 Server Error: INTERNAL SERVER ERROR for url: http://localhost:5055/webhook
ERROR rasa_core.processor - Encountered an exception while running action ‘action_help’. Bot will continue, but the actions events are lost. Make sure to fix the exception in your custom code
ERROR rasa_core.processor - Failed to execute custom action.
in my actions.py I have this line of code below:
dispatcher.utter_message(tracker.latest_message.entities(help))
As soon as I remove this line of code everything works as it should.
The precise error I get is:
AttributeError: 'dict' object has no attribute 'entities'
Any help on this.


post by ashukrishna100 on Sep 26, 2018

For version 11.0 and above
Use this

(tracker.latest_message)['text']


post by bhaarat on Sep 26, 2018

Thanks for the reply. It worked for me.


post by Ajinkz on Jan 8, 2019

I m trying to print only those user input which bot cant interpret using following code

txt=tracker.latest_message.text
return txt

Now getting this error

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

My ultimate task is to add those input which are not present in training data under some intent like unknown user input


post by srikar_1996 on Jan 8, 2019

Try it this way

message = tracker.latest_message.get('text')

post by Ajinkz on Jan 8, 2019

Thanks. Its working.


post by lohith.arcot on Sep 6, 2019

thanks


post by jeng on Nov 26, 2019

hi, may i know how and where you add in those code for tracking user input?


post by karthik1 on Nov 27, 2019

Hi all,

I want get the username from the chat conversations

example:-
bot:- Hi
user:- Hi
Bot: May i know your name?
User: I am Karthik
Bot : Thanks for providing details Karthik

Like the above example i have call the user with there name can anybody please help


post by Edukondalu on May 6, 2020

if i have form action … it is taking latest message of form field of text value.
but need a user question.

input_str = tracker.latest_message.get(“text”)

post by SumanthLazarus on Aug 5, 2020

In order to extract the name, one way to go about it is create an intent get_name with entity name; you can feed training data which demonstrates response to needed question.

eg:

## intent: get_name
    - My name is [Karthik](name)
    - My name is [possible](name)
    - My name is [other names](name)
    - I am [Sumanth](name)
    - I am [William](name)
    - I am [Lazarus](name)

post by thundersparkf on Aug 29, 2020

hey, I have tried this but it isn’t working. I have also tried the tracker.latest_message.text. I’m using the rasa/rasa-sdk:2.0.0x docker image and I had it working previously, now it’s not working. The custom action is just running completely ignoring the latest text thing. Please help, Thank you!


post by athenasaurav on Sep 4, 2020

Hi @thundersparkf

The code is

tracker.latest_message.get('text')

post by RahulJha393 on Feb 1, 2023

This will work in action :

tracker.latest_message[‘text’]