Frigate Telegram notifications, perfected - but with quite some work on your side

So i got annoyed that all solutions out there for awesome frigate notifications on telegram, using home assistant, were not 100% thought out, so i decided to take whats been made and perfect it.
Of course it’s important to note that i made this into a opiniated system, and by no means is the underlying code and blueprints perfected. In fact, you need to tweak a little bit to get this all working to your wishes, but that’s why i made this thread, in order to give back a little to the home assistant tweaking community.
I’m by no means a good coder, i just spend quite some hours today making this a well working notification system for my home, the blueprint could be way more polished, but the notifications themselfs are pretty much perfected I’d say.

A big thanks goes to NdR91 on github for the original blueprint.

What does this do and why is it better?!

Perhaps this is best described with two screenshots:


(not the same event in the above screenshot, ignore the photo and time and see the text)
As you can see, in the first screenshot, a event has been detected and you are notified of it including a photo. you could also select one without a bounding box, or a tiny thumbnail. or a crop. As soon as the event ends, the notification is updated/editted. You dont get a new message, therefore things look more organised. In the background, a video is also being send to a seperate groupchat, with notifications off. Then you have a clip of what happened without a chance your server is disconnected and you can no longer retrieve the video. Obviously you could remove this though. In the editted message (or rather a caption of the photo), you also see the clip as a link. I added two camera’s to this notification message on telegram because people are walking a certain direction where also a camera is placed, you could of course remove one, add one, do whatever you’d like.

So how do i make this for myself?
Editting messages on telegram isnt super easy. You need a way to intercept the message_ID and tags. Without making stuff too complicated, i will share the blueprint needed. You need Studio Code Server or a other editor to edit and copy the blueprints for yourself. For every camera, you need a seperate blueprint. You also need to create a input_number helper entity, and make a automation that grabs the message_id. But because you are using frigate, home assistant as well…I assume you can mess with code a little bit using guides such as this one…So lets get started.

Here is my blueprint with the name: frigate_telegram_frontdoor_notifications.yaml

Put it in the config//blueprints/NdR91/automation/ folder on your home assistant machine.

blueprint:
  name: Frigate - Telegram Notifications Front Door
  description: Create automations to receive Snapshots and Clips from Frigate
  domain: automation
  input:
    camera:
      name: Frigate Camera
      description:
        The name of the camera as defined in your frigate configuration
        (/conf.yml).
    target_chat:
      name: Target
      description:
        "The chat_id to be used by the Telegram bot. !secret chat_id is
        not allowed on Blueprint, you will need the chat_id code.

        "
    notification:
      name: Notification
      description:
        'Select "true" to disable notification, lave "false" to receive
        notification. '
      selector:
        select:
          options:
            - "true"
            - "false"
          multiple: false
          custom_value: false
          sort: false
      default: "false"
    base_url:
      name: (Optional) Base URL
      description:
        The external url for your Home Assistant instance. This will default
        to a relative URL and will open the clips in the app instead of the browser,
        which may cause issues on some devices.
      default: ""
    zone_filter:
      name: (Optional) Zone Filter
      description: Only notify if object has entered a defined zone.
      default: false
      selector:
        boolean: {}
    zones:
      name: (Optional) Trigger Zones
      description: A list (-) of zones you wish to recieve notifications for.
      default: []
      selector:
        object: {}
    labels:
      name: (Optional) Trigger Objects
      description: A list (-) of objects you wish to recieve notifications for.
      default: []
      selector:
        object: {}
    presence_filter:
      name: (Optional) Presence Filter
      description: Only notify if selected presence entity is not "home".
      default: ""
      selector:
        entity:
          multiple: false
  source_url: https://gist.github.com/NdR91/5486a1e55101e062c48545395b7dd9a3#file-frigate_telegram_notification-yaml
mode: single
max_exceeded: silent
trigger:
  platform: mqtt
  topic: frigate/events
  payload: !input camera
  value_template: "{{ value_json['after']['camera'] }}"
variables:
  id: "{{ trigger.payload_json['after']['id'] }}"
  camera: "{{ trigger.payload_json['after']['camera'] }}"
  camera_name: "{{ camera | replace('_', ' ') | title }}"
  target_chat: !input target_chat
  object: "{{ trigger.payload_json['after']['label'] }}"
  label: "{{ object | title }}"
  entered_zones: "{{ trigger.payload_json['after']['entered_zones'] }}"
  type: "{{ trigger.payload_json['type'] }}"
  base_url: !input base_url
  zone_only: !input zone_filter
  input_zones: !input zones
  zones: "{{ input_zones | list }}"
  input_labels: !input labels
  labels: "{{ input_labels | list }}"
  presence_entity: !input presence_filter
  notification: !input notification
condition:
  - "{{ type != 'end' }}"
  - "{{ not zone_only or entered_zones|length > 0 }}"
  - "{{ not zones|length or zones|select('in', entered_zones)|list|length > 0 }}"
  - "{{ not labels|length or object in labels }}"
  - "{{ not presence_entity or not is_state(presence_entity, 'home') }}"
action:
  - service: telegram_bot.send_photo
    data:
      target: "{{ target_chat }}"
      disable_notification: "{{ notification }}"
      caption: "🔴  |  🛣️🧍 Driveway entrance person detected!\n\nWatch: <a href='https://yourcamerastream.com/stream.html?src=driveway-cam'>Driveway Cam</a> | <a href='https://yourcamerastream.com/stream.html?src=garden-and-terrace'>Terrace Cam</a>"
      parse_mode: html
      url: "{{base_url}}/api/frigate/notifications/{{id}}/snapshot.jpg?bbox=1"
      message_tag: telegram_notifications_driveway

  - repeat:
      until:
        - condition: template
          value_template: "{{ wait is not none and wait.trigger is not none and wait.trigger.payload_json['type'] == 'end' }}"
      sequence:
        - wait_for_trigger:
            - platform: mqtt
              topic: frigate/events
              payload: "{{ id }}"
              value_template: "{{ value_json['after']['id'] }}"
          timeout:
            minutes: 6
          continue_on_timeout: false

        - variables:
            # Use these variables for the rest of the sequence
            event_id: "{{ wait.trigger.payload_json['after']['id'] }}"
            event_camera: "{{ wait.trigger.payload_json['after']['camera'] }}"
            msg_id: "{{ states('input_number.telegram_driveway_message_id') | int }}"

        - condition: template
          value_template: "{{ wait.trigger.payload_json['type'] == 'end' }}"

        - service: telegram_bot.edit_caption
          data:
            # Reverting back to chat_id as it is the most common native key
            chat_id: "{{ target_chat }}"
            message_id: "{{ msg_id }}"
            caption: "✅  |  🛣️🧍 Driveway entrance event complete.\nID: {{id}}.\n\nWatch: <a href='{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4'>Clip</a> | <a href='https://yourcamerastream.com/stream.html?src=driveway-cam'>Driveway Cam</a> | <a href='https://yourcamerastream.com/stream.html?src=garden-and-terrace'>Terrace Cam</a>"

        - delay: "00:00:06"

        - service: telegram_bot.send_video
          data:
            target: "-4025721811"
            disable_notification: true
            caption: "Driveway-Cam Event ID: {{ event_id }}."
            url: "{{ base_url }}/api/frigate/notifications/{{ event_id }}/{{ event_camera }}/clip.mp4"

Obviously, you need to edit the above blueprint to your liking and as said before, copy it for every seperate camera. Some notes:

  • The delay near the end is used to make sure the video and events has ended to not get errors sending the video. You can play around with this, see what works for you.
  • In the end the target (chat group) is different because it should be the seperate group chat you have for only videos, you can remove this part if you have no requirement for videos. Note that telegram only sends videos below 50mb, anyway. this is a bot api limit. As you can see, notifications are silenced for the videos posted, so you dont get bothered by them and simply have 1 clean message of a new event. You can use the ID in your event-end message to search the group with videos to find the corresponding video very fast.
  • the message_tag: telegram_notifications_frontdoor, is the tag telegram gives to a message. this is used to grab the telegram message_ID in a seperate automation. It can probably be implemented in the blueprint as well, but im not smart enough for that =) In every seperate blueprint you make, you need a seperate message_tag.
  • You should have created a input_number helper entity. be sure to link to it correctly in the above blueprint. It is in my case input_number.telegram_frontdoor_message_id. Be also sure to make the max number of the entity to like 10000000 or so.

Let’s now create the automation needed to grab the message ID and write it to the input_number.telegram_frontdoor_message_id input_number helper entity.

alias: "Frigate Telegram Message_ID Safe: FrontDoor Cam"
description: ""
triggers:
  - trigger: event
    event_type: telegram_sent
    event_data:
      message_tag: telegram_notifications_frontdoor
conditions: []
actions:
  - action: input_number.set_value
    metadata: {}
    data:
      value: "{{ trigger.event.data.message_id | int }}"
    target:
      entity_id: input_number.telegram_frontdoor_message_id
mode: single

As you can see, as soon as a telegram message (or photo with caption in this case) is send and the message_tag in it is detected, the message_id is written to the numeric value. This makes us able to edit the message like we are doing in the blueprint.

Now, we reload yaml or restart home assistant, and then create a new automation, select the blueprint, and then populate the fields. See the below screenshot.

That should be it! You will now get notified when a person enters the specific camera and specific zone, and the same message will be editted when the event has ended, including the link to the clip which will be added. No more clutter!

I dont have the knowledge, im pretty dumb to coding stuff =) But if anyone appriciates this, you could probably code this all to not require the additional automation or maybe not even require the input_number entity, maybe it is possible to update with a new photo as well, of the object leaving the zone or camera. I know frigate allows this, but not sure telegram allows editting a photo message. In any case, that’s not for me, and i’m pretty happy how this turned out.

5 Likes

I’ll try to integrate this into my setup sometime this week. Will be really helpful if I can get it working!

2 Likes

it’s working, thank you!

1 Like

Hi !!
This works perfect, thanks!

I have configured face recognition (frigate 0.16), and in trying to parse “sub_label” to send the name of face identified.

The response of sub_label tag has two values. First, the name of face recognized, and second, the value of matched confidence.

How can i parse the name of recognized face to Telegram caption?

Thanks in advance

@ borgqueenx hi, a huge THANK YOU for this, I have spent 5 days with chatgpt trying to do something like this and the bot failed, yours just works, I love it.

TrOjAn

1 Like

The message_id and chat_id is in the response of the telegram_bot.send_photo action so you don’t need the message_tag, input_number helper entity or the extra automation.

Example:

action: telegram_bot.send_photo
data:
  target:
    - "1111111111"
  url: "https://..."
response_variable: response

action: telegram_bot.edit_caption
metadata: {}
data:
  message_id: "{{ response.chats[0].message_id }}"
  chat_id: "{{ response.chats[0].chat_id }}"
  caption: "..."

i can remember i messed around with this, but wasnt working great in the end. if you have it working, then it would be awesome to share it completely to help others.

good evening.

can you tell me if blueprint is still up to date?

i tried following your code but i don’t receive a notification with the picture on telegram, when i go in front of the camera the automation triggers but that’s about it. thanks.

yes, youre likely missing something from the guide, its working for me without issue, also with the latest 0.17 beta.

I think I did something wrong, I’m a bit of a beginner. Do you think you could help me if I leave you a telegram or whatsapp number? thank you very much

I managed to make it work. Thank you.

but I have a small problem. in telegram I receive two notifications with the picture and the video and they stay like that. shouldn’t it automatically edit the message? trigger does automation :

 alias: "Frigate Telegram Message_ID Save: Front Door"
description: ""
triggers:
- event_type: telegram_sent
event_data:
message_tag: telegram_notifications_frontdoor
trigger: event
conditions: []
actions:
- data:
value: "{{ trigger.event.data.message_id | int }}"
target:
entity_id: input_number.telegram_frontdoor_message_id
action: input_number.set_value
mode: single

it should edit the message that the event is over. Maybe ask the help of grok or gemini or claude to fix it.

Use the telegram_bot.edit_message_media action.

action:

:one: Send snapshot and capture Telegram response

  • service: telegram_bot.send_photo
    data:
    target: “{{ target_chat }}”
    disable_notification: “{{ notification }}”
    caption: “:red_circle: | Motion detected!”
    parse_mode: html
    url: “{{ base_url }}/api/frigate/notifications/{{ id }}/snapshot.jpg?bbox=1”
    response_variable: telegram_response

:two: Save message_id in existing helper

  • service: input_number.set_value
    target:
    entity_id: input_number.telegram_door_message_id
    data:
    value: “{{ telegram_response.chats[0].message_id | int }}”

:three: Wait for Frigate end event

  • repeat:
    sequence:
    - wait_for_trigger:
    - platform: mqtt
    topic: frigate/events
    payload: “{{ id }}”
    value_template: “{{ value_json[‘after’][‘id’] }}”
    timeout:
    minutes: 6
    continue_on_timeout: false

    - condition: template
      value_template: "{{ wait.trigger.payload_json['type'] == 'end' }}"
    
    # 4️⃣ Edit the same Telegram message
    - service: telegram_bot.edit_caption
      data:
        chat_id: "{{ target_chat }}"
        message_id: "{{ states('input_number.telegram_door_message_id') | int }}"
        disable_notification: true
        parse_mode: html
        caption: >
          ✅  |  Motion ended  
          Event ID: {{ id }}
    
          ▶ <a href="{{ base_url }}/api/frigate/notifications/{{ id }}/{{ camera }}/clip.mp4">View Clip</a>
    
    - delay: "00:00:06"
    
    # 5️⃣ Send clip as a separate message
    - service: telegram_bot.send_video
      data:
        target: "{{ target_chat }}"
        disable_notification: true
        caption: "Event ID: {{ id }}"
        url: "{{ base_url }}/api/frigate/notifications/{{ id }}/{{ camera }}/clip.mp4"
    

    until: “{{ wait.trigger.payload_json[‘type’] == ‘end’ }}”

Since the last update home assistant frigate no longer sends Front Door event complete and Front Door Event ID via telegram, it only sends Front Door person detected! With a picture. Do you also encounter the same problem? Installation method
Home Assistant OS
Core
2026.1.0
Supervisor
2026.01.0
Operating System
16.3

Logger: homeassistant.components.automation.new_automation_4
Source: components/automation/init.py:824
integration: Automation (documentation, issues)
First occurred: 2:58:14 AM (1 occurrence)
Last logged: 2:58:14 AM

Error while executing automation automation.new_automation_4: extra keys not allowed @ data[‘disable_notification’]

and

Logger: homeassistant.components.automation.new_automation_4
Source: helpers/script.py:2070
integration: Automation (documentation, issues)
First occurred: 2:58:14 AM (2 occurrences)
Last logged: 2:58:14 AM

New automation: Repeat at step 2: Error executing script. Invalid data for call_service at pos 3: extra keys not allowed @ data[‘disable_notification’]
New automation: Error executing script. Invalid data for repeat at pos 2: extra keys not allowed @ data[‘disable_notification’]

You need to go to the automation and click on the Traces button to see what went wrong.

Thank you for all the work!

I have installed the Blueprints for each camera.
But I don’t understand how and where to place the helper script part for each camera?

Hopefully someone can help out?

Kinmd regards,
Robert

You are correct i am seeing the same thing. I am on vacation at the moment for next 2 weeks so cant check why or fix it.

You should ask gemini to fix it if in a hurry, i think its able to, give it the blueprint, both automations(saving id and blueprint automation) and give the current errors.
It should come up with a fix.

Thank you for your replay. Even when you are on holiday.
Enjoy your vacation!
I will go on vacation soon and will follow up beginning of Feb.

Thanks again!

1 Like