# CSAT Follow-up Loop

Run post-resolution CSAT (Customer Satisfaction) pings after a support ticket closes, escalate detractors, and remember accounts with chronic issues so future tickets get context.

## When to use

- A ticket has just been marked resolved and needs a satisfaction check-in.
- A CSAT reply comes back low (a "detractor") and needs human escalation.
- An account has repeated tickets for the same issue and needs a durable note flagged for future agents.
- A scheduled sweep should catch tickets that closed without a reply and send a reminder.

## Tools

- `http-get`
- `send-email`
- `update-memory`
- `create-task`

## Playbook

1. When a ticket is marked resolved, use `http-get` to confirm current ticket status and pull the customer's contact info from the org's helpdesk REST API (e.g. GET https://api.helpdesk.example.com/v1/tickets/{id}). Auth is injected by the org's Integration row for this host — never ask for, echo, or hardcode credentials.
2. Answer strictly from the org knowledge base for any wording about policy (refund windows, SLA terms, etc.); never invent policy language in the CSAT message.
3. Draft a short CSAT survey message (1-5 satisfaction scale plus optional comment) using `send-email`. Treat the draft as pending human review unless the org has explicitly opted into auto-send for this workflow.
4. If no reply arrives within the expected window, use `http-get` to re-check ticket/thread status (e.g. GET https://api.helpdesk.example.com/v1/tickets/{id}/messages), and send one reminder via `send-email`.
5. When a CSAT reply comes in with a low score (detractor), use `create-task` to open an escalation task for a human agent, including the ticket ID, score, and comment.
6. Use `http-get` to pull the account's ticket history (e.g. GET https://api.helpdesk.example.com/v1/accounts/{account_id}/tickets) and check whether this is a repeat issue.
7. If the account shows a pattern of repeated tickets on the same issue, use `update-memory` to record a durable chronic-issue note on that account (issue type, ticket count, last occurrence) so future agents see it immediately.
8. If the helpdesk API requires updating a ticket's CSAT-follow-up status field (PUT/PATCH) or removing a stale reminder (DELETE), route that step through `http-request` instead of `http-get`.
9. If a capability needed mid-loop is missing (e.g. no Integration configured for the helpdesk host, or no escalation owner assigned), stop and hand off to a human via a `create-task` describing exactly what is missing.

## Failure modes

- No Integration row exists for the helpdesk host: stop and create a human-handoff task rather than guessing at auth.
- CSAT reply is ambiguous or sarcastic and scoring logic misreads it as a promoter: escalate borderline scores to a human rather than auto-closing the loop.
- Chronic-issue memory grows unbounded or duplicates prior notes: check existing memory before writing and update in place instead of appending duplicates.
- Auto-send is not opted into but a reminder or survey is sent without human review: always default to drafting behavior when in doubt.

## Done when

- The CSAT survey has been sent (or drafted for review) and any reply has been logged against the ticket.
- Detractor replies have a corresponding escalation task, and chronic-issue accounts have an updated memory note.