Get complete control on user messages and rasa responses

I built a chatbot using the instructions given in

and it’s working absolutely fine.

But the problem with this approach is that I have absolutely no control over the user messages and rasa responses i.e., whatever user send the rasa pipeline work on it and send the response back to the user.

But instead of that I want the control of user messages and rasa responses in my hand i.e., I want that I first grab the message sent by the user and do some custom processing on that user message and after that I sent that processed message to rasa which then split the response back to me and then I do some custom processing on the response splitted by rasa and then i send that processed response to my telegram bot.

so I want some functionality like →

if user_msg == ‘I love you’ :
send_response_to_telegram_bot(‘I love you to’)
else :
rasa_response = get_response_from_rasa(usr_msg)
processed_response = apply_some_custom_functionality(string = rasa_response) send_response_to_telegram_bot(processed_response)

I first check if the user message is ‘I love you’ and if it’s true than I don’t need to pass that message to rasa and I simply sent a reponse ‘I love you to’ back to user using function send_response_to_telegram_bot(). But if the user message is something else than I pass the message to rasa using get_response_from_rasa() and rasa returns it’s reply which I stored in a variable rasa_response. I then passed the rasa_response to a function called apply_some_custom_functionality() to add some extra things to the rasa_response and stored in a variable processed_response. And finally I send the processed_reponse from the bot to the user using function send_response_to_telegram_bot().

All the functions defined above are just for demonstration purpose.

How to achieve such a functionality?

I am an absolute beginner in rasa, and started using it from last week so any suggestion/code-snippet/example/blog will be helpful.

If you only want specific responses to certain intents, use the Mapping Policy. Check the example given with insults in the documentation:

ok, this may be helpful to some extent. But I still want the control over the user messages and rasa predicted responses. I want to grab them both and do some custom processing on them. I really want this functionality in my usecase.

So how I achieve the required functionality?

You are the one programming the responses, so you should already have control over them. And for the user messages, you need to add custom components to the pipeline:

It helped me but in case of custom component it executes the whole nlu pipeline in config.yml. But what I need is that if user type a particular message I not need to process it through the nlu pipeline and all I have to do is just apply it to that custom component. That’s why I want a way to store the user input message in a variable and then on the basis of it’s value I decide whether to pass it to rasa or not.

And in case of custom component I train it save the model and all those things but I don’t want that in my case. All I needed is to check the user message and on the basis of that decide whether to pass it to rasa or do stuff on my own. Like in the example mentioned earlier I check the user message if it is “I Love You” then rasa is not required at all and all I have to do is send “I Love you to” back to the user. But if the message is something else then only send it to rasa. And to achieve this behaviour I need to store the user message in a variable and then apply simple if-else logic.

for eg. I am using telegram and building a weather assistant. In telegram we can share our current location using map. As map doesn’t contain any text how I am going to handle that via rasa directly, if some user send me location via map instead of a text message. Because using a map I cannot classify it’s intent and find entities for that I need text messages. so if the user shares his/her current location using the map then I don’t need rasa for that all I have to do is extract the location from the json object of the map and output the weather but for other text messages I have to send it to rasa for intent classifiaction and entity extraction and dialogue management.

For the case of responses from rasa you are right I do have complete control over them but what I need is to pass the predicted responses from rasa to a front end developer who then place the responses in a custom made card and do some other stuff with it if needed. And for this I have to store the predicted responses in a variable so that I can give that variable to the front end developer who then retrieve the response value from that variable and do whatever he want to do.

So in short if I have to give you the predicted responses of my model how I am going to do that?I can’t send you the template messages in domain.yml because their are hundreds of them and you don’t know which one among them is predicted by my model.

In a nutshell all I wanted is some way to store user messages and responses in some variable, so that I can achieve my goals or even give these two variables to some other person.

Hope you understand my needs this time.