Search code examples
pythonpython-requestschatbotrasa-core

How to fetch parameters from a GET request in Python


So I have been building a chatbot powered by RASA stack (open source). After creating the bot, I wanted to integrate it with our web application. Now I'm able get responses from my RASA core but I'm in a problem. I'm passing a unique user_id in the GET request which i need to fetch inside a python function and call an external API to my Database. But I don't know how to fetch that parameter out from GET request. here are some details.

My GET request: (I uploaded my bot on AWS server) http://my_ip_.amazonaws.com:5005/conversations/27/respond?q=%27Hi

So my unique id is 27 which i want to fetch inside a python function.

and the response i'm getting by this request :

[{“recipient_id”:“27”,“text”:“Hey! What can I do for you?”}]

As you can see I passed the GET request in postman and got this response from my RASA CHATBOT but I want to track this user-id 27.

So my question is how can I track this id? Or maybe you guys can suggest me another way to do it.

Thanks for your help in advance :) My first post BTW :)

[Please ask me anything if you feel this question is missing something]


Solution

  • so I solved this issue by using tracker data. Actually, I had to link tracker dictionary to my custom action file so that I can access the sender_id and other slot values. I used:

    user_id = tracker.sender_id
    parameters ={}
    parameters = {"user_id": user_id}
    

    then it follows by my post request and it works! Thanks