Macros

Updated 2 days ago by Romain Lapeyre

A short video to guide you through creating and using macros in your answers:


Need to get familiar with your account's features or a simple refresh your memory? Check out our tutorials!

What are macros?

Macros are pre-made responses that you can use to respond to your customers faster.

Macros can perform a number of actions on a ticket including:

  • Insert response text: insert text into the response area. You can include variables such as the customer's first name
  • Set subject: change the subject of the ticket
  • Add tags
  • Set status
  • Set assignee
  • HTTP actions: trigger webhooks in other applications (such as refunding a customer on Stripe)

Creating macros

Here's how to create a macro: 

  • Go to any ticket
  • In the reply area, click on Search macro by name
  • Click on Manage Macros on the right of the preview pane. This opens the manage macros page. 
  • Click on Create macro
  • Name your macro, and type the pre-made response in the Set response text area. 
  • Optional: add an action, like editing a Shopify order or adding a tag
  • Click the green Create macro button at the bottom right

Now, head to the section below to insert it in a ticket!

How to use macros in a ticket? 

To insert a macro in a ticket, click on "search macros" in the reply area, and select the macro you want to insert! 

You can display the macro menu by default on email tickets. To do so, head to Your profile, and check Display macros by default on emails under Preference

Macro variables

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, ensure that you’ve added it in Integrations first.

Gorgias variables

  • Ticket channel: {{ticket.channel}}
  • Ticket subject: {{ticket.subject}}
  • Receiver email: {{ticket.receiver.email}}
  • Ticket id: {{ticket.email}}
  • Ticket requester id: {{ticket.requester.email}}
  • Ticket url: https://{account.name}.gorgias.io/app/ticket/{{ticket.email}}
  • 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 date using the moment.js syntax. See below some examples: 

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

Shopify variables

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

Back-office variables

Back-office variables a bit more harder to use, since each back-office 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_id is 9141
  3. Now, the path to your integration is ticket.requester.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.requester.integrations[9141].data[0].delivery_cost}

That's it. This is probably one of the most complex parts of Gorgias. If you need help, ping us on the Slack community!

HTTP actions

HTTP actions can be performed with macros. If you need any assistance adding HTTP actions, ping us at support@gorgias.io.

Shopify actions

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

Send an account invite for the customer

Title: Send an account invite for the customer
          POST: https://your-store.myshopify.com/admin/customers/{{ticket.requester.customer._shopify.customer.email}}/send_invite.json
          Headers: Authorization {your-auth-token}
          

Create a new $10 gift card with a custom code

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. 

As of now, this require manual setup because the Shopify gift card endpoint is not available to apps. 

Let's add a gift card action to a macro:

  1. 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
  4. Name it Gorgias gift cards
  5. Click on ▼ Review disabled Admin API permissions 
  6. Select Read & Write in the price rule section
  7. Save
  8. Copy the API key and password on this website, and add a between the 2 to get your authorization header

  9. We're almost there, now head to a ticket in Gorgias
  10. Click on Manage macros to open the macro menu
  11. Select the macro you want to edit
  12. Click Add action and select HTTP Hook
  13.  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": {
                      "template_suffix": "gift_cards.birthday.liquid",
                      "initial_value": 10,
                      "code": "{{ticket.requester.customer._shopify.customer.first_name}{{ticket.email}}10GC",
                      "note": "Created by Gorgias for customer {{ticket.requester.email}}"
                  }
              }
          

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: <a href="https://api.loyaltylion.com/v2/customers/{{ticket.requester.customer.loyalty_lion[0].merchant_email}}/points">https://api.loyaltylion.com/v2...</a>
          Headers:
              Authorization Basic {based64 encoded API key}
              Content-Type application/x-www-form-urlencoded
          Body: points 20

Klaviyo actions

If you want to add a customer to a given 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. Modify the URL to include "external/", as shown in the example below: https://manage.kmail-lists.com/subscriptions/external/subscribe?g=LIST_ID
  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.requester.email}}

Done!

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


How did we do?