@startujn render { direction: down; arrow_spacing: 24 } journey AI_REPLY "Reply to a ticket with an AI draft" description: "An AI assistant drafts the reply and the refund; the agent decides what is sent" unique_id_friendly: ai_reply start from_queue { description: "Agent opens a ticket" } view ticket { title: "Ticket"; description: "Customer message and order"; route: /tickets/:id } action ask_ai { title: "Ask for a draft"; description: "Removes card data" } system assistant { type: external; title: "AI assistant"; host: api.ai.example } view drafting { type: waiting; title: "Drafting a reply"; description: "Until the draft arrives" } action draft_ready { type: event; title: "Draft arrives"; timeout: 30 s } view no_draft { type: toast; title: "No draft yet"; description: "Try again from the ticket" } view review { title: "Review draft"; description: "Edit the reply and refund amount"; route: /tickets/:id/draft } view write_reply { title: "Reply editor"; description: "Written by hand"; route: /tickets/:id/reply } action submit { title: "Check refund"; description: "Limit is $100" } actor lead { title: "Team lead"; role: Support lead } action issue_refund { title: "Issue refund" } action send_reply { type: message; title: "Send reply"; channel: email } end sent { type: success; description: "Customer answered" } from_queue --> ticket ticket --> ask_ai : [Draft with AI] ask_ai --> assistant { payload: [ticket_text, order_items] context: "Card numbers and payment details are never sent to the AI service" } ask_ai --> drafting ask_ai --> draft_ready drafting ..> ticket : [Cancel] draft_ready --> review : needs review { payload: [reply_draft, refund_amount] } draft_ready --> send_reply : simple, no refund { flags: [experiment] } draft_ready -x-> write_reply : failed draft_ready -x-> no_draft : timeout no_draft ..> ticket review --> submit : [Send] { payload: [reply, refund_amount] } review -x-> write_reply : [Reject] write_reply --> submit : [Send] { payload: [reply, refund_amount] } submit --> send_reply : no refund submit --> issue_refund : refund up to $100 submit --> lead : over $100 lead --> issue_refund : [Approve] lead -x-> write_reply : [Reject] issue_refund --> send_reply send_reply -right-> sent @endujn