How to pass data to custom ML model and get the result back from it to our Rasa chatbot

I have created a basic chatbot which will be able to answer FAQs. Now I want to pass data let’s say x1,x2,x3,x4 features values which I would be getting using slots and pass those values to my custom model that I have trained with Machine learning and get the output of the model say X_result back to my chatbot. How can I achieve that? I am a bit new to Rasa, any idea and sample code would be much appreciated! thanks

Hey @Srikanth,

To play it back, you want to take values that your slots collect, call an API, and show the response back in your bot right?

You can use custom actions to pull the data from your slots, call your other model, and show the response back to the user. This is the overview of what you’ll do:

If I missed your use case and you’re looking to do something else, let me know!

1 Like

Thank you for responding Desmarchris. I know the process of collect the user entered slots value. like I’m trying to collect user’s gender, bodytype, skintone, and temperature. I’ve trained a Naive bayes classifier model, using gender, bodytype, skintone, temperature as dependent variables and Suggest dress as independent variable. now I want to pass user inputted slots values to that Naive bayes classifier model and get the result using that and pass it back to user. I’m not sure how to integrate another module in actions.yml. Could you please help me with this?

It sounds like your model is outside rasa right? It shouldn’t be any different than above, treating this use case as collecting the variables as slot values and passing them to your model through a custom action. I think the interaction with your model depends on how you’re making it accessible… I was assuming you have a URL to hit that you can follow the above method to make a REST call to your model? Let me know if I’m missing something.

Regarding another module, the actions file is actually a python file and not yaml. So you can use python modules in the standard way by importing at the top. You can see this at the top of the Financial Demo

Thank you so much desmarchris. I followed what you said, my problem is solved.

1 Like