From 2004a6b2246b5fa8914483924eabb17307c835a9 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Thu, 3 Dec 2026 10:52:38 +1100 Subject: [PATCH] docs(zendesk): add a skill for ending a live chat stuck open A DM ticket auto-assigned as its chat starts keeps that chat open, and the API refuses to unassign it. The skill covers confirming it and ending the session with the endsession note trigger. Tracks .claude/skills/ so repo skills can be committed. --- .claude/skills/zendesk-stuck-chat/SKILL.md | 73 ++++++++++++++++++++++ .gitignore | 3 +- 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 .claude/skills/zendesk-stuck-chat/SKILL.md diff --git a/.claude/skills/zendesk-stuck-chat/SKILL.md b/.claude/skills/zendesk-stuck-chat/SKILL.md new file mode 100644 index 0000000..807d3d7 --- /dev/null +++ b/.claude/skills/zendesk-stuck-chat/SKILL.md @@ -0,0 +1,73 @@ +--- +name: zendesk-stuck-chat +description: Use when a Session Zendesk ticket from X (Twitter) DM is stuck "pending an agent", shows only "Conversation with " and none of the customer's messages, or the digest lists it under 💬 as a live chat still open or one Zendesk refused to unassign. Covers why the chat never ends, how to confirm it, and how to end that one session so its messages land on the ticket. +--- + +# Zendesk: a live chat stuck open + +A messaging ticket holds the customer's messages in its live chat. Zendesk writes them onto the +ticket as a comment only when the chat ends, so until then the ticket shows only +`Conversation with ` and the agent workspace shows it pending an agent. + +## Why it stays open + +The auto-assign trigger gives a new DM ticket the **Main Support** admin as its assignee in the +same audit as its `ChatStartedEvent`. A chat that started with an assignee does not end on its +own, and the API will not clear that assignee while the chat is live: the PUT answers 200 and +returns the ticket still assigned. That is the digest's "Zendesk accepted unassigning #N but kept +its assignee" line. An unassigned chat ends by itself after 10 minutes. + +## Confirm it + +The credentials live only on angus. Read over SSH, GETs only: + +```sh +ssh root@angus.oxen.io 'set -a; . /etc/session-ops/zendesk.env; set +a +/opt/session-ops/.venv/bin/python - <<"EOF" +import os +from session_ops.zendesk import api +sd = os.environ["ZENDESK_SUBDOMAIN"]; s = api.zendesk_session(sd) +tid = 29951 +t = api.fetch_ticket(s, sd, tid) +print(t["status"], t["assignee_id"], t["via"]["channel"], "open chat:", api.has_open_chat(s, sd, tid)) +EOF' +``` + +`open chat: True` on a `sunshine_conversations_twitter_dm` ticket confirms it. `None` means the +audits could not be read. + +## End it + +The **End messaging sessions** trigger (id `64618370939417`) ends the session when a private note +containing `endsession` is added. Its conditions must be exactly these two, both under `all`: + +- `comment_includes_word` `includes` `endsession` +- `comment_is_public` `is` `false` + +A `conversation_state` condition fires on every update of an active chat and ends each new chat +on arrival, which splits every later DM into a new ticket. Check the trigger before relying on it: + +```python +tr = s.request("GET", f"https://{sd}.zendesk.com/api/v2/triggers/64618370939417.json").json()["trigger"] +print(tr["active"], tr["conditions"]) +``` + +Then add the note: + +```python +s.request("PUT", f"https://{sd}.zendesk.com/api/v2/tickets/{tid}.json", + json={"ticket": {"comment": {"body": "endsession", "public": False}}}) +``` + +A few seconds later `has_open_chat` returns `False`, the audit shows `ChatEndedEvent`, and the +transcript is a comment on the ticket. The ticket keeps its status and assignee. The customer is +not notified; their next DM starts a new chat and a new ticket. + +Without API access, an admin can add the same note in the agent workspace, or open the ticket as +Main Support and use **End session** in the composer. + +## Who runs the writes + +Changing the trigger and adding the note both write to Zendesk with an OAuth client that can post +public replies on any ticket. Claude reads on angus but hands these writes to the person as +commands to run there. diff --git a/.gitignore b/.gitignore index f0edb99..54d9554 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ do_not_commit.sh # Zendesk triage dedup state (ticket ids + timestamps; restored from CI cache) .triage-state/ -.claude/ +.claude/* +!.claude/skills/ .venv/