diff --git a/source/_integrations/telegram_bot.markdown b/source/_integrations/telegram_bot.markdown index b847a67bbe4..52b127a598b 100644 --- a/source/_integrations/telegram_bot.markdown +++ b/source/_integrations/telegram_bot.markdown @@ -20,6 +20,8 @@ If you don't need to receive messages, you can use the [broadcast](/integrations Available actions: `send_message`, `send_photo`, `send_video`, `send_animation`, `send_voice`, `send_sticker`, `send_document`, `send_location`, `edit_message`, `edit_caption`, `edit_replymarkup`, `answer_callback_query`, `delete_message` and `leave_chat`. +Actions that send contents (`send_*`) will return a list of `message_id`/`chat_id` for messages delivered (in a property called `chats`). This will populate [Response Data](/docs/scripts/perform-actions#use-templates-to-handle-response-data) that you can further utilize in your automations to edit/delete the message later based on the `message_id`. See the example later on this page for usage instructions. + ### Action `telegram_bot.send_message` Send a notification. @@ -608,3 +610,27 @@ actions: parse_mode: html disable_web_page_preview: true ``` + +## Example: automation to send a message and delete after a delay + +{% raw %} + +```yaml +alias: telegram send message and delete +sequence: + - action: telegram_bot.send_message + data: + message: testing + response_variable: response + - delay: + seconds: 5 + - repeat: + sequence: + - action: telegram_bot.delete_message + data: + message_id: "{{ repeat.item.message_id }}" + chat_id: "{{ repeat.item.chat_id }}" + for_each: "{{ response.chats }}" +``` + +{% endraw %}