Macros
This guide covers how to create, edit, and manage Zendesk macros at GitLab. If you’re a support agent looking to create a simple macro, see Creating a macro as a non-admin. Administrators should review the Administrator tasks section.
Technical Details
- Deployment type:
Ad-hoc - Sync repos
- Managed content repos
Understanding Macros
What are macros
As per Zendesk:
A macro is a prepared response or action that an agent can manually apply when they are creating or updating tickets. Macros contain actions that can update ticket properties.
Unlike triggers and automations, macros only contain actions, not conditions. Conditions aren’t used because nothing is automatically evaluating tickets to determine if a macro should be applied. Agents evaluate tickets and apply macros manually as needed.
Macro categorization
Macros in Zendesk have categorization but it is not obvious in the UI. Instead, the categorization is determined based on the name of the macro itself. Essentially, every group of words becomes a “folder” of sorts in the macros dropdown selector. The separator currently used by Zendesk is two colons (::).
Simple vs. Advanced macros
A simple macro is one that only would modify the following:
- Ticket assignment (or removal thereof)
- Adding tags to the ticket
- Adding a public or private comment to a ticket
- Changing the status of a ticket
If a macro would do anything other than those listed items, it is deemed “advanced” at this time.
Using a macro in Zendesk
There are two ways to apply a macro to a ticket:
- Via slash commands
- Via the macro selection drop-down
For more information, please see Zendesk documentation
How we manage macros
While Zendesk offers a full way to manage macros via the UI, we turn to a more version controlled methodology. This allows for a set review process, the ability to perform rollbacks as needed, etc.
That being the case, we utilize the Zendesk internal forms, sync repos, and managed content repos.
How the sync repo works
The sync repo workflow follows this process:
graph TD; A-->|Webhook fires| E; B-->E; C-->D; D-->|MR merged| E; E-->F; G-->H; H-->|Trigger runs| I I-->|If using managed content| A; I-->|Sleeps 5 min if managed content file was created| B; A(Commit to master in managed content repo) B(Commit to master in sync repo) C(MR created or updated on sync repo) D(bin/compare runs) E(bin/sync runs) F(Changes synced to Zendesk) G(Zendesk internal form submission) H(Ticket created) I(Ticket processor runs)
Human readable replacements
Note
- Only applies to
administratorscreating/editing macros via YAML files
Currently, the sync repo can perform replacements of various items from a human readable item to the “Zendesk” equivalent item. This includes:
| Human readable item | Zendesk field item | Action location | Notes |
|---|---|---|---|
'Brand: XXX' |
brand_id |
value |
Replace XXX with the name of the brand |
'Field: XXX' |
custom_fields_xxx |
field |
Replace XXX with the title of the ticket field |
'Group: XXX' |
group_id |
value |
Replace XXX with the name of the group |
'XXX' |
role |
value |
Replace XXX with the name of the role type OR the email address of the requester |
'Form: XXX' |
ticket_form_id |
value |
Replace XXX with the name of the ticket form |
'Schedule: XXX' |
set_schedule |
value |
Replace XXX with the name of the schedule |
'Schedule: XXX' |
schedule_id |
value |
Replace XXX with the name of the schedule |
'XXX' |
organization_id |
value |
Replace XXX with the salesforce_id attribute of the organization |
'XXX' |
assignee_id |
value |
Replace XXX with the email address of the agent |
'XXX' |
satisfaction_reason_code |
value |
Replace XXX with the name of the satisfaction reason |
'XXX' |
via_id |
value |
Replace XXX with the name of the via type |
'XXX' |
requester_role |
value |
Replace XXX with the name of the requester role type |
As an example, if you wanted a macro to change the value of the field Preferred Region for Support to AMER, you would do the following to use the replacement:
- field: 'Field: Preferred Region for Support'
value: 'AMER'
When creating MRs in the sync repo
When a MR is created on the sync repo, it performs the compare actions (via the bin/compare script), which does the following:
- Performs a clone of the managed content repo
- Fetches all brands, ticket fields, ticket forms, groups, schedules, satisfaction reasons, and macros from the Zendesk instance
- Reviews all YAML files within the sync repo to generate a macro object
- It also checks to ensure none of the following problems exist in the sync repo files:
- A title is missing
- A file with the
activeattribute offalseis not in theactivefolder - A file with the
activeattribute oftrueis not in theinactivefolder - There is not a duplicate use of a
titleattribute - Any file with the
contains_managed_contentattribute oftruehas a matching managed content file
- It also checks to ensure none of the following problems exist in the sync repo files:
- Compares all macro objects from the YAML files to a matching Zendesk item (determined by checking the value of the attributes
titleandprevious_title)- If none exists, it will store a create object in a variable to be used later
- If one exists but has different attribute values, it will store an update object in a variable to be used later
- Output a comparison report
Syncing to Zendesk
The sync repo performs its sync task when one of two events occur:
- The managed content repo sends a signal via a project webhook (configured to do so when a commit occurs on the
masterbranch of the managed content repo) - A commit has occurred on the
masterbranch of the sync repo
When either action occurs, the sync performs the compare actions and then uses the objects generated to perform the needed creates and updates via a loop hitting the needed Zendesk endpoint:
Reporting orphaned managed content files
On the 1st of February, May, August, and November, a scheduled pipeline will have the sync repo create an issue for the support leadership team to review all orphaned managed content files.
This is done via the bin/find_orphaned_files script in the sync repo, which does the following:
- Performs a clone of the managed content repo
- Reviews every file within the
activeandinactivefolders of the managed content repo to determine thestate(i.e.activeorinactive, thepath, and thetitle) - Reviews every file within the
activeandinactivefolders of the sync repo itself to determine:- If the file is using a managed content file
- If there is a managed content file
- If it has located managed content files without a sync repo file, it then creates an issue reporting it to Customer Support leadership
Creating a macro as a non-admin
Simple macros
To get a simple macro created, you would utilize the Zendesk internal form for your instance:
Once the form is filled out and the request submitted, the ticket processor will use the information provided to create your simple macro.
If a managed content file is needed for the macro (i.e. the macro will makes a comment) and one does not already exist, a file will be created for you in the managed content repo.
Advanced macros
For the creation of an advanced macro, please consult with a member of the SIG team first and have them submit an issue to the Customer Support Operations team using this template (as it will require manual intervention by the Customer Support Operations team).
Editing a macro as a non-admin
Changing the comment wording used in a macro
To edit the comment wording in a macro, you will modify the corresponding file in the managed content repo. Once merged to the master branch, it will then sync to the Zendesk instance (via the sync repo).
Changing title, restrictions, non-comment wording actions, and so on
To change anything else in a macro, please consult with a member of the SIG team first and have them submit an issue to the Customer Support Operations team using this template (as it will require manual intervention by the Customer Support Operations team).
Deactivating a macro as a non-admin
To request the deactivation of a macro, please consult with a member of the SIG team first and have them submit an issue to the Customer Support Operations team using this template (as it will require manual intervention by the Customer Support Operations team).
Administrator tasks
Note
- All sections in this section require
Administratorlevel access to Zendesk.
Seeing macro usage information
To see the usage information on macros:
- Navigate to the admin panel for the Zendesk instance
- Go to
Workspaces > Agent tools > Macros - Click the icon to the far right of the list of macros (looks like three vertical rectangles)
- Click the usage columns you wish to see
Creating a macro
Warning
- This should only be done if there is a corresponding request issue (Feature Request, Administrative, Bug, etc.). If one does not exist, you should first create one (and let it go through the standard process before working it).
- If creating a macro that will use a managed content file, you must create said managed content file first.
If creating a simple macro, please see Simple macros.
For the creation of an advanced macro, you will need to create a MR in the sync repo. The exact changes being made will depend on the request itself. A starting template you can use would be:
---
title: 'Your::Title::Here'
previous_title: 'Your::Title::Here'
description: 'Your description here'
active: true
actions:
- field: 'the_action_to_perform'
value: 'the_value_to_use'
restriction: null
contains_managed_content: false
After a peer reviews and approves your MR, you can merge the MR (which will have the changes synced to the Zendesk instance).
Editing a macro
Warning
- This should only be done if there is a corresponding request issue (Feature Request, Administrative, Bug, etc.). If one does not exist, you should first create one (and let it go through the standard process before working it).
- If changing the macro’s
contains_managed_contentattribute fromfalsetotrue, you must create said managed content file first. - If changing the macro’s
contains_managed_contentattribute fromtruetofalse, you should create a follow-up MR to delete the corresponding managed content file.
If only modifying the comment’s wording of a macro, please see Changing the comment wording used in a macro.
For anything else, you will need to create a MR in the sync repo. The exact changes being made will depend on the request itself.
After a peer reviews and approves your MR, you can merge the MR (which will have the changes synced to the Zendesk instance).
Changing the title of a macro
If you need to change the title of a macro, copy the current value into the previous_title attribute and then change the title attribute. This allows the sync to still locate the macro in question to update.
Deactivating a macro
Warning
- This should only be done if there is a corresponding request issue (Feature Request, Administrative, Bug, etc.). If one does not exist, you should first create one (and let it go through the standard process before working it).
- If the macro was using a managed content file (i.e.
contains_managed_contentattribute in the YAML file was previously set totrue), you likely will need to also move the corresponding file from theactiveto theinactivelocation in the managed content repo.
To deactivate a macro, you will need to create a MR in the sync repo. In this MR, you should do the following to the corresponding macro’s YAML file:
-
Move the file from the
activetoinactivepath -
Modify the value of the
activeattribute tofalse -
Change the value of
actionsto the following:-
For Zendesk Global:
- field: 'brand_id' value: 'GitLab Support' -
For Zendesk US Government:
- field: 'brand_id' value: 'GitLab'
-
-
Change the value of the
contains_managed_contentattribute tofalse
After a peer reviews and approves your MR, you can merge the MR (which will have the changes synced to the Zendesk instance).
Deleting a macro
Warning
- You can only delete a macro if it is deactivated.
- This should only be done if there is a corresponding request issue (Feature Request, Administrative, Bug, etc.). If one does not exist, you should first create one (and let it go through the standard process before working it).
- When deleting a macro, you likely will need to also remove the file from the sync and managed content repos.
As the sync repos do not perform deletions, you will need to do this via Zendesk itself.
To delete a macro:
- Navigate to the admin dashboard for the Zendesk instance
- Go to
Workspaces > Agent tools > Macros - Locate the macro you wish to delete and click on the name
- Click the
Actionsbutton - Click
Delete - Click
Delete macroin the confirmation box
Common issues and troubleshooting
Not seeing macro changes after a merge
The sync does usually need 5-10 minutes to fully run. After that time, you should hard refresh Zendesk in your browser (and then check for the changes).
7dfb98d0)
