Telegram [ERROR] Exception occurred while handling uri

Hi all,

I’m using Rasa 1.7.1 connected to telegram.

So far the bot was working fine, recently I started receiving an error and the bot is not responding.

Here the error:

[2020-03-22 09:58:39 +0000] [1] [ERROR] Exception occurred while handling uri: 'http://mybot.example.com/webhooks/telegram/webhook'
Traceback (most recent call last):
  File "/build/lib/python3.6/site-packages/sanic/app.py", line 942, in handle_request
    response = await response
  File "/usr/local/lib/python3.6/asyncio/coroutines.py", line 110, in __next__
    return self.gen.send(None)
  File "/build/lib/python3.6/site-packages/rasa/core/channels/telegram.py", line 215, in message
    if self._is_user_message(msg):
  File "/build/lib/python3.6/site-packages/rasa/core/channels/telegram.py", line 175, in _is_user_message
    return message.text is not None
AttributeError: 'NoneType' object has no attribute 'text'

I did no change anything or restarted the service, and it started behaving like that.

thanks in advance

1 Like

hi @alebeta90, I guess the error is because there was no response from Rasa sever. I mean the response that was received was like:

which should be like:

[
  {"text": "Hey Rasa!"}, {"image": "http://example.com/image.jpg"}
]

It’s missing out the text key :sweat_smile:

(edit: I corrected the bot respons)

you think it could be an error from Telegram that is not sending the message properly?

No, I mean to say the error is from Rasa that it send empty response.

mmmm but it make no sense. why it will send an empty reponse?

hey @alebeta90, can you test the bot on terminal, I mean by running the below command:

rasa shell

just wanted to know whether it’s able to respond or can you restart the server and check on telegram again

the bot is responding, If I use different channel it replies without a problem

1 Like

ok, Sorry :sweat_smile:, I see because I too faced a issue sometimes back(not on telegram but rest channel) and when I checked the trace I got to know the bot was responding with empty response so thought might be same issue.

I just checked the above line from the telegram code:

I got to know from the code it might be from telegram I mean it might not have got the user input

@alebeta90 is it possible your users are sending e.g. voice messages or something? Not sure what that looks like in terms of an API call from telegram, but then the message might be None. If that’s the case we should handle that in our code though

Hi @akelad

thanks for reaching out.

Yesterday I had a nice talk with the guys from python-telegram-bot package about what is happening, and they help me to solve it using the Telegram Bot API.

Basically it seems that Rasa Telegram connector is not handling the Updates properly, and there were some messages which did not receive something call the offset (I think is a reply saying that the message was received maybe) the offset should be set with a number equal to update_id+1. Then what I did was:

  1. Stop Rasa instance
  2. Delete Webhook (Telegram Bot API)
  3. Update offset value(update_id)(Telegram Bot API)
  4. start rasa again

I think something should be solve on the side of the Telegram connector in this function

All the best

1 Like

@alebeta90 thanks for investigating! would you mind creating an issue on github?

@alebeta90 just checking, did you create a github issue?

Hi @akelad

thanks for the reminder, I will proceed to do so, during the weekend

all the best

did u solve the issue, am also facing this problem?.