Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .claude/skills/zendesk-stuck-chat/SKILL.md
Original file line number Diff line number Diff line change
@@ -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 <name>" 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 <name>` 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.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/