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

**URL:** <https://forum.rasa.com/t/how-to-pass-data-to-custom-ml-model-and-get-the-result-back-from-it-to-our-rasa-chatbot/39400>\
**Category:** Rasa Open Source\
**Created:** [January 24, 2021, 7:49am UTC](https://forum.rasa.com/t/how-to-pass-data-to-custom-ml-model-and-get-the-result-back-from-it-to-our-rasa-chatbot/39400 "2021-01-24T07:49:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Srikanth](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@Srikanth](https://forum.rasa.com/u/Srikanth)\
**Post date:** [January 24, 2021, 7:49am UTC](https://forum.rasa.com/t/how-to-pass-data-to-custom-ml-model-and-get-the-result-back-from-it-to-our-rasa-chatbot/39400/1 "2021-01-24T07:49:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![desmarchris](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/desmarchris/32/12277_2.png) [@desmarchris](https://forum.rasa.com/u/desmarchris)\
**Post date:** [January 25, 2021, 7:12pm UTC](https://forum.rasa.com/t/how-to-pass-data-to-custom-ml-model-and-get-the-result-back-from-it-to-our-rasa-chatbot/39400/2 "2021-01-25T19:12:07Z")

</div>

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](https://rasa.com/docs/action-server/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](https://github.com/RasaHQ/financial-demo/blob/rasa-2-0/data/rules/rules.yml#L80)
- In your custom action, use the tracker object to get your slot values ([equivalent financial demo example here](https://github.com/RasaHQ/financial-demo/blob/rasa-2-0/actions/actions.py#L46))
- call your API in the custom action
- use the api response in a [response template](https://rasa.com/docs/action-server/sdk-dispatcher#collectingdispatcherutter_message) 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!

---

<div class="post-metadata">

**Author:** ![Srikanth](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@Srikanth](https://forum.rasa.com/u/Srikanth)\
**Post date:** [January 28, 2021, 12:50pm UTC](https://forum.rasa.com/t/how-to-pass-data-to-custom-ml-model-and-get-the-result-back-from-it-to-our-rasa-chatbot/39400/3 "2021-01-28T12:50:47Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![desmarchris](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/desmarchris/32/12277_2.png) [@desmarchris](https://forum.rasa.com/u/desmarchris)\
**Post date:** [January 28, 2021, 2:22pm UTC](https://forum.rasa.com/t/how-to-pass-data-to-custom-ml-model-and-get-the-result-back-from-it-to-our-rasa-chatbot/39400/4 "2021-01-28T14:22:50Z")

</div>

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](https://github.com/RasaHQ/financial-demo/blob/rasa-2-0/actions/actions.py#L6)

---

<div class="post-metadata">

**Author:** ![Srikanth](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@Srikanth](https://forum.rasa.com/u/Srikanth)\
**Post date:** [January 28, 2021, 3:34pm UTC](https://forum.rasa.com/t/how-to-pass-data-to-custom-ml-model-and-get-the-result-back-from-it-to-our-rasa-chatbot/39400/5 "2021-01-28T15:34:26Z")

</div>

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