How do I post user query to rasa core from a frontend i created using flask, css, js?

I have created a custom input channel, i have my flask server running at port 5000 which opens my website or ui. I don’t know how to post user queries to rasa core+nlu model. The model works fine when I run using ‘rasa shell’ command on commandline. I’m new to rasa, any help would be really appreciated.

Hey @divi97, take a look at the channel documentation here. Which channel did you subclass for your custom input channel?

hi @akelad thanks for replying. Initially I was trying to use HttpInputChannel, I found its name was changed in new rasa core version. Nevermind that. Rightnow I’m trying to post user inputs to rasa server using rest. After running rasa server via "rasa run --enable-api --debug --cors “*” and running flask sever in separate consoles when I post requests to rasa server it shows None Type object has no attribute get for sender_id.

When I post messages to rasa server via Postman it works fine

This is my python file for flask server:

from flask import Flask, render_template, url_for, request, jsonify
import requests

app = Flask(__name__)

def hello_world():
	return render_template('home.html')

def chat():
		user_message = request.form['text']
		response ="http://localhost:5005/webhooks/rest/webhook", params ={"message": user_message} )
		print("Something filled1111")
		r = response.json()
		return jsonify({"status":"success","response":response_text})
	except Exception as e:
		return jsonify({"status":"success","response":"Sorry I am not trained to do that yet..."})

if __name__ == "__main__": = True, port = 5000)

Am I missing major things that I can learn to post requests to rasa server? rasa 1.2.7 rasa-core 0.14.5 rasa-nlu 0.15.1 rasa-sdk 1.2.0

@divi97 you need to pass a sender_id along with the message in your post request

@akelad after passing sender_id along with “message” in the above text I’m getting an AttributeError

Traceback (most recent call last):
  File "c:\users\divya\anaconda3\lib\site-packages\sanic\", line 917, in handle_request
    response = await response
  File "c:\users\divya\anaconda3\lib\site-packages\rasa\core\channels\", line 439, in receive
    sender_id = await self._extract_sender(request)
  File "c:\users\divya\anaconda3\lib\site-packages\rasa\core\channels\", line 392, in _extract_sender
    return req.json.get("sender", None)
AttributeError: 'NoneType' object has no attribute 'get'

Also I saw file in site-packages, if the sender_id is not passed i think it sets it automatically to default.

I think you actually need to pass that as a json variable to the post request, and not as params

@akelad Thank you for answering, it works like a charm. Just converted my input going to rasa server using json.dumps() and its working great.

can you guide me how i can display payload buttons in my custom ui?

That’s up to you to process the information from the request - you can take a look at the code for the open source webchat ui: GitHub - mrbot-ai/rasa-webchat: A chat widget easy to connect to chatbot platforms such as Rasa Core

Thanks for the help I’ll see to it.