Examples
Decision
Route a support ticket to a team with DecisionNode and TypeSafe's Jev
This example routes a support ticket to the team that should handle it and saves Jev's confidence with the decision. It ships as DecisionWorkflow in app/launchpad/workflows/examples/decision/ and is registered as WorkflowRegistry.DECISION.
What it demonstrates
- A
DecisionNodethat asks one typed question - Enum options described with
UseEnumMemberDocstrings - Reading the per-field confidence from
result.response.provider_details - A validated output (
teamplusconfidencefrom 0 to 1) that downstream nodes and routers can use
Files
| File | Purpose |
|---|---|
app/launchpad/workflows/examples/decision/schema.py | TicketEvent with a single message: str. |
app/launchpad/workflows/examples/decision/nodes/decide_team_node.py | DecideTeamNode, the Team enum, and the TeamQuestion model. |
app/launchpad/workflows/examples/decision/workflow.py | DecisionWorkflow registered as WorkflowRegistry.DECISION. |
app/launchpad/workflows/examples/decision/request_examples/ticket.json | Sample ticket about a duplicate charge. |
Workflow
from launchpad.core.schema import NodeConfig, WorkflowSchema
from launchpad.core.workflow import Workflow
from launchpad.workflows.examples.decision.nodes.decide_team_node import (
DecideTeamNode,
)
from launchpad.workflows.examples.decision.schema import TicketEvent
class DecisionWorkflow(Workflow):
workflow_schema = WorkflowSchema(
description="Choose a support team with Jev and validate the decision.",
event_schema=TicketEvent,
start=DecideTeamNode,
nodes=[NodeConfig(node=DecideTeamNode)],
)See the Decision Node page for the full DecideTeamNode.
Run it
Set the API key
Add your TypeSafe key to the root
.env:TYPESAFE_API_KEY=your-api-keyRun the playground
uv run playground/decision.pyThe script loads
app/launchpad/workflows/examples/decision/request_examples/ticket.json, runsWorkflowRegistry.DECISION.value(), and prints the finalTaskContext.
Output
{
"event": {
"message": "I was charged twice. Please refund the duplicate."
},
"nodes": {
"DecideTeamNode": {
"team": "billing",
"confidence": 1.0
}
},
"metadata": {},
"should_stop": false,
"trace_id": null
}Downstream nodes read the result with self.get_output(DecideTeamNode). A router can branch on output.team, or send decisions below a confidence threshold to review.