Twilio integration - problem with sanic?

Hi all I have a chat working the browser, and I am now trying to integrate it Whatsapp through Twilio. But I get the following error

sanic.exceptions.ServerError: Invalid response type None (need HTTPResponse)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/rafa/opt/anaconda3/envs/installingrasa/lib/python3.8/site-packages/sanic/", line 129, in http1
    await self.protocol.request_handler(self.request)
  File "/Users/rafa/opt/anaconda3/envs/installingrasa/lib/python3.8/site-packages/sanic_plugin_toolkit/", line 562, in _handle_request_21_03
    raise cancelled
  File "/Users/rafa/opt/anaconda3/envs/installingrasa/lib/python3.8/site-packages/sanic_plugin_toolkit/", line 550, in _handle_request_21_03
    _ = await real_handle(request)
  File "/Users/rafa/opt/anaconda3/envs/installingrasa/lib/python3.8/site-packages/sanic/", line 791, in handle_request
    await self.handle_exception(request, e)
  File "/Users/rafa/opt/anaconda3/envs/installingrasa/lib/python3.8/site-packages/sanic/", line 704, in handle_exception
    await response.send(end_stream=True)
  File "/Users/rafa/opt/anaconda3/envs/installingrasa/lib/python3.8/site-packages/sanic/", line 122, in send
    await, end_stream=end_stream)
  File "/Users/rafa/opt/anaconda3/envs/installingrasa/lib/python3.8/site-packages/sanic/", line 335, in http1_response_header
    await self._send(ret)

Could it be a problem with the sanic version?

sanic                              21.12.0
Sanic-Cors                         1.0.0
sanic-jwt                          1.7.0
sanic-plugin-toolkit               1.2.0
Sanic-Plugins-Framework            0.9.4.post1
sanic-routing                      0.7.2

I have

Rasa Version      :         3.0.2
Minimum Compatible Version: 3.0.0
Rasa SDK Version  :         3.0.2
Rasa X Version    :         None
Python Version    :         3.8.8
Operating System  :         macOS-10.14.6-x86_64-i386-64bit

@rafa21 can you please see this tutorial video : SETUP RASA CHATBOT ON WHATSAPP - YouTube [ based on rasa 2.x] and please share the complete traceback error if still it persist.

Hi @nik202

Yes, I did watch the tutorial. I also run a curl call to check that a POST is processed correctly (and it is) The following call gets the right response:

curl -X POST -H "Content-Type: application/json"  -d '{"sender": "test_user", "message": "sad"}'`

I also have the web chat running so I can check the rest service works.

I did set up the Twilio service with the same URI I used in curl, so I would expect the same result.

But on Whatsapp I don’t hear back.

Although I am running rasa with the debug option there is no error message.

The Twilio console says it received the message but returns an error: [**11200** There was a failure attempting to retrieve the contents of this URL.](

This should mean a configuration option, but can’t figure out what.

My apologies. I am now getting this error message. This is why I originally thought it was a sanic problem

[2021-12-28 14:39:36 -0300] [4396] [ERROR] Exception occurred while handling uri: ''
Traceback (most recent call last):
  File "/Users/rafa/opt/anaconda3/envs/installingrasa/lib/python3.8/site-packages/sanic/", line 291, in load_json
    self.parsed_json = loads(self.body)
ValueError: Expected object or value

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/rafa/opt/anaconda3/envs/installingrasa/lib/python3.8/site-packages/sanic/", line 770, in handle_request
    response = await response
  File "/Users/rafa/opt/anaconda3/envs/installingrasa/lib/python3.8/site-packages/rasa/core/channels/", line 101, in receive
    sender_id = await self._extract_sender(request)
  File "/Users/rafa/opt/anaconda3/envs/installingrasa/lib/python3.8/site-packages/rasa/core/channels/", line 52, in _extract_sender
    return req.json.get("sender", None)
  File "/Users/rafa/opt/anaconda3/envs/installingrasa/lib/python3.8/site-packages/sanic/", line 285, in json
  File "/Users/rafa/opt/anaconda3/envs/installingrasa/lib/python3.8/site-packages/sanic/", line 295, in load_json
    raise InvalidUsage("Failed when parsing body as json")
sanic.exceptions.InvalidUsage: Failed when parsing body as json