Duplicate Subject in Email Alerts

Hello,
Can someone help me, I’m having a little trouble with an email template.

I have the following template who brings me a fine subject for my email
Code:

{{ define “correo.asunto2” }}
{{ if len .Alerts }}
:fire: [Warning] Alerta de CPU elevado - AWS
{{ end }}

{{ if len .Alerts.Resolved }}
:white_check_mark: [Resuelto] Alerta de CPU elevado - AWS
{{ end }}
{{ end }}

Subject for email:

I want to replace the text in the condition with variables sets on the alert rule, but I recieve the subject duplicated when another alert trigger
Code:
{{ define “correo.asunto2” }}
{{ if len .Alerts }}
:fire: {{range .Alerts }} [{{.Labels.criticidad}}] {{.Labels.Asunto}} - {{.Labels.ambiente}} {{end}}
{{ end }}

{{ if len .Alerts.Resolved }}
:white_check_mark: {{range .Alerts }} [Resuelto] {{.Labels.Asunto}} - {{.Labels.ambiente}} {{end}}
{{ end }}
{{ end }}
Subject for email:


The subject duplicate the text when two alerts triggers, and it continuously grows if more alerts triggers.

I’m pretty sure is because the following function {{ range .Alerts }}, if someone have an alternative in order to have an generic subject.

Thanks!

Grafana ver: 10.0