Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Use a template to generate the message #44

Closed
freefd opened this issue May 4, 2024 · 1 comment
Closed

Feature: Use a template to generate the message #44

freefd opened this issue May 4, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@freefd
Copy link
Contributor

freefd commented May 4, 2024

To give users more flexibility, frigate-notify could allow them to specify the format of message using templating engines like Jinja2 or Go Templates.

There is an assumption, the user would like to define the individual template for each notifier type.
Since the frigate-notify uses YAML based single configuration file, the template could be built-in as a dedicated top-level configuration section. For example:

frigate:
...
alerts:
...
monitor:
...
template: # or message_template
  telegram: |
    {{ if .event }}
    Detection at {{ .event.StartTime }}
    Camera: {{ .event.Camera }}
    Label: {{ .event.Label }} {{ event.TopScore }}

    {{ if ge (len .event.Zones) 1 }}
    Zone(s): {{ .event.Zones }}
    {{ end }}

    Links: [Camera]({{ .config.ServerUri }}/cameras/{{ .event.Camera }})
    {{- if .event.HasClip }}
    | [Event Clip]({{ .config.ServerUri }}/api/events/{{ .event.ID }}/clip.mp4)
    {{ end }}
    {{ end }}
...

As usual, if no template is specified, a default template will take effect for a particular notifier.

Thank you.

@0x2142 0x2142 self-assigned this May 5, 2024
@0x2142 0x2142 added the enhancement New feature or request label May 5, 2024
@0x2142 0x2142 added this to the v0.3.0 milestone May 5, 2024
@0x2142 0x2142 mentioned this issue May 15, 2024
@0x2142
Copy link
Owner

0x2142 commented Jun 3, 2024

Added in v0.3.0

Docs

@0x2142 0x2142 closed this as completed Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants