0

I am trying to call a callback URL from a python function.

Here is the code:

rasa_url = "http://localhost:5005/webhooks/callback/webhook"
wa_data = {
    "sender":"Rasa",
    "message":"hi"
}
r = requests.post(url=rasa_url, data=wa_data)

In the terminal of rasa run, I am getting below error:

sanic.exceptions.InvalidUsage: Failed when parsing body as json.

I also tried,

r = requests.post(url=rasa_url, data=json.loads(json.dumps(wa_data)))

How can I solve this?

AnsFourtyTwo
  • 2,480
  • 2
  • 13
  • 33
KbiR
  • 4,047
  • 6
  • 37
  • 103

1 Answers1

0

I think your request does not coincide with the documentation. The only one with both sender and message i found is to:

http://localhost:5005/conversations/{conversation_id}/messages

where you can send a JSON in this format (you also have an optional parse_data key)

{
    "text": "Hello!",
    "sender": "user"
}
AnsFourtyTwo
  • 2,480
  • 2
  • 13
  • 33