id: typesafe-ticket-urgency-compliance-gate
namespace: company.team
description: |
Evaluate incoming ticket or record content against a calibrated
urgency question via the TypeSafe API on a schedule, classify the
result as CRITICAL, NORMAL, or UNREACHABLE against a probability
threshold, log clean checks, and alert Slack the moment urgent
content is detected or the API cannot be reached.
inputs:
- id: ticket_content
type: STRING
defaults: "Help! My payouts have been failing for 3 days and I'm losing customers."
displayName: "Ticket Content"
description: "Text content to evaluate for urgency, for example a support
ticket, review, or log record."
- id: urgency_threshold
type: FLOAT
defaults: 0.7
displayName: "Urgency Probability Threshold"
description: "NOUL probability (0 to 1) at or above which content is classified
CRITICAL."
triggers:
- id: typesafe_urgency_gate_schedule
type: io.kestra.plugin.core.trigger.Schedule
description: "Run a canary urgency check every hour. Replace with a webhook
trigger per ticket in production."
cron: "0 * * * *"
disabled: true
inputs:
ticket_content: "Help! My payouts have been failing for 3 days and I'm losing customers."
urgency_threshold: 0.7
tasks:
- id: evaluate_ticket_urgency
type: io.kestra.plugin.typesafe.Evaluate
description: "Evaluate ticket_content against a single NOUL (yes/no probability)
question asking whether the content conveys urgency."
apiKey: "{{ secret('TYPESAFE_API_KEY') }}"
state: "{{ inputs.ticket_content }}"
questions:
is_urgent:
type: NOUL
instructions: "Does this content convey urgency or describe a critical issue
requiring immediate attention?"
allowFailure: true
- id: classify_urgency_level
type: io.kestra.plugin.core.debug.Return
description: "Classify UNREACHABLE when no answers were returned, CRITICAL when
the is_urgent NOUL probability is at or above urgency_threshold, otherwise
NORMAL."
format: "{{ outputs.evaluate_ticket_urgency.answers is defined ?
(outputs.evaluate_ticket_urgency.answers.is_urgent.noul >=
inputs.urgency_threshold ? 'CRITICAL' : 'NORMAL') : 'UNREACHABLE' }}"
- id: route_by_urgency
type: io.kestra.plugin.core.flow.Switch
description: "Log a quiet confirmation for normal content, page Slack for a
critical urgency reading, or page Slack when the API could not be
reached."
value: "{{ outputs.classify_urgency_level.value }}"
cases:
"NORMAL":
- id: log_normal
type: io.kestra.plugin.core.log.Log
message: "Ticket content classified NORMAL, urgency probability {{
outputs.evaluate_ticket_urgency.answers.is_urgent.noul }}."
"CRITICAL":
- id: alert_critical
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"text": "TypeSafe sentinel CRITICAL: urgency probability {{ outputs.evaluate_ticket_urgency.answers.is_urgent.noul }} is at or above the threshold of {{ inputs.urgency_threshold }} for content: {{ inputs.ticket_content }}. Execution {{ execution.id }}."
}
"UNREACHABLE":
- id: alert_unreachable
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"text": "TypeSafe sentinel UNREACHABLE: no answers were returned for the urgency check (invalid API key, platform outage, or malformed request). Execution {{ execution.id }}."
}
defaults:
- id: log_unclassified
type: io.kestra.plugin.core.log.Log
message: "Completed TypeSafe urgency check with status: {{
outputs.classify_urgency_level.value }}"
- id: log_audit_status
type: io.kestra.plugin.core.log.Log
description: "Post-audit status line recorded on every run regardless of branch,
for a continuous urgency-triage trend in the execution history."
message: "TypeSafe urgency audit: threshold={{ inputs.urgency_threshold }},
status={{ outputs.classify_urgency_level.value }}, execution={{
execution.id }}."
errors:
- id: alert_flow_failure
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
description: "Alert Slack when the gate flow itself fails, so a broken check
never silently stops triaging urgent content."
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"text": "TypeSafe urgency gate flow {{ flow.id }} FAILED (execution {{ execution.id }}). Urgency triage status is now unknown; check the task logs and the TypeSafe API manually."
}
outputs:
- id: status
type: STRING
value: "{{ outputs.classify_urgency_level.value }}"