Macro Variables and Actions

Updated 5 days 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.

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")}}
BigCommerce variables

Please find the Complete list of variables here.

Back-office variables

Back-office variables 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.io/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[0].delivery_cost}

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

Actions

Please note that this function is available to all customers but will only be supported for Advanced and Enterprise plan customers. While any plan can set up the integration following the instructions, due to the manual work it requires on our end, if you are on the Basic or Pro plan we will not be able to provide support in setting it up or fixing any issues with it should they arise.
Shopify actions

HTTP actions can be used to trigger specific actions in Shopify that are not included by default in Gorgias.

For example, Shopify Plus allows you to create gift cards for customers. You can use macros to create custom gift card codes in Gorgias, and set the value of the gift card. To create a $10 gift card with a custom code please follow the guidelines below:

  1. Let's add a gift card action to a macro. In the Shopify admin, click on 'Apps'.
  2. At the bottom of the page, click on 'Manage private apps'.
  3. Click 'Create a new private app' and name it 'Gorgias gift cards'.
  4. Click on 'Review disabled Admin API permissions' and select 'Read & Write' in the price rule section, then hit 'Save'.
  5. Now, let's grab the API key first and copy it. The key now needs to be converted from ASCII to HEX and then from HEX to Base64. You can use any online converter to do this. Here's a video tutorial that will hopefully help:
  6. We're almost there, now head over to a ticket in Gorgias.
  7. Click on 'Manage macros' to open the macro menu and select the macro you want to edit.
  8. Click 'Add action' and select 'HTTP Hook'.
  9.  Put the config below:
Title: Create a new $10 gift card with a custom code
POST: https://your-store.myshopify.com/admin/gift_cards.json
Headers: Authorization Basic {copy text from 8b}
Body:
{
"gift_card": {
"note": "Created by Gorgias for customer {{ticket.customer.email}}",
"initial_value": 10,
"template_suffix": "gift_cards.birthday.liquid",
"code": "{{ticket.customer.integrations.shopify.customer.first_name}}{{ticket.id}}20GC"
}
}

Please just keep in mind that the macros that have any kind of action included cannot be used inside the rules. They will not show on the list under the 'apply macro' action once creating a rule.
LoyaltyLion actions

HTTP actions can be used to trigger specific actions in Loyalty Lion.

To award a given number of points to a customer, create an HTTP hook with the info below: 

Title: Award any number of points to a customer
POST
URL: https://api.loyaltylion.com/v2/customers/{{ticket.customer.integrations["xxxxx"].customers[0].merchant_id}}/points
Headers:
Authorization Basic {based64 encoded API key}
application/json
Body:
{
"points": 1500
}
Make sure to substitute "xxxxx" in the URL with the integration number of your Loyalty Lion integration. It's the last string of numbers that you see in the URL when you are on the Loyalty Lion integration page.
Klaviyo actions

If you want to add a customer to a specific Klaviyo list, you can add an HTTP action that will do it for you. 

  1. Go to the Klaviyo you want to subscribe customers to.
  2. Copy the Subscribe URL. Here is an example: https://manage.kmail-lists.com/subscriptions/subscribe?a=123456789
  3. In Gorgias, open a ticket, click on Manage Macroscreate a macro, click Add action and click HTTP hook
  4. Fill the hook with the info below:
Title: Add customer to Klaviyo list
POST: url from step 2
Body (application/x-www-form-urlencoded): email {{ticket.customer.email}}

Done!

Now, to add a customer to a Klaviyo list, just use the macro. 

Please note that this macro will need to be used manually in order to push customer emails to a certain Klaviyo list. If you only have one list you want to push all customer emails to, you can simply set up an HTTP integration, as outlined here. If you have multiple lists, it would be best to keep using macros.
HTTP actions

HTTP actions can be performed with macros as well by adding webhooks directly inside a macro.

Snooze actions

We have a new feature now that lets you auto-snooze tickets using macros! Please have a look at the video tutorial below on how to set this up:


How did we do?


Powered by HelpDocs (opens in a new tab)