Behavior of CallbackInput channel

I’m experimenting with the CallbackInput channel as described in Your Own Website.

I have a question about the general behavior of Callbacks in Rasa. My expectation was that rasa will return the “success” message when it successfully receives a properly formatted message with all required fields to the callback endpoint ‘webhooks/callback/webhook’, without waiting for the messaged to be successfully parsed and a reply formulated by nlu+core.

However, a simple test shows me that not only rasa would process the message but attempt to deliver the reply to the designated callback endpoint before sending the “success” message to the original caller.

i.e. if there are delays in either processing or delivering the message to the callback endpoint, the original REST call to ‘webhooks/callback/webhook’ will be blocking.

test: Create a dummy flask ‘print’ endpoint for receiving callbacks.

@app.route("/print", methods=["POST"])
def echo():
    try:
        data = request.json
        print(f"received {data}")
        sleep(10) # dummy wait for 10 secs 
        return jsonify("Got it!")
    except Exception as e:
        print("Error!", e)
        return jsonify("error")

Add the callback url in the credentials file:

callback:
  # URL to which Core will send the bot responses
  url: "http://localhost:5000/print"

When I call ‘http://localhost:5005/webhooks/callback/webhook’ with the message, it waits for 10s to return “success” indicating that the call is not async.

Is this desired behavior, and why?

Thanks,

I’m pretty sure this is how the callback is going to work since you are putting a sleep in there before returning.

What are you expecting to happen I guess is my question from this custom code you displayed?

Also if you are just wanting a bot on a website using the socketio with the webchat widgets out there might be a better option.

Does anyone have the answer to this topic? I have the same issue, that the bot send the response after the success message has been sent. That causes me some dificulties because the bot is already trying to answer to the response of the second message and not the first one.

Thank you

Can anyone please give some feedback on this issue? I’m still having the same error.

1 Like