Macros: canned responses and field changes. Zendesk's "apply"
endpoints only preview a macro; apply-macro previews and then
updates the ticket with the result, which is what an agent clicking
the macro does.
Context Vars
zendesk.subdomain
Functions
apply-macro
fn (ticket-id: Any, macro-id: Any): Any
fn (ticket-id: Any, macro-id: Any, opts: Map): Any
Apply a macro to a ticket: preview it, then PUT /tickets/{id} with
the resulting changes (fields, tags, assignee, and the macro's
comment). Returns {ticket, audit}.
Example
::zendesk::macros/apply-macro(35436, 360001234567)
get-macro
fn (id: Any): Any
fn (id: Any, opts: Map): Any
GET /macros/{id} - One macro with its actions.
Example
out ::zendesk::macros/get-macro(360001234567)
out.macro.actions
list-active-macros
fn (): Any
fn (opts: Map): Any
GET /macros/active - Active macros available to the user: {macros}.
Example
out ::zendesk::macros/list-active-macros()
map(out.macros, %.title)
list-macros
fn (): Any
fn (options: Map): Any
fn (options: Map, opts: Map): Any
GET /macros - One cursor page of macros: {macros, meta, links}.
options: active (Bool), access, category, group_id, include
("usage_7d"), page_size, after.
Example
page ::zendesk::macros/list-macros({active: true, category: "billing", page_size: 50})
map(page.macros, %.title)
macro-update
fn (result: Map): Map
Turn a macro preview result into ticket changes for PUT /tickets/{id}: the result's ticket fields, with its comment reduced
to body, html_body and public (dropping the read-only
scoped_body), and the ticket id and url removed. Exposed for testing.
Example
result {ticket: {id: 1, url: "https://acme.zendesk.com/api/v2/tickets/1.json", status: "solved", comment: {body: "Done", scoped_body: [], public: true}}}
::zendesk::macros/macro-update(result) // {status: "solved", comment: {body: "Done", public: true}}
preview-macro
fn (ticket-id: Any, macro-id: Any): Any
fn (ticket-id: Any, macro-id: Any, opts: Map): Any
GET /tickets/{ticket_id}/macros/{id}/apply - What the ticket would look
like after the macro: {result: {ticket, comment?}}. Changes nothing.
Example
out ::zendesk::macros/preview-macro(35436, 360001234567)
out.result.ticket