How to loop a automation of Telegrambot

Hello,
I want to loop my automation. When network devices are turned off I want the telegram bot to send a message something like: There is a problem with a network device. I already have that working. Now I want to loop the message until someone answers in the group chat: Ok or Stop. I was looking for other topics but i cant figure it out. I am new to home assistant. Can someone help me out?
this is what i have( currently used with a dummy switch).

- id: '1585574182630'
  alias: teststan
  description: ''
  trigger:
  - entity_id: switch.dummy
    from: 'on'
    platform: state
    to: 'off'
  condition: []
  action:
  - data:
      message: Test
    service: notify.wifibot

Stan

Change your automation to turn on a different automation.

- id: '1585574182630'
  alias: teststan
  description: ''
  trigger:
  - entity_id: switch.dummy
    from: 'on'
    platform: state
    to: 'off'
  condition: []
  action:
  - service: automation.turn_on
    entity_id: automation.telegram_spam_bot

This automation just runs on a timer. The only way for it to stop running is to turn it off

- alias: telegram_spam_bot
  trigger:
    # This automation runs every 5 minutes if it's enabled....
    - platform: time_pattern
      # "/X" means when the field is divisible by this number, it triggers.
      # So in this case, a XX:05, XX:10, XX:15 ....
      minutes: "/5"
  action:
  - data_template:
      message: |-
        {% set name = state_attr('switch.dummy', 'friendly_name') %}
        Hello, you have subscribed to  {{ name }} facts.
        Did you know, {{ name }}'s favorite thing is to not be off?
        Well, it's off. 
        Respond 'OK' to unsubscribe from {{ name }} facts!
    service: notify.wifibot
    

Finally, one more automation to receive messages on telegram to turn that one off. I do not use telegram, so you’ll have to figure this one out.

- alias: 'Telegram bot that simply acknowledges'
  trigger:
    # The secret sauce to parse telegram replies for you to figure out!!
  action:
    - service: automation.turn_off
      entity_id: automation.telegram_spam_bot
1 Like

Hello @jocnnor Thanks for you help, your awesome. It works!