The `target` parameter for Telegram Bot is being removed -- template issue?

Just updated and now have some warnings that the suggested repairs don’t work for…not sure how to “fix” it.

I thought I’d got thru all these but apparently previously I had only done ones where the target was using a ‘notify’ and not dynamic.

The problem is I have no “notify.something” to change it to - I am replying dynamically to the user who sent the message. I really hope I don’t now have to do separate automations for every possible user???

  - alias: 'Telegram bot that reply pong to Sensor Low Battery Alerts'
    trigger:
      - platform: event
        event_type: telegram_command
        event_data:
          command: '/check_low_sensor_battery'
    action:
      - service: telegram_bot.send_message
        data_template:
          target: '{{ trigger.event.data.user_id }}'
          message: |
            Check blah

I’m further confused it somehow only complains about 2 of the numerous automations I have that follow this same pattern…for example this one it seems to think is fine:

  # On Demand Status

  - alias: 'Telegram Network Status Query'
    trigger:
      - platform: event
        event_type: telegram_command
        event_data:
          command: '/netstat'
    action:
      - service: telegram_bot.send_message
        data_template:
          target: '{{ trigger.event.data.user_id }}'
          message: |
            Network Status:

Change this:

  - alias: 'Telegram bot that reply pong to Sensor Low Battery Alerts'
    trigger:
      - platform: event
        event_type: telegram_command
        event_data:
          command: '/check_low_sensor_battery'
    action:
      - service: telegram_bot.send_message
        data_template:
          target: '{{ trigger.event.data.user_id }}'
          message: |
            Check blah

To this:

  - alias: 'Telegram bot that reply pong to Sensor Low Battery Alerts'
    triggers: # changed
      - trigger: event  # changed
        event_type: telegram_command
        event_data:
          command: '/check_low_sensor_battery'
    actions:  # changed
      - action: telegram_bot.send_message  # changed
        data:  # changed
          chat_id: '{{ trigger.event.data.user_id }}'  # changed
          message: |
            Check blah

The repair is only about the target part but I also corrected some other legacy format you are using. e.g. data_template has not been used since forever.

Trying to fix this but I still get the warning popup even after fixing it.

I did a search for telegram_bot.send_message in my config folder and only one search comes up. Changed from target: to chat_id. Restarted HA, but the warning still pops up.

Any suggestions on how to further refine the search? What other search perimeters should I be targeting?

update: so I think the issue is that I still have the old telegram bot integration as suggested here.

I see the new telegram bot has been added. Do I just comment out these old lines and nothing else?? My existing automation should use the new telegram bot integration???

  - name: amberthebot
    platform: telegram
    chat_id: !secret telegram_chatid

This repair is also coming up if you are using the old method anywhere too.

Don’t forget to check Alarmo notifications if you use it.

ok. I think I have idea of what I need to do. Has this been address with a fix to migrate over the new telegram bot integration??

.
.
.
  actions:
    - choose:
        - conditions:
            - condition: trigger
              id: mail
          sequence:
            - action: notify.amberthebot 
              data:
                message: "You've got mail!"
                data:
                  inline_keyboard:
                  - 'Received:/received, Mute:/donothing' 

hI @tom_l , any idea why this still results in the persistent notification about target

    - action: notify.home_telegram

      data:
        title: '*Garage Presence*'
        message: Triggered due to presence

That is the depreciated format. Use the new format.

    - action: telegram_bot.send_message
      data:
        chat_id: # your chat id here
        title: '*Garage Presence*'
        message: Triggered due to presence

Thank you, I have changed it to the code below, it works:

 - action: telegram_bot.send_message

    data:
      chat_id: !secret casabot_chatid
      title: '*Garage Warning*'
      message: Garage just opened
1 Like

Hi @tom_l , I have a new bot but with the same chatID as the usual bot I use, but it does not send messages , when I comment out api_key: !secret snifferzbot_api it works but send to the old bot, when it is not commented out, I get no messages, what am I doing wrong?

actions:
    - repeat:
        while:
          - condition: state
            entity_id: device_tracker.galaxy_s24_ultra
            state: "not_home"
        sequence:    
          - action: telegram_bot.send_message

            data:
              chat_id: !secret casabot_chatid
              api_key: !secret snifferzbot_api
              title: '*TwoHourAlertPops*'
              message: This is a two hour check-in alert pops
          - delay: 
              minutes: 1

thanks for your assistance, the previous changes removed the warning and work perfectly.