ArticlesLeer en españolLire en français
ArticleBy Piotr MyszkiewiczPublished: Dec 03, 20263 min read

Route a Support Ticket with Ollama Structured Outputs

A customer writes that a PDF invoice downloads correctly but opens as a blank page. Your support queue accepts three labels: billing, product and review. A chat reply explaining the problem might help a person, but the queue needs one field it can read. With Ollama you can give the model a JSON Schema that limits the shape of its answer.

Give the model a routing rule

Use a running local Ollama server, curl and jq. Download the example model with the command below. Save the following prompt as prompt.txt in a working directory. The category names are part of the queue interface.

ollama pull llama3.2:3b
Classify the ticket. Use billing for a charge or payment problem, product for a broken feature, and review if the cause is unclear. Ticket: My invoice PDF downloads but opens as a blank page.

Send the same schema with each ticket

The format field constrains the response to an object with one required label. Turning streaming off gives the shell one response document. The last command extracts the model’s reply from the API envelope, parses it and rejects an unexpected field or label.

jq -n --rawfile prompt prompt.txt '{
  model: "llama3.2:3b",
  messages: [{role: "user", content: $prompt}],
  stream: false,
  format: {
    type: "object",
    properties: {label: {enum: ["billing", "product", "review"]}},
    required: ["label"],
    additionalProperties: false
  }
}' > request.json
curl --fail-with-body -sS http://localhost:11434/api/chat \
  -H 'Content-Type: application/json' -d @request.json > response.json
jq -e '.message.content | fromjson | select(type == "object")
  | select(keys == ["label"])
  | .label | select(. == "billing" or . == "product" or . == "review")' response.json
A ticket enters the model with a schema, then the application validates the label before routing.
The schema permits three labels. The application still has to check whether the chosen label fits the ticket. sAIgnals.

Check both shape and meaning

For this example the expected label is product: the customer describes a broken PDF and says nothing about an incorrect charge. A billing answer passes the structural check too. Keep this ticket as a labeled example and compare the actual answer with product before connecting the model to a live queue.

Try a second ticket that says only “Something is wrong with my invoice.” Under the same rule, expect review. If the command fails or the label is review, leave the ticket for a person. For a form where customers already select a category, route directly from that field.

This example follows the local API documentation. The expected labels are worked examples. We did not measure a model’s accuracy or run live inference for this guide.

Sources: Ollama · API · llama3.2:3b .

Your next step

Turn the update into a working practice

Explore practical guides to configuring, reviewing, and working with coding agents.

Explore practical guides →

Keep up at your pace

Get useful changes, a workflow to try, and a repository to explore. Choose a twice-weekly, weekly or monthly briefing.

Preview the briefing and subscribe →

Explore these tool hubs