Slack integration - 500 error

Hi Rasa people!

I am struggling with the integration of my bot to Slack. Could you please check whether I have correctly captured the steps below:

RASA & NGROK

  • install Rasa with: pip install rasa-x --extra-index-url https://pypi.rasa.com/simple
  • start a new project with: rasa init
  • change the credendials.yml file with the Slack chat bot OAuth token and Slack channel ID
  • start rasa with: rasa run. It seems like to start on port 5005
  • Start NGROK on port 5005

SLACK

  • create a workspace, a channel, an app and a bot.
  • add the app to “scope”: channels:read, channels:write, chat:write:bot, chat:write:user (do you know which scopes I need?)
  • re-install the app
  • turn Event subscription ON. Subscribe to workspace events: message.channel , message.groups , message.im and message.mpim)
  • add a request url as such: http://8f34ea92.ngork.io/webhooks/slack/webhook

I get an error 500: " Your URL didn’t respond with the value of the challenge parameter."

Do you know what I am missing? Do I need to change anything in the enpoints.yml file? Do I need to change the rasa api url in the credentials.yml file? Do I need to start an action server? Is this not done automatically by the command rasa run? If so, how to start it and on which port should I start the action server? 5005 or 5055? Do I need to change this in the endpoints.yml file?

I really appreciate the help, All the best!

Arthur

Did you make sure that the token in your credentials is the bot token (starts with xoxob)?

Hi Ella, thank you for your answer! I think i am using the right token, but it starts with xoxb.

Do you only have one credential set up in your credentials.yml? It’s possible it’s loading a different one – can you try running with rasa run --connector slack?

Hi! thanks a lot for your reply. I tried and got the following message. I am not sure what to make of it. My credentials are set up in credentials/yml

C:\Users\hp\Documents\rasa3>rasa run --connector slack Traceback (most recent call last): File “c:\users\hp\anaconda3\lib\runpy.py”, line 193, in _run_module_as_main “main”, mod_spec) File “c:\users\hp\anaconda3\lib\runpy.py”, line 85, in run_code exec(code, run_globals) File "C:\Users\hp\Anaconda3\Scripts\rasa.exe_main.py", line 9, in

File “c:\users\hp\anaconda3\lib\site-packages\rasa_main_.py”, line 70, in m ain cmdline_arguments.func(cmdline_arguments) File “c:\users\hp\anaconda3\lib\site-packages\rasa\cli\run.py”, line 101, in r un rasa.run(**vars(args)) File “c:\users\hp\anaconda3\lib\site-packages\rasa\run.py”, line 59, in run **kwargs File “c:\users\hp\anaconda3\lib\site-packages\rasa\core\run.py”, line 139, in serve_application input_channels = create_http_input_channels(channel, credentials) File “c:\users\hp\anaconda3\lib\site-packages\rasa\core\run.py”, line 36, in c reate_http_input_channels return [_create_single_channel(channel, all_credentials.get(channel))] File “c:\users\hp\anaconda3\lib\site-packages\rasa\core\run.py”, line 45, in _ create_single_channel return BUILTIN_CHANNELS[channel].from_credentials(credentials) File “c:\users\hp\anaconda3\lib\site-packages\rasa\core\channels\slack.py”, li ne 123, in from_credentials cls.raise_missing_credentials_exception() File “c:\users\hp\anaconda3\lib\site-packages\rasa\core\channels\channel.py”, line 151, in raise_missing_credentials_exception cls.name(), cls.name(), DOCS_BASE_URL Exception: To use the slack input channel, you need to pass a credentials file u sing ‘–credentials’. The argument should be a file path pointing to a yml file containing the slack authentication information. Details in the docs: https://ra sa.com/docs/rasa/user-guide/messaging-and-voice-channels/

Ah okay I have an idea of what it could be – can you copy and paste your credentials.yml (you can just put in xxxx… for the bot token

Also this is probably just a typo, but it should be in credentials.yml, not credentials/yml

Thanks a lot. Here you go!


# This file contains the credentials for the voice & chat platforms
# which your bot is using.
# https://rasa.com/docs/rasa/user-guide/messaging-and-voice-channels/

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


#facebook:
#  verify: "<verify>"
#  secret: "<your secret>"
#  page-access-token: "<your page access token>"

#slack:
  slack_token: "xoxb-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  slack_channel: "CL31GLA5D"

#socketio:
#  user_message_evt: <event name for user message>
#  bot_message_evt: <event name for but messages>
#  session_persistence: <true/false>

rasa:
  url: "http://localhost:5002/api"

Sorry I just saw this! From what you sent here it looks like slack: is commented out which is probably causing problems. Then you can run with rasa run --connector slack

to be precise :

  1. setup the credentials for slack (you did it already)

  2. run ngrok and copy/paste the URL of the tunnel inside credentials.yml

  3. save the file credentials.yml

  4. run rasa run actions -vv to handle the actions

  5. run rasa run -vv to start rasa and ALL the connectors

  6. eventually set the URLs from ngrok inside the slack admin console : https://api.slack.com/apps/YOUR_APP_ID

  7. open slack and the channel running your bot

  8. start conversing with your bot :slight_smile:

Now it should work!

Hi Ella!

I am having the same problem and even though everything is the same as you and the thread’s owner stated here, I still cannot run rasa run --connector slack.

This is what I got:

    2020-03-02 14:57:55 INFO     root  - Connecting to channel 'slack' which was specified by the '--connector' argument. Any other channels will be ignored. To connect to all given channels, omit the '--connector' argument.Traceback (most recent call last): File "/Users/mac/venv/bin/rasa", line 8, in <module>
    sys.exit(main())
  File "/Users/mac/venv/lib/python3.7/site-packages/rasa/__main__.py", line 76, in main
    cmdline_arguments.func(cmdline_arguments)
  File "/Users/mac/venv/lib/python3.7/site-packages/rasa/cli/run.py", line 114, in run
    rasa.run(**vars(args))
  File "/Users/mac/venv/lib/python3.7/site-packages/rasa/run.py", line 56, in run
    **kwargs,
  File "/Users/mac/venv/lib/python3.7/site-packages/rasa/core/run.py", line 162, in serve_application
    input_channels = create_http_input_channels(channel, credentials)
  File "/Users/mac/venv/lib/python3.7/site-packages/rasa/core/run.py", line 47, in create_http_input_channels
    return [_create_single_channel(channel, all_credentials.get(channel))]
  File "/Users/mac/venv/lib/python3.7/site-packages/rasa/core/run.py", line 56, in _create_single_channel
    return BUILTIN_CHANNELS[channel].from_credentials(credentials)
  File "/Users/mac/venv/lib/python3.7/site-packages/rasa/core/channels/slack.py", line 123, in from_credentials
    cls.raise_missing_credentials_exception()
  File "/Users/mac/venv/lib/python3.7/site-packages/rasa/core/channels/channel.py", line 126, in raise_missing_credentials_exception
    cls.name(), cls.name(), DOCS_BASE_URL
Exception: To use the slack input channel, you need to pass a credentials file using '--credentials'. The argument should be a file path pointing to a yml file containing the slack authentication information. Details in the docs: https://rasa.com/docs/rasa/user-guide/messaging-and-voice-channels/

Am I still missing something?

@mia.le0711 did you configure the credentials (with slack: not commented out)?

I changed the last command in credentials.yml to rasa: url: “http://localhost:5005/webhook

And it works! :slight_smile:

@erohmensing So, I’m having the same issue as well. When I have the --debug flag up when connecting to Slack, the bot actually recognizes my responses, but there it’s not responding on the actual Slack workspace. My credentials.yml file only has the token as well as the rasa url webhook. My endpoints file have the action_endpoint set to localhost:5005. My ngrok server is also on 5005.

On the Slack API site, I have my ngrok link set up in the Event Subscriptions page. Like I said, the bot on Slack is actually recognizing my inputs, but it’s not responding. In the debug logs only, it is responding. Please let me know if you have a solution ASAP.

I’m also having troubles connecting to Slack using Rasa X and docker-compose

RASA_X_VERSION=0.33.1
RASA_VERSION=2.0.2

I have done all the configurations as in the documentation but unfortunately I’m not able to send and receive messages successfully.

I have already implemented my bot to use Google Chat, Microsoft Teams, Telegram, socketio and Facebook Messenger, so I know that my webhook is working. However, Slack won’t seem to work.

Here is the log from the running container rasa_nginx_1:

3.85.169.219 - - [01/Feb/2021:17:45:06 +0000] "POST /webhooks/slack/webhook HTTP/1.1" 500 250 "-" "Slackbot 1.0 (+https://api.slack.com/robots)"

Here is the error message from rasa_rasa-production_1:

    [2021-02-01 17:45:06 +0000] [1] [ERROR] Exception occurred while handling uri: 'http://<dns>/webhooks/slack/webhook'
Traceback (most recent call last):
  File "/opt/venv/lib/python3.7/site-packages/sanic/app.py", line 973, in handle_request
    response = await response
  File "/opt/venv/lib/python3.7/site-packages/rasa/core/channels/slack.py", line 422, in webhook
    user_message, metadata["users"]
  File "/opt/venv/lib/python3.7/site-packages/rasa/core/channels/slack.py", line 230, in _sanitize_user_message
    for uid_to_remove in uids_to_remove:
TypeError: 'NoneType' object is not iterable
[2021-02-01 17:45:06 +0000] [1] [ERROR] Exception occurred while handling uri: 'http://<dns>/webhooks/slack/webhook'
Traceback (most recent call last):
  File "/opt/venv/lib/python3.7/site-packages/sanic/app.py", line 973, in handle_request
    response = await response
  File "/opt/venv/lib/python3.7/site-packages/rasa/core/channels/slack.py", line 422, in webhook
    user_message, metadata["users"]
  File "/opt/venv/lib/python3.7/site-packages/rasa/core/channels/slack.py", line 230, in _sanitize_user_message
    for uid_to_remove in uids_to_remove:
TypeError: 'NoneType' object is not iterable
[2021-02-01 17:46:07 +0000] [1] [ERROR] Exception occurred while handling uri: 'http://<dns>/webhooks/slack/webhook'
Traceback (most recent call last):
  File "/opt/venv/lib/python3.7/site-packages/sanic/app.py", line 973, in handle_request
    response = await response
  File "/opt/venv/lib/python3.7/site-packages/rasa/core/channels/slack.py", line 422, in webhook
    user_message, metadata["users"]
  File "/opt/venv/lib/python3.7/site-packages/rasa/core/channels/slack.py", line 230, in _sanitize_user_message
    for uid_to_remove in uids_to_remove:
TypeError: 'NoneType' object is not iterable
[2021-02-01 17:51:07 +0000] [1] [ERROR] Exception occurred while handling uri: 'http://<dns>/webhooks/slack/webhook'
Traceback (most recent call last):
  File "/opt/venv/lib/python3.7/site-packages/sanic/app.py", line 973, in handle_request
    response = await response
  File "/opt/venv/lib/python3.7/site-packages/rasa/core/channels/slack.py", line 422, in webhook
    user_message, metadata["users"]
  File "/opt/venv/lib/python3.7/site-packages/rasa/core/channels/slack.py", line 230, in _sanitize_user_message
    for uid_to_remove in uids_to_remove:
TypeError: 'NoneType' object is not iterable

I have replaced my dns with <dns>

Here is the file credentials.yml:

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

rasa:
  url: ${RASA_X_HOST}/api

telegram:
  access_token: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  verify: "xxxxxxxxxxxxx"
  webhook_url: "https://<dns>/webhooks/telegram/webhook"

hangouts:

facebook:
  verify: "xxxxxxxxxxxxx"
  secret: "xxxxxxxxxxxxxxxxxxxxxxx"
  page-access-token: "xxxxxxxxxxxxxxxxxxxxxxxxx"

botframework:
  app_id: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  app_password: "xxxxxxxxxxxxxxxxxxxxxxxxxx"

slack:
  slack_token: "xoxb-xxxxxxxxxxxxxxxxxxxxxxxxxxx"
  slack_channel: "C01KK9E6VAP"
  slack_signing_secret: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

socketio:
  user_message_evt: user_uttered
  bot_message_evt: bot_uttered
  session_persistence: true/false

Any tips to fix this?

Best regards, Robyn

Hi Robyn, this issue was pointed out here: Update Slack Connector to new Slack Events API · Issue #6961 · RasaHQ/rasa · GitHub

It was fixed in version 2.1.0, so updating to that version or newer (and a compatible Rasa X version) should fix it.

Thank you very much! I’ll try that out

1 Like