state, ask two questions about it, read the typed answers, and route the ticket automatically when the model is sure, or to a person when it isn’t.
Want the concepts first? Read the System One guide.
Prerequisites
Before starting, ensure you have:- A Gloo AI Studio account
- Your API key from the API Keys page, exported as
GLOO_API_KEY - Authentication setup - Complete the Authentication Tutorial first
- Python 3 with
requests, or Node.js 18 or later (for the built-infetch)
Understanding the endpoint
See the API reference for every field.
Step 1: Describe the ticket and the questions
Thestate is everything System One reads: here, the ticket text and the customer’s plan. The questions are what you want decided:
categoryis achoice: which team should handle the ticket. Each option incriteriasays when to pick it, andothercatches tickets that fit none of them.wants_refundis anoul: a statement that is either true or false of the ticket.
Step 2: Send the request
Send the state and questions, and fail loudly on any non-2xx status:Step 3: Read the answers
Each key inquestions comes back as a key in answers. A choice answer has the picked option in choice and a probability for every option in probabilities. A noul answer is the probability that the statement is true.
Read each value without assuming it is there. If one is missing, the code below gets None (Python) or undefined (TypeScript) instead of failing, and Step 4 sends that ticket to a person.
Step 4: Route on the probabilities
Act automatically only when the model is sure, and send everything else to a person. Here, a ticket goes straight to its team when the chosen category’s probability is at least 0.9 and the category isn’tother. A refund request is flagged only when wants_refund is at least 0.9; between 0.5 and 0.9 a person checks it. If a value is missing, a person handles it too. To choose thresholds for your own app, see Act on probabilities.
billing and the refund request (0.66) goes to a person to check. Keep the model with each decision so you can tell which version made it.
For more patterns built the same way (moderation with a review band, intent routing, yes-or-no policy checks and choosing a next step), see System One Examples.
Run it
Put the code from every step, in order, into one file:- Python: save it as
triage.pyand runpython triage.py. - TypeScript: save it as
triage.mtsand runnpx tsx triage.mts. The.mtsextension makes the file an ES module, so the top-levelawaitin Step 3 works without a build step.
Troubleshooting
400withstate is requiredorquestions must be an object. The body must be one JSON object with astatefield and an object-valuedquestionsfield.401. TheAuthorizationheader is missing or the key is not valid. CheckGLOO_API_KEY.429. Iferror.typeisbilling_error, your organization reached its spend limit. Otherwise wait for theRetry-Afterdelay and retry.
Next steps
Best Practices: System One
Write questions that get clear answers, set thresholds, and handle errors in production.
System One Examples
Short patterns for moderation, intent routing, policy checks and next-step choices.
API Reference: System One Decisions
Every request and response field, and every error status.

