All,
I have built bot using Rasa (version-1.10.8) frame work using python(version - 3.6.4.).Trying to deploy it on web using flask, however not able establish connectivity.
Bot is working absolutely fine in the console.`from flask import Flask, request, render_template, Response.
- Rasa server is running on port http://localhost:5005
- started server using 'rasa run -m models --enable-api --endpoints endpoints.yml
- Actions server is running(command used rasa run actions)
- below code is in run.py which is under root folder of the project.
ISSUE -
- After receiving text from web page, it is not getting passed to Rasa.
- Hard coded content is also not getting sent back to web page.
import json
from flask import Flask, request, render_template, Response
app = Flask(__name__)
@app.route('/', methods = ['POST', 'GET'])
def index():
return render_template('index.html')
@app.route('/',methods = ['POST','GET'])
def index_get():
val = str(request.args.get('text'))
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
data = json.dumps({"sender": "Rasa", "message": val})
res = request.post('http://localhost:5005/webhooks/rest/webhook', data=data, headers=headers)
res = res.json()
val = res[0]['text']
return render_template('index.html', val=val)
if __name__ == '__main__':
app.run()(debug=True)`
using simple html page. This is present in templates/index.html
<html>
<head>
<title>CHATBOT</title>
</head>
<body>
<h1>CHATBOT</h1>
<form>
<label for="text">You:</label><br>
<input type="text" id="text" name="text"><br>
<p>{{val}}</p>
</form>
</body>
</html>
rasa run --debug- amn41