3

I am working on a rasa chatbot. For training the chatbot, I added all the training data to the nlu.md file. I added the stories to the stories.md file. I configured the domain.yml file and I also created a few custom actions that the bot should run when the user asks a particular question. Now I trained the chatbot using the rasa train command. This created a zipped file inside the models folder.

I started the NLU server with the following command

rasa run --enable-api -m models/nlu-20190919-171124.tar.gz

For the front end, I am using django to create a web appication for the chatbot.

This is the index.html file

<form class="" action="" method="post">
    {% csrf_token %}
    <input type="text" name="message">
    <button type="submit" name="button">Send</button>
</form>

When the user types a message in the input area and clicks send, this view should run

def index(request):
    if request.method == 'POST':
        user_message = request.POST['message']
        response = requests.get("http://localhost:5005/model/parse",params={"q":user_message})
        print(response)
        return redirect('home')

    else:
        return render(request, 'index.html')

But when I click the send button, I get a 405 error. This is the complete error message from the NLU-server

Traceback (most recent call last):
  File "/Users/sashaanksekar/anaconda3/lib/python3.7/site-packages/sanic/app.py", line 893, in handle_request
    handler, args, kwargs, uri = self.router.get(request)
  File "/Users/sashaanksekar/anaconda3/lib/python3.7/site-packages/sanic/router.py", line 407, in get
    return self._get(request.path, request.method, "")
  File "/Users/sashaanksekar/anaconda3/lib/python3.7/site-packages/sanic/router.py", line 446, in _get
    raise method_not_supported
sanic.exceptions.MethodNotSupported: Method GET not allowed for URL /model/parse

This is the message from my django server.

<Response [405]>

Not sure what I am doing wrong. I am following the steps indicated in the rasa documentation.

Sashaank
  • 571
  • 9
  • 30

1 Answers1

-1

To answer your question, I will simply highlight two lines of your question:

requests.get("http://localhost:5005/model/parse"

and

Method GET not allowed for URL /model/parse

I suggest you read this: https://www.geeksforgeeks.org/get-post-requests-using-python/

Shellsort
  • 11
  • 3
  • 2
    Could you add some context for the link you provided? It might be that the link is broken somewhere down the line. – jakdep Dec 08 '19 at 21:08