Macro Variables 101Updated 10 months ago
Once you set up a variable within a Macro, each time you use this Macro the system will replace the variable with a relevant piece of customer data - so long as it's something available in the customer sidebar to the right.
If the information isn't available, the variable will be replaced with a blank space.
Types of variables
Ticket variables
Ticket channel | {{ticket.channel}} |
Ticket subject | {{ticket.subject}} |
Message body | {{ticket.messages[0].body_html}} → for the first message in the thread {{ticket.messages[1].body_html}} → for the second message in the thread {{ticket.messages[-1].body_html}} → for the last message in the thread {{ticket.messages[-2].body_html}} → for the message before the last message in the thread |
Ticket ID | {{ticket.id}} |
Ticket URL | https://YOURDOMAIN.gorgias.com/app/ticket/{{ticket.id}} |
Last message datetime | {{ticket.last_message_datetime}} |
Ticket created datetime | {{ticket.created_datetime}} |
Ticket updated datetime | {{ticket.updated_datetime}} |
Customer ID (set in sidebar) | {{ticket.customer.id}} |
Customer first name (set in sidebar) | {{ticket.customer.firstname}} |
Customer email (set in sidebar) | {{ticket.customer.email}} |
Sender email | {{ticket.sender.email}} |
Ticket assignee ID | {{ticket.assignee_user.id}} |
Ticket assignee email | {{ticket.assignee_user.email}} |
Ticket assignee name | {{ticket.assignee_user.name}} |
Current user ID | {{current_user.id}} |
Current user first name | {{current_user.firstname}} |
Current user last name | {{current_user.lastname}} |
Current user full name | {{current_user.name}} |
Current user email | {{current_user.email}} |
Current user Bio | {{current_user.bio}} |
Date variables
You can format the date using the moment.js syntax.
Refund date formatted as Mar 22nd 18 | {{ticket.customer.integrations.shopify.orders[0].refunds[0].processed_at|datetime_format("MMM Do YY")}} |
Refund date formatted as 03/22/2018 | {{ticket.customer.integrations.shopify.orders[0].refunds[0].processed_at|datetime_format("L")}} |
Refund date formatted as 22-03-2018 | {{ticket.customer.integrations.shopify.orders[0].refunds[0].processed_at|datetime_format("DD-MM-YYYY")}} |
Refund date formatted as 22.3.2018 | {{ticket.customer.integrations.shopify.orders[0].refunds[0].processed_at|datetime_format("d.M.YYYY")}} |
E-commerce variables
You can find some specific variables for various e-commerce platforms in our articles on Shopify, Magento 2, BigCommerce, and WooCommerce variables.
Back-office variables
Back-office variables are a bit harder to use since each back-office is unique. For instance, you can display the ETA of an order or the order_count of a customer.
To use a variable from your back-office in a Macro:
1. Go to the HTTP integration's page that you use to fetch back-office data.
2. Copy the integration_id at the end of the URL - for instance, if the URL is https://YOURDOMAIN.gorgias.com/app/integrations/http/9141, the integration_id is 9141.
Now, the path to your integration is ticket.customer.integrations[{{integration_id}}].
3. Head over to a ticket that contains back-office data, and click on the gear icon in the sidebar to the right.
4. Follow the data structure to find the names of the variables. All variables have this form: {{ticket.customer.integrations[9141].data.delivery_cost}}.