Rasa making authorised requests to Telegram API but logs report "Invalid access token"?

I installed Rasa 1.9.6, generated the default project as described in the Rasa Basics tutorial. I confirmed this works in the shell.

I also have a bot on Telegram, and have confirmed the bot works using a separate library.

I ran Rasa with my bot details in credentials.yml using ngrok to tunnel webhook requests to localhost.

Everything seems to work, from the debug output I can see the webhook is set up.

2020-04-22 12:17:10 DEBUG    telegram.bot  - Entering: set_webhook
2020-04-22 12:17:10 DEBUG    telegram.vendor.ptb_urllib3.urllib3.connectionpool  - Starting new HTTPS connection (1): api.telegram.org
2020-04-22 12:17:12 DEBUG    telegram.vendor.ptb_urllib3.urllib3.connectionpool  - https://api.telegram.org:443 "POST /bot<mytoken>/setWebhook HTTP/1.1" 200 57
2020-04-22 12:17:12 DEBUG    telegram.bot  - True
2020-04-22 12:17:12 DEBUG    telegram.bot  - Exiting: set_webhook

All good so far, but I don’t see any response in Telegram. Each time I send the bot a message in Telegram I can see Rasa performs a GET to /bot<myid>/getMe e.g.

2020-04-22 12:17:26 DEBUG    telegram.bot  - Entering: get_me
2020-04-22 12:17:26 DEBUG    telegram.vendor.ptb_urllib3.urllib3.connectionpool  - https://api.telegram.org:443 "GET /bot<mycredentials>/getMe HTTP/1.1" 200 196
2020-04-22 12:17:26 DEBUG    telegram.bot  - {'id': 1150041222, 'first_name': 'InChatBot', 'is_bot': True, 'username': 'InChatDesignBot'}
2020-04-22 12:17:26 DEBUG    telegram.bot  - Exiting: get_me
2020-04-22 12:17:26 DEBUG    rasa.core.channels.telegram  - Invalid access token, check it matches Telegram
2020-04-22 12:21:20 DEBUG    telegram.bot  - Entering: get_me
2020-04-22 12:21:20 DEBUG    telegram.vendor.ptb_urllib3.urllib3.connectionpool  - https://api.telegram.org:443 "GET /bot<mycredentials>/getMe HTTP/1.1" 200 196
2020-04-22 12:21:20 DEBUG    telegram.bot  - {'id': 1150041222, 'first_name': 'InChatBot', 'is_bot': True, 'username': 'InChatDesignBot'}
2020-04-22 12:21:20 DEBUG    telegram.bot  - Exiting: get_me
2020-04-22 12:21:20 DEBUG    rasa.core.channels.telegram  - Invalid access token, check it matches Telegram

In logs above it looks like the getMe requests works fine, but then there’s the line saying rasa.core.channels.telegram - Invalid access token, check it matches Telegram - ???

Another thing I notice is that when I inspect the POST requests to the Rasa webook endpoint on ngrok it says the response is 200 OK but then the response content is failed - ???

Can someone point me in the right direction?

Edit: Something that might be relevant is a warning I get when I first run rasa 2020-04-22 12:17:12.614709: E tensorflow/stream_executor/cuda/cuda_driver.cc:351] failed call to cuInit: UNKNOWN ERROR (303)

Edit 2: Another thing I hadn’t notice in logs until now is the following:

2020-04-22 14:50:00 DEBUG    rasa.nlu.classifiers.diet_classifier  - Failed to load model for 'ResponseSelector'. Maybe you did not provide enough training data and no model was trained or the path '/tmp/tmputhg6qvt/nlu' doesn't exist?

I tried running rasa with the API enabled: rasa run -vv --enable-api. It returns a response when I send requests via curl:

$ curl -d '{ "text": "Hello", "message_id": "b2831e73-1407-4ba0-a861-0f30a42a2a5a" }' -H "Content-Type: application/json" -X POST http://localhost:5005/model/parse

{"intent":{"name":"greet","confidence":0.9954654574},"entities":[],"intent_ranking":[{"name":"greet","confidence":0.9954654574},{"name":"bot_challenge","confidence":0.0036696936},{"name":"mood_great","confidence":0.0003250062},{"name":"goodbye","confidence":0.0002903836},{"name":"mood_unhappy","confidence":0.0001085473},{"name":"affirm","confidence":0.0001025955},{"name":"deny","confidence":0.0000382178}],"response_selector":{"default":{"response":{"name":null,"confidence":0.0},"ranking":[],"full_retrieval_intent":null}},"text":"Hello"}

Not sure why Telegram is not working as expected, but I can ensure that the two things you pointed out in the edits are not the reason for the failure. The first one is just a tensorflow warning related to cuda and the second warning, just informs you that you have listed a ResponseSelector in your config file, but no data for it.

1 Like

Hello @digitalWestie!

What we do before showing this debug message is we basically just check if the username of your bot (which is InChatDesignBot in your case) matches the verify value in your credentials.yml Can you please check and confirm that the value of verify is InChatDesignBot there?

1 Like

@Tanja thank you for confirming those are just warnings!

@alwx it was set to ‘InChatBot’, I have corrected this value and now it’s working.

I’m absolutely convinced earlier on I had this name!! I think in my experimentation with settings I fixed an earlier problem, but then broken it again by inserting the wrong bot name. Can’t believe I got caught out like this!

Thank you both for your help!

having same issue as mentioned above, but did not resolve. I have checked access token as well as varify.