Gorgias logo
Gorgias logo

All articles

Macro variablesUpdated 2 months ago

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.


*Important update on Macro Actions released! Please check it out here.


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:
    1{{ticket.channel}}
  • Ticket subject:
    1{{ticket.subject}}
  • Message body:
    1{{ticket.messages[0].body_text}} (no negative) ←for chat
    2{{ticket.messages[0].body_html}} ←for email

These will pull the first message on every ticket. If you want to pull the second message please use [1] and so on.

  • Ticket id:
    1{{ticket.id}}
  • Ticket customer id:
    1{{ticket.customer.id}}
  • Ticket customer email:
    1{{ticket.customer.email}}
  • Ticket url:
    1https://sfbycicles.gorgias.com/app/ticket/{{ticket.id}}/
  • Ticket customer first name:
    {{ticket.customer.firstname}}
Please note that we will use the Gorgias subdomain 'sfbycicles' in these examples, but this is where you will want to put your Gorgias account subdomain.
  • Ticket sender’s email:
    1{{ticket.sender.email}}
  • Ticket assignee email:
    1{{ticket.assignee_user.email}}
  • Last message datetime:
    1{{ticket.last_message_datetime}}
  • Ticket created datetime:
    1{{ticket.created_datetime}}
  • Ticket updated datetime:
    1{{ticket.updated_datetime}}
  • Curent User variables:
    1{{current_user.firstname}}
    2{{current_user.lastname}}
    3{{current_user.name}}
    4{{current_user.email}}
    5{{current_user.bio}}
All of these Current User variables except the last one can also be used in Custom Redirection Links.

Date variables

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

  • Refund date formatted like "Mar 22nd 18":
    1{{ticket.customer.integrations.shopify.orders[0].refunds[0].processed_at|datetime_format("MMM Do YY")}}
  • Refund date formatted like "03/22/2018":
    1{{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: 
    1{{ticket.customer.integrations.shopify.customer.default_address.address1}},
    1{{ticket.customer.integrations.shopify.customer.default_address.address2}}, 
    1{{ticket.customer.integrations.shopify.customer.default_address.zip}},
    1{{ticket.customer.integrations.shopify.customer.default_address.city}},
    1{{ticket.customer.integrations.shopify.customer.default_address.province}}
  • Last order id:
    1{{ticket.customer.integrations.shopify.orders[0].id}}
  • Tracking url of the last order:
    1{{ticket.customer.integrations.shopify.orders[0].fulfillments[0].tracking_url}}
  • Product name: 
    1{{ticket.customer.integrations.shopify.orders[0].line_items[0].name}}
  • Variant name: 
    1{{ticket.customer.integrations.shopify.orders[0].line_items[0].variant_title}}
  • Credit card number: 
    1{{ticket.customer.integrations.shopify.orders[0].payment_details.credit_card_number}}
  • Refund process date: 
    1{{ticket.customer.integrations.shopify.orders[0].refunds[0].processed_at|datetime_format("L")}}
  • Last order number:

    1{{ticket.customer.integrations.shopify.orders[0].name}}


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


Big Commerce variables
  • Big Commerce Data:
    1{{ticket.customer.bigcommerce}}
  • First Name:
    1{{ticket.customer.bigcommerce.firstname}}
  • Last Name:
    1{{ticket.customer.bigcommerce.last_name}}
  • Phone:
    1{{ticket.customer.bigcommerce.phone}}
  • Big Commerce Order Id:
    1{{ticket.customer.bigcommerce.orders[0].id}}
  • Customer message:
    1{{ticket.customer.bigcommerce.orders[0].message}}
  • Date created:
    1{{ticket.customer.bigcommerce.orders[0].date_created}}
  • Date shipped:
    1{{ticket.customer.bigcommerce.orders[0].date_shipped}}
  • Items shipped:
    1{{ticket.customer.bigcommerce.orders[0].order_products[0].name}}
  • Items total:
    1{{ticket.customer.bigcommerce.orders[0].items_total}}
  • Refunded amount:
    1{{ticket.customer.bigcommerce.orders[0].refunded_amount}}
  • Staff notes:
    1{{ticket.customer.bigcommerce.orders[0].staff_notes}}
  • Status:
    1{{ticket.customer.bigcommerce.orders[0].status}}
  • Total inc tax:
    1{{ticket.customer.bigcommerce.orders[0].total_inc_tax}}
  • Date created:
    1{{ticket.customer.bigcommerce.orders[0].shipments[0].date_created}}
  • Shipping provider:
    1{{ticket.customer.bigcommerce.orders[0].shipments[0].shipping_provider}}
  • Tracking link:
    1{{ticket.customer.bigcommerce.orders[0].shipments[0].tracking_link}}
  • Tracking number:
    1{{ticket.customer.bigcommerce.orders[0].shipments[0].tracking_number}}
  • City:
    1{{ticket.customer.bigcommerce.orders[0].shipping_addresses[0].city}}
  • Company:
    1{{ticket.customer.bigcommerce.orders[0].shipping_addresses[0].company}}
  • Country:
    1{{ticket.customer.bigcommerce.orders[0].shipping_addresses[0].country}}
  • Country iso2:
    1{{ticket.customer.bigcommerce.orders[0].shipping_addresses[0].country_iso2}}
  • Email:
    1{{ticket.customer.bigcommerce.orders[0].shipping_addresses[0].email}}
  • First name:
    1{{ticket.customer.bigcommerce.orders[0].shipping_addresses[0].first_name}}
  • Last name:
    1{{ticket.customer.bigcommerce.orders[0].shipping_addresses[0].last_name}}
  • Phone:
    1{{ticket.customer.bigcommerce.orders[0].shipping_addresses[0].phone}}
  • State:
    1{{ticket.customer.bigcommerce.orders[0].shipping_addresses[0].state}}
  • Street 1:
    1{{ticket.customer.bigcommerce.orders[0].shipping_addresses[0].street_1}}
  • Street 2:
    1{{ticket.customer.bigcommerce.orders[0].shipping_addresses[0].street_2}}
  • Zip:
    1{{ticket.customer.bigcommerce.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 theintegration_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[{{integration_id}}]
  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 names 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:




Please note: When macros are applied by rules, user-related variables will default to the account owner. 
For example, It will always show the account owner's first name when the macro is sent via rule



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


Was this article helpful?
Yes
No