Ticket lifecycle
One row per ticket with its dimensions, first response and resolution times derived from the message log and close timestamp, message counts and CSAT.
- Grain
- gorgias_account x ticket
- Built from
- 3Raw tables
- 3Staging
- 1Core
- 1Analytics
- Reads from Gorgias
- satisfaction_surveyticketticket_message
- Ships as
- Weld and dbt SQL, open source on GitHub
1-- core.gorgias.ticket_lifecycle
2-- One row per ticket with its dimensions, first response and resolution times
3-- derived from the message log and close timestamp, message counts and CSAT.
4-- Grain: gorgias_account x ticket. The other ticket models read this one.
5--
6-- EXCLUDED: spam, trashed and merged tickets. Gorgias' statistics leave them out,
7-- and a merged ticket's messages live on in the ticket it was merged into.
8--
9-- FIRST RESPONSE is the first public message from the helpdesk side that was not
10-- sent by a rule, after the customer's first message:
11-- start = the customer's first message (the ticket's creation time if none)
12-- reply = earliest message with from_agent, public, rule_id empty, after start
13-- Messages written by AI Agent or by an app through the API are counted as agent
14-- replies, because nothing on the synced message reliably marks them.
15-- first_response_via shows how the reply was sent, so you can filter.
16-- Tickets the helpdesk started (outbound) are flagged and left out of averages.
17--
18-- RESOLUTION is creation to the ticket's LATEST close. Gorgias overwrites
19-- closed_datetime when a reopened ticket is closed again, so a ticket closed,
20-- reopened and closed counts once, on its last close. resolved_at is NULL for a
21-- ticket that is open now.
22--
23-- All durations are calendar minutes. Gorgias does not apply business hours.
24
25WITH tickets AS (
26 SELECT *
27 FROM {{staging.gorgias.ticket}}
28 WHERE NOT is_spam
29 AND NOT is_merged
30 AND trashed_at IS NULL
31 AND created_at IS NOT NULL
32),
33
34messages AS (
35 SELECT *
36 FROM {{staging.gorgias.ticket_message}}
37 WHERE failed_at IS NULL
38),
39
40first_customer AS (This model and the 4 it depends on. Deploy them together; refs like {{staging.…}} resolve to the matching folders in Weld, and the dbt view uses source() and ref().
How it counts. And where it stops.
EXCLUDED: spam, trashed and merged tickets. Gorgias' statistics leave them out, and a merged ticket's messages live on in the ticket it was merged into. FIRST RESPONSE is the first public message from the helpdesk side that was not sent by a rule, after the customer's first message: start = the customer's first message (the ticket's creation time if none) reply = earliest message with from_agent, public, rule_id empty, after start Messages written by AI Agent or by an app through the API are counted as agent replies, because nothing on the synced message reliably marks them. first_response_via shows how the reply was sent, so you can filter. Tickets the helpdesk started (outbound) are flagged and left out of averages. RESOLUTION is creation to the ticket's LATEST close. Gorgias overwrites closed_datetime when a reopened ticket is closed again, so a ticket closed, reopened and closed counts once, on its last close. resolved_at is NULL for a ticket that is open now. All durations are calendar minutes. Gorgias does not apply business hours.
Raw tables it reads
- raw.gorgias.satisfaction_survey
- raw.gorgias.ticket
- raw.gorgias.ticket_message
Put Gorgias in front
of your agents.
Connect Gorgias, deploy the models, and ask questions in Claude, Cursor or ChatGPT. Free for 14 days, no credit card.