0
votes

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.

  1. Rasa server is running on port http://localhost:5005
  2. started server using 'rasa run -m models --enable-api --endpoints endpoints.yml
  3. Actions server is running(command used rasa run actions)
  4. below code is in run.py which is under root folder of the project.

ISSUE -

  1. After receiving text from web page, it is not getting passed to Rasa.
  2. 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>
1
Index file: <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> - techno_mad
"After receiving text from web page, it is not getting passed to Rasa" Is the API call to Rasa being made? you can check this by inspecting the 'network' tab in your browser's developer tools, and/or by running your rasa server with rasa run --debug - amn41
Do I need to do any changes in server.py under rasa folder? - techno_mad

1 Answers

0
votes

instead of using this

rasa run -m models --enable-api --endpoints endpoints.yml

use this

rasa run -m models --credentials credentials.yml --enable-api --cors '*'