Anyone know how to get a reminder working with Telegram?

I’ve tried posting this in the relevant forum but didn’t get a reply, which is fine, but just thought I might try here before giving up on the idea.

I am trying to setup Telegram reminders using this code:

  - service: telegram_bot.send_message
    data_template:
      title: 'Black Sacks'
      target: xx
      message: 'Black sacks waste collection tomorrow! Do you want a reminder?'
      inline_keyboard:
        - "Yes 30 Minutes:/30m, Yes 1 Hour:/1h, Yes In the morning:/8h"
        - "No need!:/removekeyboard"

with the callback here:

  - id: 'telegramrepeat8h'
    alias: 'Telegram callback to repeat message in 8 hours'
    hide_entity: true
    trigger:
      platform: event
      event_type: telegram_callback
      event_data:
        data: '/8h'
    action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'OK, reminding you in the morning'
    - service: telegram_bot.edit_replymarkup
      data_template:
        message_id: '{{ trigger.event.data.message.message_id }}'
        chat_id: '{{ trigger.event.data.user_id }}'
        inline_keyboard: []
    - delay: '08:00:00'
    - service: notify.telegram
      data_template:
        data:
          message: '{{ trigger.event.data.message.text }}'

but I don’t find the delay ever triggers a message? Everything else works, I get the message “OK, reminding you in the morning” and the keyboard disappears…

Change:

- service: notify.telegram
  data_template:
    data:
      message: '{{ trigger.event.data.message.text }}'

to:

- service: telegram_bot.send_message
  data_template:
    data:
      message: '{{ trigger.event.data.message.text }}'

Also, not sure if you actually need “data:” in there either. It could be just:

- service: telegram_bot.send_message
  data_template:
     message: '{{ trigger.event.data.message.text }}'

thanks - still doesn’t seem to work - have amended to

  - id: 'telegramrepeat8h'
    alias: 'Telegram callback to repeat message in 8 hours'
    hide_entity: true
    trigger:
      platform: event
      event_type: telegram_callback
      event_data:
        data: '/8h'
    action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'OK, reminding you in the morning'
    - service: telegram_bot.edit_replymarkup
      data_template:
        message_id: '{{ trigger.event.data.message.message_id }}'
        chat_id: '{{ trigger.event.data.user_id }}'
        inline_keyboard: []
    - delay: '08:00:00'
    - service: telegram_bot.send_message
      data_template:
        data:
          message: '{{ trigger.event.data.message.text }}'

if anyone’s got any bright ideas I’m all ears!! :slight_smile: :slight_smile:

It’s not a big deal but it’s weird that it doesn’t seem to work

I think it is your last service. I have the same automation just with an hour delay and for a different entity. The only difference between your automation and mine is the last service. I think the message needs to be moved up in your sequence.

- service: telegram_bot.send_message
    data_template:
      message: '{{ trigger.event.data.message.text }}'
      data:
        inline_keyboard:
          - 'Lock:/FrontDoor, Lock ALL:/AllDoors'
          - 'Snooze 30 mins:/30mfrontdoor, Snooze 1 hour:/1hfrontdoor, Ignore:/ignorefrontdoor' 
          - 'RETURN TO HOME:/start2'  

Thanks - have amended to:

    - service: telegram_bot.send_message
      data_template:
        message: '{{ trigger.event.data.message.text }}'

checking now to see if that has fixed it. :slight_smile: Thank you

That did it! Thanks! Seems like it was the empty “data”!

Is there no way of using a template, to save the number of automations needed?
Like, I want an automation that will set the delay according to the answer in the inline_keyboard…

So, what I’m asking is, can you use a template here:
trigger:
platform: event
event_type: telegram_callback
event_data:
data: <> ???