Cosmos DB Expired Document Retention Gate
Query a Cosmos DB container for documents that should have expired but are still present, classify the run by violation count, alert Slack, and optionally delete them and verify.
Gate support ticket or record content on urgency probability via the TypeSafe API and alert Slack when content is critical.
A support ticket or incident record that says "losing customers right now" should never wait in a queue behind routine requests, but a human has to read it first for that to happen. This blueprint evaluates content against a calibrated yes/no urgency question through the TypeSafe API, classifies the result against a probability threshold, and pages Slack the moment something crosses it, instead of relying on someone noticing in time.
evaluate_ticket_urgency (io.kestra.plugin.typesafe.Evaluate) sends ticket_content as the state and a single NOUL question (is_urgent) asking whether the content conveys urgency. allowFailure: true means a connection or authentication failure still lets the flow continue instead of aborting.classify_urgency_level (io.kestra.plugin.core.debug.Return) checks whether outputs.evaluate_ticket_urgency.answers is defined; if not, UNREACHABLE. Otherwise it compares the is_urgent answer's noul probability (0 to 1) against urgency_threshold, returning CRITICAL or NORMAL.route_by_urgency (io.kestra.plugin.core.flow.Switch) branches on that string: NORMAL logs a quiet confirmation, CRITICAL pages Slack with the probability and content, UNREACHABLE pages Slack separately, and defaults logs the raw outcome.log_audit_status records a status line on every run regardless of branch, so the execution history is a continuous triage trend.errors block pages Slack separately if the flow itself fails outright.typesafe_urgency_gate_schedule trigger runs an hourly canary check with explicit input overrides, shipped disabled: true; see How to extend for wiring it to real tickets.status output (CRITICAL / NORMAL / UNREACHABLE) you can chart or gate other flows on.A keyword filter in a script is brittle and untraceable; this flow makes the classification a first-class, typed step. Every evaluation is recorded in the execution history, the result becomes a typed output other flows can depend on, and the Switch branch is one edit away from real routing (paging on-call, opening a priority ticket) without rewriting the check itself.
TYPESAFE_API_KEY: TypeSafe API key used to authenticate the evaluation request.SLACK_WEBHOOK_URL: Slack incoming webhook used for the critical alert, the unreachable alert, and the flow-failure alert.SECRET_TYPESAFE_API_KEY and SECRET_SLACK_WEBHOOK_URL as base64, for example echo -n "<your-api-key>" | base64 and echo -n "<your-webhook-url>" | base64.TYPESAFE_API_KEY and SLACK_WEBHOOK_URL secrets.ticket_content to a real example and urgency_threshold to the probability you want to gate on.status reads CRITICAL for an urgent example and NORMAL for a routine one.typesafe_urgency_gate_schedule, or replace it with a webhook trigger fed by your real ticket intake.Schedule trigger with a Webhook trigger so every incoming ticket is evaluated as it arrives instead of on a fixed interval.CHOICE question (for example routing by department) alongside is_urgent and branch the Switch on both answers.confidence field on the answer to route low-confidence evaluations to human review instead of trusting a borderline score.