This module combines everything: types, unions, tests, streaming, and integration into a realistic feature—a Customer Support Triage Bot.
This is production-ready code. Real types, real tests, real reliability. Not a demo.
// Customer Support Triage Bot - combining everything
class CustomerMessage {
content string
customerTier "enterprise" | "pro" | "free"
previousTickets int
}
class DraftResponse {
response string
suggestedActions string[]
confidence float
}
class EscalateToHuman {
reason string
urgency "immediate" | "high" | "normal"
suggestedTeam "billing" | "technical" | "legal" | "general"
}
class NeedMoreContext {
questions string[]
}
function TriageMessage(msg: CustomerMessage) -> DraftResponse | EscalateToHuman | NeedMoreContext {
client FallbackChain
prompt #"
You are a customer support assistant.
Customer tier: {{ msg.customerTier }}
Previous tickets: {{ msg.previousTickets }}
Message: {{ msg.content }}
{% if msg.customerTier == "enterprise" %}
Note: Enterprise customers should be escalated if issue seems complex.
{% endif %}
{{ ctx.output_format }}
"#
}
test EnterprisePriority {
functions [TriageMessage]
args {
msg {
content "Our API is down and we're losing revenue"
customerTier "enterprise"
previousTickets 0
}
}
@@assert {{ result is EscalateToHuman }}
@@assert {{ result.urgency == "immediate" }}
}