Exception connecting Facebook messenger to Rasa Core

I deployed Rasa Core, Rasa NLU and Action Server using Docker. Everything seems to be fine, but when I tried to connect the Facebook messenger I get this inspecting the core logs

root@baseai-demo-01:/home/airoot/baseai/baseai_demo# docker logs rasa_core
2019-03-22 21:58:32 INFO     root  - Starting Rasa Core server on http://localhost:5005
2019-03-22 21:58:32 INFO     sanic.root  - Goin' Fast @ http://0.0.0.0:5005
[2019-03-22 21:58:32 +0000] [1] [INFO] Goin' Fast @ http://0.0.0.0:5005
2019-03-22 21:58:32.206173: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
[2019-03-22 21:58:34 +0000] [1] [INFO] Starting worker [1]
2019-03-22 21:58:34 INFO     sanic.root  - Starting worker [1]
2019-03-22 21:58:35 ERROR    sanic.root  - Exception occurred while handling uri: 'http://someurl:443/webhooks/facebook/webhook'
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/sanic/app.py", line 750, in handle_request
    response = await response
  File "/app/rasa/core/channels/facebook.py", line 270, in webhook
    if not self.validate_hub_signature(self.fb_secret, request.data,
AttributeError: 'Request' object has no attribute 'data'
[2019-03-22 21:58:35 +0000] [1] [ERROR] Exception occurred while handling uri: 'http://someurl:443/webhooks/facebook/webhook'
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/sanic/app.py", line 750, in handle_request
    response = await response
  File "/app/rasa/core/channels/facebook.py", line 270, in webhook
    if not self.validate_hub_signature(self.fb_secret, request.data,
AttributeError: 'Request' object has no attribute 'data'
[2019-03-22 21:59:10 +0000] [1] [ERROR] Exception occurred in one of response middleware handlers
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/sanic/app.py", line 791, in handle_request
    request, response
  File "/usr/local/lib/python3.6/site-packages/spf/framework.py", line 543, in _run_response_middleware
    _response = await _response
  File "/usr/local/lib/python3.6/site-packages/sanic_cors/extension.py", line 266, in unapplied_cors_response_middleware
    set_cors_headers(req, resp, context, res_options)
  File "/usr/local/lib/python3.6/site-packages/sanic_cors/core.py", line 248, in set_cors_headers
    if resp.headers is None:
AttributeError: 'str' object has no attribute 'headers'
2019-03-22 21:59:10 ERROR    sanic.error  - Exception occurred in one of response middleware handlers
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/sanic/app.py", line 791, in handle_request
    request, response
  File "/usr/local/lib/python3.6/site-packages/spf/framework.py", line 543, in _run_response_middleware
    _response = await _response
  File "/usr/local/lib/python3.6/site-packages/sanic_cors/extension.py", line 266, in unapplied_cors_response_middleware
    set_cors_headers(req, resp, context, res_options)
  File "/usr/local/lib/python3.6/site-packages/sanic_cors/core.py", line 248, in set_cors_headers
    if resp.headers is None:
AttributeError: 'str' object has no attribute 'headers'
[2019-03-22 21:59:10 +0000] [1] [ERROR] Invalid response object for url b'/webhooks/facebook/webhook?hub.mode=subscribe&hub.challenge=231761797&hub.verify_token=rasa-bot', Expected Type: HTTPResponse, Actual Type: <class 'str'>
2019-03-22 21:59:10 ERROR    sanic.root  - Invalid response object for url b'/webhooks/facebook/webhook?hub.mode=subscribe&hub.challenge=231761797&hub.verify_token=rasa-bot', Expected Type: HTTPResponse, Actual Type: <class 'str'>
[2019-03-22 21:59:10 +0000] [1] [ERROR] Exception occurred while handling uri: 'http://someurl:443/webhooks/facebook/webhook?hub.mode=subscribe&hub.challenge=231761797&hub.verify_token=rasa-bot'
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/sanic/server.py", line 374, in write_response
    response.output(
AttributeError: 'str' object has no attribute 'output'
2019-03-22 21:59:10 ERROR    sanic.root  - Exception occurred while handling uri: 'http://someurl:443/webhooks/facebook/webhook?hub.mode=subscribe&hub.challenge=231761797&hub.verify_token=rasa-bot'
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/sanic/server.py", line 374, in write_response
    response.output(
AttributeError: 'str' object has no attribute 'output'
[2019-03-22 21:59:41 +0000] [1] [ERROR] Invalid response object for url b'/webhooks/facebook/webhook?hub.mode=subscribe&hub.challenge=699898131&hub.verify_token=rasa-bot', Expected Type: HTTPResponse, Actual Type: <class 'str'>
[2019-03-22 21:59:41 +0000] [1] [ERROR] Exception occurred while handling uri: 'http://someurl:443/webhooks/facebook/webhook?hub.mode=subscribe&hub.challenge=699898131&hub.verify_token=rasa-bot'
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/sanic/server.py", line 374, in write_response
    response.output(
AttributeError: 'str' object has no attribute 'output'
[2019-03-22 21:59:41 +0000] [1] [ERROR] Exception occurred in one of response middleware handlers
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/sanic/app.py", line 791, in handle_request
    request, response
  File "/usr/local/lib/python3.6/site-packages/spf/framework.py", line 543, in _run_response_middleware
    _response = await _response
  File "/usr/local/lib/python3.6/site-packages/sanic_cors/extension.py", line 266, in unapplied_cors_response_middleware
    set_cors_headers(req, resp, context, res_options)
  File "/usr/local/lib/python3.6/site-packages/sanic_cors/core.py", line 248, in set_cors_headers
    if resp.headers is None:
AttributeError: 'str' object has no attribute 'headers'
2019-03-22 21:59:41 ERROR    sanic.error  - Exception occurred in one of response middleware handlers
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/sanic/app.py", line 791, in handle_request
    request, response
  File "/usr/local/lib/python3.6/site-packages/spf/framework.py", line 543, in _run_response_middleware
    _response = await _response
  File "/usr/local/lib/python3.6/site-packages/sanic_cors/extension.py", line 266, in unapplied_cors_response_middleware
    set_cors_headers(req, resp, context, res_options)
  File "/usr/local/lib/python3.6/site-packages/sanic_cors/core.py", line 248, in set_cors_headers
    if resp.headers is None:
AttributeError: 'str' object has no attribute 'headers'
2019-03-22 21:59:41 ERROR    sanic.root  - Invalid response object for url b'/webhooks/facebook/webhook?hub.mode=subscribe&hub.challenge=699898131&hub.verify_token=rasa-bot', Expected Type: HTTPResponse, Actual Type: <class 'str'>
2019-03-22 21:59:41 ERROR    sanic.root  - Exception occurred while handling uri: 'http://someurl:443/webhooks/facebook/webhook?hub.mode=subscribe&hub.challenge=699898131&hub.verify_token=rasa-bot'
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/sanic/server.py", line 374, in write_response
    response.output(
AttributeError: 'str' object has no attribute 'output'

Here my docker-compose.yml version: ‘3.0’

services:
  rasa_core:
container_name: rasa_core
restart: always
image: rasa/rasa_core:latest
ports:
  - 5002:5005
volumes:
  - ./models/rasa_core:/app/models
  - ./config:/app/config
command: start --core models -c facebook --endpoints config/endpoints.yml -u current/ --credentials config/messenger-credentials.yml

  rasa_nlu:
container_name: rasa_nlu
restart: always
image: rasa/rasa_nlu:latest-spacy
volumes:
  - ./models/rasa_nlu:/app/models
  - ./config:/app/config
command: start --path models -c config/nlu_config.yml

  action_server:
build:
  context: .
  dockerfile: Dockerfile
container_name: action_server
restart: always
volumes:
  - ./actions:/app/actions

And here my Dockerfile

FROM rasa/rasa_core_sdk:latest

RUN apt-get update &amp;&amp; apt-get install -y mc nano git

COPY requirements.txt /app/requirements.txt

RUN python -m pip install --upgrade pip &amp;&amp; \

python -m pip install --no-cache-dir requests &amp;&amp; \

python -m pip install --no-cache-dir elasticsearch &amp;&amp; \

python -m pip install -r /app/requirements.txt

RUN python -m spacy download en

Any idea?

@ramsesdm have you had any luck debugging this? I’m wondering if you change request.data to request.json here it’ll do the trick.

Did you ever resolve this issue? I am facing the same issue using docker+messenger.

Hey @Jasmin25. What image are you using? I believe this problem is fixed in the new rasa 1.0.1. If you are still using rasa_core, I think that the issue would appear on latest, but not on any of the tagged versions.

Updating versions resolved this issue. Thanks @erohmensing

1 Like

Glad to hear it :slight_smile: