Web Integration of Rasa Bot

Using Rasa NLU - 0.11.4 and Rasa Core - 0.8.2

I’m facing issues with integrating Rasa bot with Web. My objective is to send an API call to Bot and get back the reply. Very much similar to what @juste_petr did in her tutorial. But not on slack, rather on a local system. For example, I send a simple CURL request to the bot, and it returns the reply.

Current Status: My bot is recieving the message sent through CURL command, but returns NULL value. I’ve implemented this, excluding the Slack parts. I guess the input part is working correctly but there is some issue with the output part. I can’t find any documentation regarding “HttpInputComponent” and “OutputChannel” in rasa core 0.8.2 docs.

This is the connector code:

class BotOutput(OutputChannel):	
    def send_text_message(self, message):
	    text = message
	    return(text)


class BotInput(HttpInputComponent):	
    def blueprint(self, on_new_message):
	    from flask import Flask, request, Response
	    bot_webhook = Blueprint('bot_webhook', __name__)
	
	    @bot_webhook.route('/', methods = ['GET'])
	    def health():
		    return jsonify({'status':'ok'})


	    @bot_webhook.route('/bot/events', methods = ['POST'])
	    def event():
		    data = request.get_json()
		    text = data['text']
		    on_new_message(UserMessage(text, BotOutput()))
		
		    return Response(), 200
		
	    return bot_webhook

And this is the Curl request I want to send : curl -H "Content-Type: application/json" -X POST -d '{"text":"Hello"}' http://127.0.0.1:5004/bot/events and get a reply.

Any help is appreciated.

p.s I know there is no code for security will add it later. First I want to implement the bot in web.

hey @Sayak9495 i made a tutorial video on youtube , you can get it here:

and you can get the code for custom channel here :

https://github.com/JiteshGaikwad/RASA-Chatbot-UI

and if you want to make api call you can read this post :

Hey Thanks for the help. But I guess this is for the latest version of Rasa Core. I’m Using 0.8.2. I’m afraid it doesn’t work for the previous version.

hey @Sayak9495 before it sacres you can you give it a try :sweat_smile:

https://rasa.com/docs/core/0.8.6/http/

Hehe. I did. It raises error: unrecognized arguments: --enable_api. Anyways, I was going to move to the newer version anyway. Let me set up my bot in the newer version. Then I’ll try your method.

ya it will be better😃

Hey! thanks. It’s working now. I’ve got another issue, can you tell me why it’s happening? My custom action is not executing. The name in domain and action.py is correct. I’ve cross checked.

older version runs with rasa_core.server not like currently, rasa_core.run --enable_api

are you running your action server?

python -m rasa_core_sdk.endpoint --actions actions

yeah it’s working now. my actions.py file was inside another directory. Thanks for the help.