Trouble Editing/Deleting Telegram Bot Messages: Incorrect message_id Issue

I’m currently encountering an issue with my Telegram bot implemented using Rasa, specifically related to editing or deleting messages. I aim to manage the conversation flow by removing or modifying messages once they’re no longer needed. While Telegram offers functionality for this task, it requires both the chat ID and the message ID. Obtaining the chat ID using tracker.sender_id isn’t an issue, but I’ve run into difficulties with retrieving accurate message IDs for user-sent messages. Furthermore, I’m unable to track messages sent by the bot itself, complicating the process.

Has anyone encountered a similar challenge or found a workaround for obtaining accurate message IDs and managing bot-sent messages within the conversation flow effectively? Any insights or suggestions would be immensely valuable

Working solution Telegram integration with rasa - #2 by fabiolamfleury

Going to post the solution i found:

Implemented a custom input channel in a file called the same folder that the credentials.yml is, with the content:

from rasa.core.channels import TelegramInput
from typing import Text

class TelegramInputChannel(TelegramInput):
    def get_metadata(self, request):
        return metadata

Then, edited my credentials.yml using:

  access_token: "token provided by father bot"
  verify: "bot_username"
  webhook_url: "https://address/webhooks/telegram/webhook"

After that, it was possible to access in actions file:

    telegram_username = tracker.latest_message["metadata"]["from"]["username"] #user that sent the message
    telegram_chat_type = tracker.latest_message["metadata"]["chat"]["type"]
    if telegram_chat_type == 'group':
        is_group = True
    return [
                SlotSet("is_in_telegram_group", is_group),