Skip to main content
This tutorial builds a small support-ticket triage step with System One. You’ll send a ticket as 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-in fetch)

Understanding the endpoint

See the API reference for every field.

Step 1: Describe the ticket and the questions

The state is everything System One reads: here, the ticket text and the customer’s plan. The questions are what you want decided:
  • category is a choice: which team should handle the ticket. Each option in criteria says when to pick it, and other catches tickets that fit none of them.
  • wants_refund is a noul: 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 in questions 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.
A response looks like this:

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’t other. 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.
For the example response above, the ticket goes to 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.py and run python triage.py.
  • TypeScript: save it as triage.mts and run npx tsx triage.mts. The .mts extension makes the file an ES module, so the top-level await in Step 3 works without a build step.

Troubleshooting

  • 400 with state is required or questions must be an object. The body must be one JSON object with a state field and an object-valued questions field.
  • 401. The Authorization header is missing or the key is not valid. Check GLOO_API_KEY.
  • 429. If error.type is billing_error, your organization reached its spend limit. Otherwise wait for the Retry-After delay and retry.
See Best Practices: System One for every status and how to 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.