Tutorial · Zendesk AI

Zendesk AI agent: deflection with an LLM API

A good support agent is not the one that answers everything. It is the one that answers when it has a permitted source, cites it, and escalates cleanly when it does not.

Short answer. Create a Zendesk trigger that fires a webhook on new tickets. Your service retrieves relevant Help Center articles, calls an LLM with a strict JSON schema, and writes back a public reply only when confidence is high and the ticket is safe to automate. Otherwise, add an internal note, tag the ticket, and assign it to a human queue.

Architecture

  1. Trigger: Zendesk fires a webhook when a ticket is created or updated.
  2. Normalize: extract subject, description, requester, tags, priority and custom fields.
  3. Retrieve: search Help Center articles or your own vector index for permitted sources.
  4. Decide: call the model with a schema containing answer, citations, confidence and action.
  5. Act: public reply, internal note, or escalate with a tag and assignee.
  6. Log: store the prompt version, sources, confidence, action and model for audit.

What the model should return

{
  "answer": "string",
  "citations": ["https://help.example.com/articles/123"],
  "confidence": 0.0,
  "action": "reply" | "escalate",
  "reason": "string"
}

Use JSON mode and validate the shape. If action is reply but confidence is below your threshold, override to escalate. The model does not get the final say on risk.

When to escalate, no matter what

  • Billing, refunds, chargebacks, cancellations and plan changes.
  • Account access, password resets, identity verification and security incidents.
  • Legal threats, privacy requests, data deletion and regulatory complaints.
  • No permitted article retrieved, or citations do not support the answer.
  • Angry or vulnerable customers, or a conversation that has already been reopened.

Webhook handler

from flask import Flask, request
import requests, os

app = Flask(__name__)
ZD = "https://your-subdomain.zendesk.com/api/v2"
AUTH = (os.environ["ZD_EMAIL"] + "/token", os.environ["ZD_TOKEN"])

@app.post("/zendesk/webhook")
def webhook():
    ticket = request.json["ticket"]
    text = f"{ticket['subject']}\n\n{ticket['description']}"

    result = ask_model(text)  # returns answer, citations, confidence, action

    if result["action"] == "reply" and result["confidence"] >= 0.75:
        requests.put(
            f"{ZD}/tickets/{ticket['id']}.json",
            auth=AUTH,
            json={"ticket": {"comment": {"body": result["answer"], "public": True}}},
        )
    else:
        requests.put(
            f"{ZD}/tickets/{ticket['id']}.json",
            auth=AUTH,
            json={"ticket": {
                "comment": {"body": "AI could not answer confidently. See attached sources.", "public": False},
                "tags": ["ai_escalated"],
                "status": "open",
            }},
        )
    return {"ok": True}

Retrieve Help Center articles

GET https://your-subdomain.zendesk.com/api/v2/help_center/articles/search.json?query=reset+password
Authorization: Basic base64(email/token:api_token)

If you index articles yourself, store the article ID, URL, locale, section, updated date and visibility with each chunk. For internal articles, filter by the requester's permissions; do not send restricted content to a public reply.

Ticket schema to normalize

FieldUse
subjectPrimary intent signal
descriptionFull request; redact PII before logging
requester_id / organizationPlan, locale and entitlement lookup
tags / custom fieldsRouting, product area and risk flags
priorityEscalation threshold and SLA
conversation historyAvoid repeating an answer the customer rejected

QA and deflection measurement

  • Answer accuracy: sample 100 tickets and grade against the approved article.
  • Citation correctness: the cited article actually supports the answer.
  • Escalation precision: the tickets that should have been escalated were.
  • Reopen rate: AI-answered tickets reopened within 7 days.
  • CSAT and time to first response: compare AI and human cohorts.
  • Deflection: public AI replies that did not need a human, not just closed tickets.

Cost per ticket

cost_per_ticket =
    (retrieved_tokens × input_rate + answer_tokens × output_rate)
    + escalation_rate × human_cost_per_ticket
    + platform / observability cost

A cheap model with a high escalation rate can cost more than a stronger model that resolves more tickets. Measure cost per resolved ticket, not cost per call. Plugsky paid plans start at $8/month; Builder and Scale have no monthly token cap, with fair-use concurrency and RPM. See pricing.

Security and compliance

  • Redact PII before sending text to any model you do not control.
  • Never let the agent issue refunds, change plans or reset credentials without human approval.
  • Store an audit record: ticket ID, prompt version, sources, confidence, action and reviewer.
  • Use a private deployment if support data cannot leave your environment.

FAQ

Can I build a Zendesk AI agent with my own model?

Yes. Use a trigger and webhook, retrieve Help Center articles, call the model API, and write back through the Tickets API.

How do I stop the AI from answering when it is unsure?

Require a structured confidence and citations; escalate below the threshold or when no permitted article is retrieved.

Which Zendesk APIs do I need?

Webhooks/triggers for intake, Help Center search for articles, and the Tickets API for replies and internal notes.

How do I measure deflection?

Track public AI replies, escalations, reopens, CSAT and time to first response. A closed ticket is not proof of deflection.

How much does it cost per ticket?

Retrieved context + answer tokens + escalation rate × human cost. Plugsky paid plans start at $8/month; Builder and Scale have no monthly token cap.

Reviewed 20 November 2026. Zendesk API paths and authentication were checked against public Zendesk documentation on that date. Test in a sandbox and keep a human approval path for account, billing and security actions.