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
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:
- at the end of your story/rule that collects the slots, call your custom action with a step. Here’s an example in our Financial Demo
- In your custom action, use the tracker object to get your slot values (equivalent financial demo example here)
- call your API in the custom action
- use the api response in a response template for the dispatcher to send a message back to the user
If I missed your use case and you’re looking to do something else, let me know!
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 actions.py
Thank you so much desmarchris. I followed what you said, my problem is solved.