Macro Variables

Updated 1 month ago by Yohan Loyer

Below is a list of variables that can be inserted into macros to populate them with customer data from third-party apps.

To use variables from another app, please ensure that you’ve added it as an integration first.

How it works

Once you set up a variable within a macro, each time that you use this macro the system will replace the variable with a relevant piece of customer data. Here's a quick step-by-step below:

Setup instructions

Please find a list of some of the most common macro variable setups below!

Ticket variables
  • Ticket channel:
    {{ticket.channel}}
  • Ticket subject:
    {{ticket.subject}}
  • Message body:
    {{ticket.messages[0].body_text}} (this is only for the initial message in the ticket)
  • Last message text:
    {{ticket.messages[-1].body_text}}
  • Receiver email:
    {{ticket.receiver.email}}
  • Ticket id:
    {{ticket.id}}
  • Ticket customer id:
    {{ticket.customer.id}}
  • Ticket customer email:
    {{ticket.customer.email}}
  • Ticket url:
    https://{{ticket.account.domain}}.gorgias.com/app/ticket/{{ticket.id}}/
  • Ticket sender’s email:
    {{ticket.sender.email}}
  • Ticket assignee email:
    {{ticket.assignee_user.email}}
  • Last message datetime:
    {{ticket.last_message_datetime}}
  • Text of the first message:
    {{ticket.first_message.body_text}}
  • Ticket created datetime:
    {{ticket.created_datetime}}
  • Ticket opened datetime:
    {{ticket.opened_datetime}}
  • Ticket updated datetime:
    {{ticket.updated_datetime}}

Date variables

You can format the date using the moment.js syntax. See below some examples: 

  • Refund date formatted like "Mar 22nd 18":
    {{ticket.customer.integrations.shopify.orders[0].refunds[0].processed_at|datetime_format("MMM Do YY")}}
  • Refund date formatted like "03/22/2018":
    {{ticket.customer.integrations.shopify.orders[0].refunds[0].processed_at|datetime_format("L")}}

Shopify variables
  • Customer id:
    {{ticket.customer.integrations.shopify.customer.email}}
  • Customer's address: 
    {{ticket.customer.integrations.shopify.customer.default_address.address1}},
    {{ticket.customer.integrations.shopify.customer.default_address.address2}}, 
    {{ticket.customer.integrations.shopify.customer.default_address.zip}},
    {{ticket.customer.integrations.shopify.customer.default_address.city}},
    {{ticket.customer.integrations.shopify.customer.default_address.province}}
  • Last order id:
    {{ticket.customer.integrations.shopify.orders[0].id}}
  • Tracking url of the last order:
    {{ticket.customer.integrations.shopify.orders[0].fulfillments[0].tracking_url}}
  • Product name: 
    {{ticket.customer.integrations.shopify.orders[0].line_items[0].name}}
  • Variant name:  
    {{ticket.customer.integrations.shopify.orders[0].line_items[0].variant_title}}
  • Credit card number: 
    {{ticket.customer.integrations.shopify.orders[0].payment_details.credit_card_number}}
  • Refund process date: 
    {{ticket.customer.integrations.shopify.orders[0].refunds[0].processed_at|datetime_format("L")}}

Magento variables
  • Order number:
{{ticket.customer.integrations.magento2.orders[0].increment_id}}
  • Tracking ID of last shipment:
{{ticket.customer.integrations.magento2.orders[0].created_at|datetime_format("MMMM d YYYY")}}
  • Tracking number:
{{ticket.customer.integrations.magento2.orders[0].last_shipment.last_track.track_number}}
  • Tracking URL:
{{ticket.customer.integrations.magento2.orders[0].last_shipment.last_track.tracking_url}}
  • Shipping street:
{{ticket.customer.integrations.magento2.orders[0].extension_attributes.shipping_assignments[0].shipping.address.street[0]}}
  • Shipping city:
{{ticket.customer.integrations.magento2.orders[0].extension_attributes.shipping_assignments[0].shipping.address.city}}
  • Shipping country:
{{ticket.customer.integrations.magento2.orders[0].extension_attributes.shipping_assignments[0].shipping.address.country_id}}
  • Shipping postcode:
{{ticket.customer.integrations.magento2.orders[0].extension_attributes.shipping_assignments[0].shipping.address.postcode}}

BigCommerce variables
  • Big Commerce Data:
    {{ticket.customer.data}}
  • First Name:
    {{ticket.customer.data.first_name}}
  • Last Name:
    {{ticket.customer.data.last_name}}
  • Phone:
    {{ticket.customer.data.phone}}
  • Big Commerce Customer:
    {{ticket.customer.customer}}
  • Order:
    {{ticket.customer.data.orders[0].id}}
  • Big Commerce Order:
    {{ticket.customer.data.orders[0].id}}
  • Customer message:
    {{ticket.customer.data.orders[0].message}}
  • Date created:
    {{ticket.customer.data.orders[0].date_created}}
  • Date shipped:
    {{ticket.customer.data.orders[0].date_shipped}}
  • Items shipped:
    {{ticket.customer.data.orders[0].shipments[0].date_created}}
  • Items total:
    {{ticket.customer.data.orders[0].shipments[0].items_total}}
  • Refunded amount:
    {{ticket.customer.data.orders[0].refunded_amount}}
  • Staff notes:
    {{ticket.customer.data.orders[0].staff_notes}}
  • Status:
    {{ticket.customer.data.orders[0].status}}
  • Total inc tax:
    {{ticket.customer.data.orders[0].total_inc_tax}}
  • Shipments:
    {{ticket.customer.data.orders[0].shipments[0]}}
  • Date created:
    {{ticket.customer.data.orders[0].shipments[0].date_created}}
  • Shipping provider:
    {{ticket.customer.data.orders[0].shipments[0].shipping_provider}}
  • Tracking link:
    {{ticket.customer.data.orders[0].shipments[0].tracking_link}}
  • Tracking number:
    {{ticket.customer.data.orders[0].shipments[0].tracking_number}}
  • Shipping address:
    {{ticket.customer.data.orders[0].shipping_addresses[0]}}
  • City:
    {{ticket.customer.data.orders[0].shipping_addresses[0].city}}
  • Company:
    {{ticket.customer.data.orders[0].shipping_addresses[0].company}}
  • Country:
    {{ticket.customer.data.orders[0].shipping_addresses[0].country}}
  • Country iso2:
    {{ticket.customer.data.orders[0].shipping_addresses[0].country_iso2}}
  • Email:
    {{ticket.customer.data.orders[0].shipping_addresses[0].email}}
  • First name:
    {{ticket.customer.data.orders[0].shipping_addresses[0].first_name}}
  • Last name:
    {{ticket.customer.data.orders[0].shipping_addresses[0].last_name}}
  • Phone:
    {{ticket.customer.data.orders[0].shipping_addresses[0].phone}}
  • State:
    {{ticket.customer.data.orders[0].shipping_addresses[0].state}}
  • Street 1:
    {{ticket.customer.data.orders[0].shipping_addresses[0].street_1}}
  • Street 2:
    {{ticket.customer.data.orders[0].shipping_addresses[0].street_2}}
  • Zip:
    {{ticket.customer.data.orders[0].shipping_addresses[0].zip}}

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, follow the steps below: 

  1. Go to the HTTP integration's page that you use to fetch back-office data
  2. On this page, copy the integration_id at the end of the url. For instance, if the url is https://sfbicycles.gorgias.com/app/integrations/http/9141, the integration_idis 9141
  3. Now, the path to your integration is ticket.customer.integrations.9141
  4. Head over to a ticket that contains back-office data, and click on the Gear icon
  5. Now, follow the data structure to find the name of the variables. All variables have this form: {{ticket.customer.integrations.9141.data.delivery_cost}}

You can have a look at this video tutorial as well for further guidance:

That's it! This is probably one of the most complex parts of Gorgias.


What do you think? Yay or Nay?