How to connect my own python file to rasa chatbot?

please help me for connecting my chatbot to rasa chatbot.

What exactly you want to do?

If you mean how to access Rasa from your own chat frontend written in python, you can use the Rasa API to send messages to the chatbot and get the response back. In your python script you would use requests to call the api. Here’s an example:

import requests


#replace rasa_server with the ip or name of actual server
message_url = 'http://rasa_server:5005/webhooks/rest/webhook'

headers = { 'Content-type':'application/json'}

# user_id is the name of the conversation, message is the text to send to Rasa
payload = '{"sender": "' + str(user_id) + '", "message": "' + message + '"}'

r =, data=payload.encode('utf-8'), headers=headers)
response = json.loads(r.content)


You need to add error handling code to this in case the Rasa server is down, to make sure the response is valid, etc… response[0].['text'] normally contains the text response from Rasa, but if a custom action crashes, the response returns empty. Examine a few response objects to see how it’s all formatted.

have you created your own nlp and tensorflow based chatbot with intents? I too created similar code and I want to know exactly your intension so that can help you.