Rasa X docker cors issue / webchat / socket.io

We have a problem integrating Rasa X into our website via botfront/webchat.

The error seems to be caused by CORS. Rasa X is running on a Linux 18.04 VM on Google Cloud Platform. Another forum entry proposed the following command: rasa run -m models --enable-api --cors "*" --debug

How do we run this from Rasa X, which is running containerized with Docker?

We have used the following code from botfront/webchat:

<div id="webchat"></div>
<script src="https://cdn.jsdelivr.net/npm/rasa-webchat/lib/index.min.js"></script>
<script>
  WebChat.default.init({
    selector: "#webchat",
    initPayload: "/get_started",
    customData: {"language": "en"}, // arbitrary custom data. Stay minimal as this will be added to the socket
    socketUrl: "http://35.xxx.xxx.x", // server ip adress here
    socketPath: "/socket.o/",
    title: "Title",
    subtitle: "Subtitle",
  })
</script>

Our credentials.yml looks like this:

rest:
#  # you don't need to provide anything here - this channel doesn't
#  # require any credentials

# ...

# according to https://rasa.com/docs/rasa/connectors/your-own-website/
socketio:
  user_message_evt: user_uttered
  bot_message_evt: bot_uttered
  session_persistence: true

#...

# This entry is needed if you are using Rasa X. The entry represents credentials 
# for the Rasa X "channel", i.e. Talk to your bot and Share with guest testers.
rasa:
  url: "${RASA_X_HOST}/api"

In our docker-compose.yml (see downwards) file cors is already enabled, but it still doesn’t work.

x-rasa-services: &default-rasa-service
  restart: always
  image: "rasa/rasa:${RASA_VERSION}-full"
  expose:
    - "5005"
  command: >
    x
    --no-prompt
    --production
    --config-endpoint http://rasa-x:5002/api/config?token=${RASA_X_TOKEN}
    --port 5005
    --jwt-method HS256
    --jwt-secret ${JWT_SECRET}
    --auth-token '${RASA_TOKEN}'
    --cors "*"
  depends_on:
    - rasa-x
    - rabbit
    - redis
1 Like

Hi @jackpotandy, it looks like the socketPath in the botfront code you’ve shared has a typo with /socket.o/. Can you check if this is properly configured to /socket.io/?

Hi @b-quachtran, thanks. I already checked it and it is just a typo here in the forum not in the code.

Hi @jackpotandy, please where can you find the conversations users have with your bot through webchat ? I can’t find them on Rasa X.

Thanks.