← All tutorialsSupport

Triage + auto-reply bot

Classify inbound tickets, draft a reply, queue refunds over $50 for human approval via the built-in approvals queue.

Cost~$0.01 per ticket
Operations
text_generation.generateemail.send

Prerequisites

  • Two services enabled on your agent: text_generation.generate, email.send
  • Approval threshold set to 5000 cents ($50) on email.send so high-value replies get parked.

Walkthrough

1. Classify + draft in one call

Use a structured prompt that returns JSON with category + suggested_reply + needs_human flags.

bash# Classify the ticket and draft a reply in one JSON-structured call.
curl -X POST https://www.upivia.com/v1/service-requests \
  -H "Authorization: Bearer $AGENT_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "service": "text_generation",
    "operation": "generate",
    "payload": {
      "model": "openai/gpt-4o-mini",
      "messages": [
        {"role":"system","content":"Return JSON: {category, reply, needs_human}"},
        {"role":"user","content":"<ticket body>"}
      ],
      "response_format": {"type":"json_object"}
    }
  }'

2. Send the reply

If `needs_human` is false, send. If true, skip - surface the ticket in your own UI. Either way the org audit log captures it.

bash# Send the drafted reply when needs_human is false.
curl -X POST https://www.upivia.com/v1/service-requests \
  -H "Authorization: Bearer $AGENT_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "service": "email",
    "operation": "send",
    "payload": { "to": "user@x.com", "subject":"Re: your ticket", "body": "<reply>" }
  }'

3. Refund path with approvals

If the LLM proposes a refund > $50, set approval_threshold_cents on the binding. Requests over the threshold come back as status `approval_required`. Approve at /approvals; the original request resumes from where it stopped.

Next steps

Audit every call at /audit-logs, watch spend at /usage, and tune budgets per service on the agent's page.

Create an account →