ZENDESK_TRIGGER_TYPES is the same tuple ZendeskChatbot uses in the event connector for session-link trigger routing, so what you configure in Zendesk Admin Center stays aligned with connector parsing and linking.
zendesk_chatbot_webhook_url and zendesk_chat_webhook_url build the correct /chatbot-webhook/{product_id} and /zendesk/chat/{product_id} URLs respectively. zendesk_auth_headers produces the correct Basic-auth header for all Zendesk REST API calls. build_zendesk_trigger_body generates the JSON body string for Zendesk trigger actions with the right fields for each trigger type.
Module: autoplay_sdk.integrations.zendesk
Small, dependency-light helpers in autoplay_sdk/integrations/zendesk.py for trigger type constants, connector URL builders, API auth headers, and trigger payload construction.
Trigger types
Configure Zendesk triggers to send exactly thesetrigger_type values so session linking and LLM reply routing stay aligned with ZendeskChatbot parsing in the connector:
| Name | Constant | Value |
|---|---|---|
| New ticket | ZENDESK_TRIGGER_TYPE_NEW_TICKET | "new_ticket" |
| User reply | ZENDESK_TRIGGER_TYPE_USER_REPLY | "user_reply" |
ZENDESK_TRIGGER_TYPES — both strings above. Other trigger_type values are ignored by the connector.
zendesk_chatbot_webhook_url(connector_host, product_id) -> str
Builds the absolute HTTPS URL for Zendesk Trigger A (session link + internal note):
{origin}/chatbot-webhook/{product_id}
connector_host: hostname (event-connector-xxxx.onrender.com) or full origin (https://…). Trailing slashes stripped; bare host getshttps://prepended.product_id: non-empty, no/(single path segment).
ValueError if host or product id is invalid.
zendesk_chat_webhook_url(connector_host, product_id) -> str
Builds the absolute HTTPS URL for Zendesk Trigger B (LLM reply):
{origin}/zendesk/chat/{product_id}
Same validation rules as zendesk_chatbot_webhook_url.
zendesk_auth_headers(email, api_token) -> dict[str, str]
Returns Authorization and Content-Type headers for Zendesk REST API calls:
/token literal between email and API token is required by Zendesk. Never hand-roll this — use this helper.
build_zendesk_trigger_body(trigger_type, *, include_user_message=False) -> str
Returns the JSON string to paste into the Zendesk trigger action body. Includes ticket_id, requester_email, and trigger_type. When include_user_message=True, also includes "user_message": "{{ticket.latest_comment}}" (required for Trigger B / Zendesk Messaging compatibility).
include_user_message for Trigger B? Zendesk Messaging tickets do not expose messages via GET /api/v2/tickets/{id}/comments.json — the API returns only internal notes for those tickets. Passing {{ticket.latest_comment}} inline is the only reliable source for the user’s message.
Example (Python)
Helpers reference
| Helper | Purpose |
|---|---|
zendesk_auth_headers(email, api_token) | Authorization: Basic … + Content-Type: application/json. Never hand-roll Zendesk Basic auth. |
zendesk_chatbot_webhook_url(host, product_id) | Builds /chatbot-webhook/{product_id} — Trigger A endpoint. |
zendesk_chat_webhook_url(host, product_id) | Builds /zendesk/chat/{product_id} — Trigger B endpoint. |
build_zendesk_trigger_body(trigger_type, *, include_user_message=False) | JSON body string for Zendesk trigger actions. Set include_user_message=True for Trigger B. |
ZENDESK_TRIGGER_TYPES | ("new_ticket", "user_reply") — all connector-recognized trigger types. |
ZENDESK_TRIGGER_TYPE_NEW_TICKET | "new_ticket" |
ZENDESK_TRIGGER_TYPE_USER_REPLY | "user_reply" |
Connector endpoints (reference)
| HTTP | Role |
|---|---|
POST /chatbot-webhook/{product_id} | Primary session-link path: receives new_ticket from Zendesk, resolves PostHog session by requester email, flushes buffered events as an internal note (public: false). |
POST /zendesk/chat/{product_id} | LLM reply path: receives user_reply with inline user_message, builds RAG context, calls Claude, posts public reply (public: true). Returns 200 immediately; LLM + Zendesk write run as a background task. |
X-Zendesk-Webhook-Signature (HMAC-SHA256) when signing_secret is present in integration_config. If absent, all inbound requests are accepted.
Delivery stack in this repo
BaseChatbotWriter(Support agent writer) — pre-link buffer, post-link debounce, shared note body format (format_chatbot_note_header, numbered action lines, binning).ZendeskChatbot(event connectorflows/chatbot/zendesk.py) — subclass; implements_post_note(ZendeskPUT /api/v2/tickets/{id}.jsonwithpublic: false, exponential retry) and_redact_part(no-op — Zendesk comments are immutable). Registered asCHATBOT_REGISTRY["zendesk"].
AsyncAgentContextWriter as described on the support agent writer page.
Related
- Support agent writer —
BaseChatbotWritercontract and note format. - Agent context — summariser +
overwrite_with_summaryflow. chatbot-zendeskskill — full setup guide: preflight, webhook + trigger registration, smoke test, and failure modes.