-
we have this workflow:
works well, but sometimes, we clients do not send mentions, causing the alert to fail. Can we make it fallback to empty array when mentions is not sent ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can make the mentions field optional by using Mustache-like conditional templating. Replace your mentions line with: mentions: '{{#alert.mentions}}{{.}}{{/alert.mentions}}{{^alert.mentions}}[]{{/alert.mentions}}' This tells the workflow engine: if alert.mentions exists, use it; if not, use an empty array. This approach leverages the IOHandler's support for conditional logic and default values in templates, so missing mentions won't cause failures anymore see code reference. No built-in YAML syntax exists for this, but this template pattern is supported by the engine's rendering logic see IOHandler implementation. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
You can make the mentions field optional by using Mustache-like conditional templating. Replace your mentions line with:
This tells the workflow engine: if alert.mentions exists, use it; if not, use an empty array. This approach leverages the IOHandler's support for conditional logic and default values in templates, so missing mentions won't cause failures anymore see code reference.
No built-in YAML syntax exists for this, but this template pattern is supported by the engine's rendering logic see IOHandler implementation.
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect