diff --git a/bot.py b/bot.py
index ad33f11..066e928 100755
--- a/bot.py
+++ b/bot.py
@@ -27,8 +27,9 @@ TEMPLATE_TEXT = (
"{% elif labels.severity == 'warning' %}"
"ATTENTION "
"{% endif %}"
- "{{ labels.alertname }} {{ labels.instance }}"
- "{% if annotations.summary %}"
+ "{{ labels.alertname }}"
+ "{% if labels.instance is defined %} {{ labels.instance }}{% endif %}"
+ "{% if annotations.summary is defined %}"
"\n{{ annotations.summary }}"
"{% else %}"
"{% for key, value in annotations.items() %}"
@@ -45,9 +46,9 @@ TEMPLATE_HTML = (
"{% elif labels.severity == 'warning' %}"
"ATTENTION "
"{% endif %}"
- "{{ labels.alertname }} "
- "{{ labels.instance }}"
- "{% if annotations.summary %}"
+ "{{ labels.alertname }}"
+ "{% if labels.instance is defined %} {{ labels.instance }}{% endif %}"
+ "{% if annotations.summary is defined %}"
"
"
"
{{ annotations.summary }}" "{% else %}"