rasa: Telegram buttons problem

Rasa version: Rasa 1.1.4

Python version: Python 3.6.8

Operating system (windows, osx, …): Windows (host)

Issue: Just to further clarify, I’m using Docker instance of the Rasa’s image rasa/rasa:1.1.4-full. And I’m also using Rasa’s implemented connector for Telegram. The Rasa raises the error when it tries to send request to the Telegram to display the buttons. I’m using custom implementation of the action_default_ask_affirmation function and not the default one. This implementation was taken from the rasa-demo (link to the implementation is https://github.com/RasaHQ/rasa-demo/blob/master/demo/actions.py#L445). The only change that I’ve made is that instead of calling:

dispatcher.utter_button_message(message_title, buttons=buttons)

I’m calling:

dispatcher.utter_button_message(message_title, buttons=buttons, button_type="vertical")

In most cases Rasa works perfectly well and the buttons are correctly displayed. But in some cases the following error occurs on the Rasa server (check the error’s traceback below). Those cases are the similar as the one that works. They are similar in the sense that they try to trigger intent with some entity. By printing buttons variable I didn’t saw that anything is wrong with the JSON format.

Error (including full traceback):

2019-07-18 13:15:53 ERROR    rasa.core.channels.telegram  - Exception when trying to handle message.Button_data_invalid
[2019-07-18 13:15:53 +0000] [1] [ERROR] Exception occurred while handling uri: 'http://a063c738.ngrok.io/webhooks/telegram/webhook'
Traceback (most recent call last):
cal/lib/python3.6/site-packages/sanic/app.py", line 917, in handle_request
    response = await response
  File "/usr/local/lib/python3.6/site-packages/rasa/core/channels/telegram.py", line 228, in message
    text, out_channel, sender_id, input_channel=self.name()
  File "/usr/local/lib/python3.6/site-packages/rasa/core/channels/channel.py", line 75, in handler
    await app.agent.handle_message(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/rasa/core/agent.py", line 440, in handle_message
    return await processor.handle_message(message)
  File "/usr/local/lib/python3.6/site-packages/rasa/core/processor.py", line 84, in handle_message
    await self._predict_and_execute_next_action(message, tracker)
  File "/usr/local/lib/python3.6/site-packages/rasa/core/processor.py", line 350, in _predict_and_execute_next_action
    action, tracker, message.output_channel, self.nlg, policy, confidence
  File "/usr/local/lib/python3.6/site-packages/rasa/core/processor.py", line 461, in _run_action
    await self._send_bot_messages(events, tracker, output_channel)
  File "/usr/local/lib/python3.6/site-packages/rasa/core/processor.py", line 382, in _send_bot_messages
    await output_channel.send_response(tracker.sender_id, e.message())
  File "/usr/local/lib/python3.6/site-packages/rasa/core/channels/channel.py", line 179, in send_response
    recipient_id, message.pop("text"), message.pop("buttons"), **message
  File "/usr/local/lib/python3.6/site-packages/rasa/core/channels/telegram.py", line 92, in send_text_with_buttons
    self.send_message(recipient_id, text, reply_markup=reply_markup)
  File "/usr/local/lib/python3.6/site-packages/telegram/bot.py", line 65, in decorator
    result = func(self, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/telegram/bot.py", line 90, in decorator
    result = self._request.post(url, data, timeout=kwargs.get('timeout'))
  File "/usr/local/lib/python3.6/site-packages/telegram/utils/request.py", line 309, in post
    headers={'Content-Type': 'application/json'})
  File "/usr/local/lib/python3.6/site-packages/telegram/utils/request.py", line 223, in _request_wrapper
    raise BadRequest(message)
telegram.error.BadRequest: Button_data_invalid

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (7 by maintainers)

Most upvoted comments

@erohmensing we can check at this link “https://core.telegram.org/bots/api”. InlineKeyboardButton image

I met a similar problem. I recognized that telegram limit payload size so we can not attach data with long text.