The Myndbend™ Process Manager action add-approvers-by-email is used to automatically add approvers to tickets, using primary email on their Zendesk user profile, when certain conditions are met.
For example, an end-user may request a refund. Based on the selections in the form, the premium version of MPM can add one or more approvers automatically.
How do I use this action?
Create a Zendesk trigger with conditions that match the moment when you want to add in the approver.
Then set the action in MPM. For the action, select Notify Webhook - MPM Webhook. You will be presented the option to paste in the message that will be sent to our servers.
The message for this action is:
{
"action": "add-approvers-by-email",
"data": ...
}
Where can I find the emails of the users I want to add?
Approvers can be either agents or end-users / customers. If you'd like your end-users to be approvers, you'll first need to follow this guide to enable it in MPM admin settings.
- Navigate to Zendesk Settings > People
- Search for the approver and click on the user's name.
- You'll see the email address on the user profile:
How do I specify the email addresses of users that I want to add?
MPM's action add-approvers-by-email has two options you can use...
Adding approvers using their emails in an array of strings:
{
"action": "add-approvers-by-email",
"data": {
"email": ["user1@myndbend.com", "user2@myndbend.com"]
}
}
Adding approvers using comma-separated string:
{
"action": "add-approvers-by-email",
"data": {
"email": "user1@myndbend.com,user2@myndbend.com"
}
}
Both of these options will perform the same action: Add users with the following emails (e.g. user1@myndbend.com, user2@myndbend.com) as approvers.
How to add approvers from a custom field
Zendesk placeholders can be used in every trigger message body in order to pull data that will be sent to the webhook. That means if you have custom fields that hold the data that you want to send, you can use them! Instead of specifying the emails, though, use a placeholder for the field that holds the ID:
{
"action": "add-approvers-by-email",
"data": {
"email": "{{ticket.ticket_field_<field ID number>}}"
}
}
This also means that you can reference fields on the assignee's or requester's profile! For example, you can have a custom user field that will contain the email address of the requester's manager. This way, the manager of the requester will be added as an approver each time a ticket is submitted:
{
"action": "add-approvers-by-email",
"data": {
"email": "{{ticket.requester.custom_fields.<key_name>}}"
}
}
Conditionally adding approvers based on form data
You may need to add approvers conditionally, based on what data is present in the ticket form itself. For example, a senior manager may only need to added as an approver for expedited tickets. There are two ways to do this:
- Define the conditions of your Zendesk trigger as such. This means that you will have one trigger for each of your possible combinations.
- Use Liquid Script...
Liquid Script is a simple scripting language developed by Shopify, used through Zendesk. You can use the liquid script in your tickets, macros, automations as well as trigger messages.
Using Liquid Script you can write simple conditional statements such as:
{%- if ticket.ticket_field_123 == 'laptop' -%}
321,
{%- endif -%}
The above makes this statement: If the value of our ticket.ticket_field_123 is laptop the script will print 321. Otherwise, it will be skipped completely.
This means we can write conditional statements (as well as more complex scripts) that will determine the final approval list that needs to be added. It's done by including these scripts into our webhook message bodies:
{
"action": "add-approvers-by-email",
"data": {
"email": "
{%- if ticket.ticket_field_option_title_<FIELD_ID> == '<DESIRED_VALUE>' -%}
<USER_EMAIL>,
{%- endif -%}
{%- if ticket.ticket_field_option_title_<FIELD_ID> == '<DESIRED_VALUE>' -%}
<USER_EMAIL>,
{%- endif -%}
"
}
}
Note:
The outlined script above is just an example. Be sure to replace field IDs, values, and user emails with the values you need.
In the above code block, you will notice trailing commas after the user emails. This is required if there will be more than one approver added to the string of approvers.
If you decide to use Liquid Script, be sure to read our quick Liquid guide, which covers some of the most common questions.