Use variables in macrosUpdated 6 days ago
Variables let you auto-populate customer and ticket data into a macro so you don't have to copy information manually. When a macro with variables is applied to a ticket, Gorgias replaces each variable with the relevant data from your helpdesk. If the data isn't available for that ticket, the variable is replaced with a blank space.
Requirements
- Available on all Helpdesk plans
- The account owner, admins, and leads can create and manage macros
- Everyone can apply a macro to a ticket
- Ecommerce variables are only available when you connect a store to Gorgias
Add variables to a macro
When creating a macro, you can use the variable selectors at the bottom of the macro editor to add a variable placeholder into the body of your macro.
- From your helpdesk, click the dropdown menu in the top-left corner.
- Select Workflows.
- In the menu, locate Tools, then select Macros.
- Click Create macro in the top-right corner.
- Write your message body, then use the variable dropdown at the bottom of the reply box to browse and insert variables. The dropdown is labeled with the type of variable (e.g., Ticket customer, Current agent, Shopify, BigCommerce, Magento 2, etc.).
If the variable you’re looking for isn’t included in the variable selectors, you can manually enter the variable by typing it between double curly brackets in the macro’s response text. For example, if you’d like to include a ticket’s ID in your response, include {{ticket.id}} in the macro editor:
1Thanks for reaching out, we've received your message. A representative from our team should be in touch in the next 48 hours. If 48 hours pass and you still haven't heard from us, send an email to [email protected] and reference your case ID for us to investigate further.23Your case ID is {{ticket.id}}.4
Browse the tables below for variables you can add to your macros and their formatting.
Ticket variables
| Variable | Description |
{{ticket.channel}}
| Ticket channel |
{{ticket.subject}}
| Ticket subject |
{{ticket.messages[0].body_html}}
| First message in the thread (HTML format) |
{{ticket.messages[1].body_html}}
| Second message in the thread |
{{ticket.messages[-1].body_html}}
| Last message in the thread |
{{ticket.messages[-2].body_html}}
| Message before the last message |
{{ticket.id}}
| Ticket ID |
{{ticket.last_message_datetime}}
| Last message datetime |
{{ticket.created_datetime}}
| Ticket created datetime |
{{ticket.updated_datetime}}
| Ticket updated datetime |
{{ticket.customer.id}}
| Customer ID (from sidebar) |
{{ticket.customer.firstname}}
| Customer first name (from sidebar) |
{{ticket.customer.email}}
| Customer email (from sidebar) |
{{ticket.sender.email}}
| Sender email |
{{ticket.assignee_user.id}}
| Ticket assignee ID |
{{ticket.assignee_user.email}}
| Ticket assignee email |
{{ticket.assignee_user.name}}
| Ticket assignee name |
{{current_user.id}}
| Current user ID |
{{current_user.firstname}}
| Current user first name |
{{current_user.lastname}}
| Current user last name |
{{current_user.name}}
| Current user full name |
{{current_user.email}}
| Current user email |
{{current_user.bio}}
| Current user bio |
To reference the ticket URL, combine the static base URL with the ticket ID variable: https://YOURDOMAIN.gorgias.com/app/ticket/{{ticket.id}}
All current_user variables except {{current_user.bio}} can also be used in custom redirection links.
If a message's content is not in HTML format — for example, offline capture messages — use {{ticket.messages[0].body_text}} instead of body_html.
current_user variables default to the account owner.Date variables
You can format dates using moment.js syntax with the datetime_format filter. The examples below use a Shopify refund date, but the same filter works on any datetime variable.
| Variable | Output format |
{{ticket.customer.integrations.shopify.orders[0].refunds[0].processed_at|datetime_format("MMM Do YY")}}
| Mar 22nd 18 |
{{ticket.customer.integrations.shopify.orders[0].refunds[0].processed_at|datetime_format("L")}}
| 03/22/2018 |
{{ticket.customer.integrations.shopify.orders[0].refunds[0].processed_at|datetime_format("DD-MM-YYYY")}}
| 22-03-2018 |
{{ticket.customer.integrations.shopify.orders[0].refunds[0].processed_at|datetime_format("d.M.YYYY")}}
| 22.3.2018 |
Ecommerce variables
Shopify
| Variable | Description |
{{ticket.customer.integrations.shopify.customer.email}}
| Customer email |
{{ticket.customer.integrations.shopify.customer.first_name}}
| Customer first name |
{{ticket.customer.integrations.shopify.customer.last_name}}
| Customer last name |
{{ticket.customer.integrations.shopify.customer.phone}}
| Customer phone |
{{ticket.customer.integrations.shopify.customer.default_address.address1}}
| Address line 1 |
{{ticket.customer.integrations.shopify.customer.default_address.address2}}
| Address line 2 |
{{ticket.customer.integrations.shopify.customer.default_address.city}}
| City |
{{ticket.customer.integrations.shopify.customer.default_address.zip}}
| ZIP code |
{{ticket.customer.integrations.shopify.customer.default_address.province_code}}
| Province/state code |
{{ticket.customer.integrations.shopify.orders[0].id}}
| Last order ID |
{{ticket.customer.integrations.shopify.orders[0].line_items[0].name}}
| First product name in last order |
{{ticket.customer.integrations.shopify.orders[0].line_items[1].name}}
| Second product name |
{{ticket.customer.integrations.shopify.orders[0].line_items[2].name}}
| Third product name |
{{ticket.customer.integrations.shopify.orders[0].line_items[0].variant_title}}
| Variant name of first product |
{{ticket.customer.integrations.shopify.orders[0].total_price}}
| Total price of last order |
{{ticket.customer.integrations.shopify.orders[0].payment_details.credit_card_number}}
| Last 4 digits of credit card |
{{ticket.customer.integrations.shopify.orders[0].refunds[0].processed_at|datetime_format("L")}}
| Refund processed date (MM/DD/YYYY) |
Use orders[0] for the most recent order, orders[1] for the second most recent, and so on. The same indexing applies to line_items.
BigCommerce
| Variable | Description |
{{ticket.customer.integrations.bigcommerce.customer.first_name}}
| Customer first name |
{{ticket.customer.integrations.bigcommerce.customer.last_name}}
| Customer last name |
{{ticket.customer.integrations.bigcommerce.customer.email}}
| Customer email |
{{ticket.customer.integrations.bigcommerce.customer.phone}}
| Customer phone |
{{ticket.customer.integrations.bigcommerce.customer.addresses[0].address1}}
| Address line 1 |
{{ticket.customer.integrations.bigcommerce.customer.addresses[0].address2}}
| Address line 2 |
{{ticket.customer.integrations.bigcommerce.customer.addresses[0].city}}
| City |
{{ticket.customer.integrations.bigcommerce.customer.addresses[0].postal_code}}
| Postal code |
{{ticket.customer.integrations.bigcommerce.customer.addresses[0].state_or_province}}
| State or province |
{{ticket.customer.integrations.bigcommerce.customer.addresses[0].country}}
| Country |
{{ticket.customer.bigcommerce.orders[0].id}}
| Last order ID |
{{ticket.customer.bigcommerce.orders[0].message}}
| Customer order message |
{{ticket.customer.bigcommerce.orders[0].bc_products[0].name}}
| First product name in last order |
{{ticket.customer.bigcommerce.orders[0].bc_products[1].name}}
| Second product name |
{{ticket.customer.bigcommerce.orders[0].bc_products[2].name}}
| Third product name |
{{ticket.customer.bigcommerce.orders[0].items_total}}
| Total number of items in last order |
{{ticket.customer.bigcommerce.orders[0].staff_notes}}
| Staff notes on last order |
{{ticket.customer.integrations.bigcommerce.draft_orders[0].draft_order_url}}
| URL of last draft order |
{{ticket.customer.bigcommerce.draft_orders[0].bc_products[0].name}}
| First product in last draft order |
{{ticket.customer.bigcommerce.draft_orders[0].bc_products[1].name}}
| Second product in last draft order |
ticket.customer.bigcommerce (without integrations) while others use ticket.customer.integrations.bigcommerce. Use the paths exactly as shown above.Magento 2
| Variable | Description |
{{ticket.customer.integrations.magento2.customer.firstname}}
| Customer first name |
{{ticket.customer.integrations.magento2.customer.lastname}}
| Customer last name |
{{ticket.customer.integrations.magento2.customer.email}}
| Customer email |
{{ticket.customer.integrations.magento2.customer.dob|datetime_format("MMMM d YYYY")}}
| Customer date of birth |
{{ticket.customer.integrations.magento2.orders[0].extension_attributes.shipping_assignments[0].shipping.address.telephone}}
| Phone number used in last order |
{{ticket.customer.integrations.magento2.orders[0].store_name}}
| Store name |
{{ticket.customer.integrations.magento2.orders[0].grand_total}}
| Total price of last order |
{{ticket.customer.integrations.magento2.orders[0].order_currency_code}}
| Currency of last order |
{{ticket.customer.integrations.magento2.orders[0].items[0].name}}
| First product name in last order |
{{ticket.customer.integrations.magento2.orders[0].items[0].base_price_incl_tax}}
| Price of first item (tax included) |
{{ticket.customer.integrations.magento2.orders[0].items[0].sku}}
| SKU of first item |
{{ticket.customer.integrations.magento2.shipments[0].tracks[0].title}}
| Shipping company for last shipment |
For additional items in an order, increase the index number: items[1], items[2], etc.
WooCommerce
WooCommerce variables cannot be selected from the variable dropdown in the macro editor, but you can manually type the variables described in the table below to use them. Each variable path requires your store's unique UUID.
Find your store UUID
- Open any ticket where the customer has a WooCommerce order.
- Click the gear icon at the top right of the customer section to open the sidebar settings and view all available WooCommerce data.
- Scroll to the Store section and locate the uuid field.
- Copy the UUID value and use it in your variable paths, replacing
uuidin the examples below. Keep the quotation marks around the UUID value in the variable path.
| Variable | Description |
{{ticket.customer.ecommerce_data["uuid"].store.display_name}}
| Store display name |
{{ticket.customer.ecommerce_data["uuid"].orders[0].number}}
| Last order number |
{{ticket.customer.ecommerce_data["uuid"].shopper.first_name}}
| Customer first name |
{{ticket.customer.ecommerce_data["uuid"].shopper.last_name}}
| Customer last name |
{{ticket.customer.ecommerce_data["uuid"].shopper.email_address}}
| Customer email address |
{{ticket.customer.ecommerce_data["uuid"].shopper.phone_number}}
| Customer phone number |
{{ticket.customer.ecommerce_data["uuid"].shopper.birthdate}}
| Customer birthdate |
{{ticket.customer.ecommerce_data["uuid"].addresses[0].line_1}}
| Street address line 1 |
{{ticket.customer.ecommerce_data["uuid"].addresses[0].line_2}}
| Street address line 2 |
{{ticket.customer.ecommerce_data["uuid"].addresses[0].city}}
| City |
{{ticket.customer.ecommerce_data["uuid"].addresses[0].state}}
| State |
{{ticket.customer.ecommerce_data["uuid"].addresses[0].zip_code}}
| ZIP code |
{{ticket.customer.ecommerce_data["uuid"].addresses[0].country}}
| Country |
Back-office variables
If you have an HTTP integration that pulls data from a custom back-office system, you can use that data in macros too. Each back-office is unique, so you'll need to find the integration ID and follow the data structure to build your variable path.
- From your helpdesk, click the Settings icon in the bottom-left corner.
- In the menu, locate Account, then select HTTP integration.
- Select the Manage tab, then select your HTTP integration from the list.
- Copy the integration ID from the end of the URL. For example, if the URL is
https://YOURDOMAIN.gorgias.com/app/integrations/http/9141, the integration ID is9141. - Open a ticket that has back-office data loaded in the sidebar.
- Click the gear icon at the top right of the customer section to open the sidebar settings and view all available data fields.
- Follow the data structure to identify the variable names you need. All back-office variables take this form:
{{ticket.customer.integrations[9141].data.delivery_cost}}
The base path for any back-office variable is ticket.customer.integrations[{{integration_id}}].