Has anyone managed to edit a telegram message sent that is not the last one?
I have an automation that send me a “Door open” message with the timestamp.
I would like to edit that message when the door closes, not sending another message but editing the old one adding the closing timestamp.
I tried to get the message_id of the notification sent when opening the door and store that in a input_number without any result.
It’s possible, but it’s a bit tricky. You need to know the message id (and potentially chat id) of the original message that you want to edit.
Step 0. Create twoinput_numbers, one for saving message id and another for chat id.
Step 1. When you are sending your message you should add a message_tag to it.
Step 2. Create an automation to listen to telegram_sent event. And if received message_tag is the same as the one you sent on Step 1, then you save the message id and chat id in your two input_numbers that you created on Step 0.
Step 3. Now you can edit the message since you have message id and chat id of the original message. You can edit by calling telegram_bot.edit_message service.
More info here.
I hope it helps. Gets more tricky if you send a message to more than one person .
This is ingenious. It’s a shame it doesn’t scale. The telegram service should return the id in the service call (and allow media editing while I’m wishing for stuff).