Telegram Bot usage

Hello,

I have a Telegram “send message” and after another trigger a “delete message” of the stored message_id of this related sent message running in NodeRed.

Now I wanted to migrate this to HA. Send message part is working.
Not with a delete delay of a first message!

A) Is there a complete example available to send a message AND store the used message_ ID after a first trigger.

B)
Then in another automation of another trigger how to retrieve the stored message_ ID and use it for the delete message command of Telegram Bot?

I could not solve it with the current Telegram Bot documentation.

Thanks so far!

After playing around with HA I found my current solution.
Using NodeRed and Homematic so far I was not so familar with the HA limitations of variables and response value handling/usage.

perhaps it helps others:

I used the HA add-on "Saver" for variables valid outside the Action and after HA restart.

A)
sending the message an getting the response in the variable "response"

action: telegram_bot.send_message
data:
  message: a test message
  entity_id:
    - notify.homeassistant_ID1
response_variable: response

saving response sequence to Saver-variable: TelegramID

action: saver.set_variable
metadata: {}
data:
  name: TelegramID
  value: "{{ response }}"

Hint: the TelegramID is now a string and no usable sequence/list anymore

B)
deleting the telegram message later with the message_id from the stored TelegramID:

action: telegram_bot.delete_message
metadata: {}
data:
  message_id: >-
    {{ (saver_variable("TelegramID") | replace('\'','"') |
    from_json).chats[0].message_id }}

if the original message was sent to more recipients the second is addressed with chats[1] etc.

Have fun.