urgent-ticket-router

astropods-org/urgent-ticket-router 

Receives Zendesk ticket webhooks, applies relevant tags using AI, and routes urgent tickets to the correct PagerDuty team.

AGENT.md

Route Urgent Tickets Agent

Automatically triages incoming Zendesk tickets. Uses GPT-4.1 to analyse ticket content, apply relevant tags, and route urgent issues to the correct PagerDuty service (e.g. IAM, Platform). Standard tickets are tagged only — no escalation.

How it works

New ticket webhook:

  1. Reads ticket ID and description from the webhook payload
  2. Fetches all existing Zendesk tags and selects the most relevant ones
  3. Updates the ticket with the selected tags
  4. Assesses urgency from the description and tags:
    • Urgent (outage, security, data loss, P1/P2) → fetches PagerDuty services → creates incident routed to the correct team
    • Standard → stops after tagging

Webhook setup

Configure a Zendesk webhook to POST to your agent's URL:

  • Trigger: Ticket created → send to https://<your-agent-url>

Payload format (set this as the webhook body template in Zendesk):

{
  "detail": {
    "id": "{{ticket.id}}",
    "description": "{{ticket.description}}"
  }
}

Zendesk automatically signs each request with an HMAC-SHA256 signature using your WEBHOOK_SECRET and adds the x-zendesk-webhook-signature and x-zendesk-webhook-signature-timestamp headers. The agent verifies these on every request.

Testing locally — generate the signature manually:

SECRET="your-webhook-secret"
TIMESTAMP=$(date -u +%s)
BODY='{"detail":{"id":"12345","description":"The login page returns a 500 error for all users. Service is completely down."}}'
SIG=$(printf '%s' "${TIMESTAMP}.${BODY}" | openssl dgst -sha256 -hmac "$SECRET" -binary | base64)

curl -X POST https://<agent-url>/ \
  -H "Content-Type: application/json" \
  -H "x-zendesk-webhook-signature: $SIG" \
  -H "x-zendesk-webhook-signature-timestamp: $TIMESTAMP" \
  -d "$BODY"

Usage via web chat or Slack

MessageEffect
12345Triage ticket #12345
check ticket 12345Any text containing a ticket ID
{"detail":{"id":"12345","description":"..."}}Full webhook payload

Environment variables

VariableDescription
OPENAI_API_KEYAuto-injected by Astropods
ZENDESK_SUBDOMAINThe {subdomain} in https://{subdomain}.zendesk.com
ZENDESK_USERNAMEZendesk agent email for API auth
ZENDESK_API_KEYZendesk API token
ZENDESK_TICKET_URLBase ticket URL e.g. https://mycompany.zendesk.com/agent/tickets
PAGERDUTY_API_KEYPagerDuty REST API key
PAGERDUTY_FROM_EMAILEmail for PagerDuty From header (required by PagerDuty API)
WEBHOOK_SECRETZendesk webhook signing secret — used to verify HMAC-SHA256 signatures on incoming requests