Myndbend™ Process Manager enables you to automatically create child tickets by a trigger. For example, when a New Hire Request is submitted as a ticket in Zendesk, there is a list of different tasks that need to be completed to onboard a new person, including:
- The account manager needs to set up all of the accounts that are needed (Zoom account, Slack account, mail account, etc.)
- The IT department needs to make sure that the proper laptop is configured
- The HR department needs to track that the employee is trained on important policies and guidelines
- Many more tasks may need to be assigned depending on company policy and the role of the new employee
Action create-child-tickets is used to automatically create child tickets from templates you've created in MPM.
A template is used to create one child ticket. A template set is a group of templates that can be used simultaneously or sequentially to create many tickets. You can create templates (and add them to sets if necessary) in the MPM admin settings (left side of Zendesk, circular icon). Each template and the set will display an ID that you can use in the trigger:
How do I use this action?
Create a Zendesk trigger with conditions that match the moment when you want to create the child tickets.
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": "create-child-tickets",
"data": [...]
}
Creating a child ticket from a template
In order to create a child ticket from a template, you'll need to note which templates you want to use in the ticket creation. In this example, let's say we want to create tickets from templates ID 123 and ID 234.
The action is expecting an array of objects (a bit down in the article...we'll explain why). To define templates you want to use, you can specify it under the templates property, either using an array:
{
"action": "create-child-tickets",
"data": [{
"templates": [123, 234]
}]
}
Or using a comma-separated string:
{
"action": "create-child-tickets",
"data": [{
"templates": "123,234"
}]
}
Both of the messages outlined above will do the same thing: Create child tickets from templates (e.g. "123" and "234").
Creating a child ticket from a template set
Myndbend™ Process Manager allows you to group multiple templates into a template set. A template set is used to create child tickets from all of the templates in the set at once. In order to create child tickets from templates, you need to note the ID of the set you want to use.
o define sets you want to use, you can specify it under the sets property, either using an array:
{
"action": "create-child-tickets",
"data": [{
"sets": [1, 2]
}]
}
Or using a comma-separated string:
{
"action": "create-child-tickets",
"data": [{
"sets": "1,2"
}]
}
Both of the messages outlined above will do the same thing: Create child tickets from sets (e.g. "1" and "2".
Combining templates and sets
As mentioned above, the action is expecting an array of objects. That means that you can provide multiple properties at once. So, you can create tickets from templates and from the sets at the same time!
Again, this can be done either using IDs in an array of numbers:
{
"action": "create-child-tickets",
"data": [{
"templates": [123, 234],
"sets": [1, 2]
}]
}
Or using comma-separated string:
{
"action": "create-child-tickets",
"data": [{
"templates": "123,234",
"sets": "1,2"
}]
}
Both of the messages outlined above will do the same thing: Create child tickets from sets (e.g. "1" and "2") and child tickets from templates (e.g. "123" and "234").
Conditionally creating tickets based on the form data
As mentioned at the beginning of this article, in a lot of cases you'll need to create child tickets conditionally, based on the form data (e.g. "name of user that is submitting the tickets", or any other parameter that is in the ticket). 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! (see my comment on this in previously edited articles)
Using Liquid Script, you can write simple conditional statements such as:
{%- if ticket.ticket_field_123 == 'laptop' -%}
321,
{%- endif -%}
With this statement: If the value of our ticket.ticket_field_123 is a laptop the script will print 321. Otherwise, it will be skipped completely. Meaning, if the value of our field is a laptop (for example, we've selected that the new hire needs to get the laptop) - We will create a child ticket form template 321. You can use any of the Zendesk Placeholders to pull data from the ticket in combination with Liquid script.
This means we can write conditional statements (as well as more complex scripts) in MPM that will determine the final list of child tickets that need to be created. This is done by including these scripts into our webhook message bodies, like so:
{
"action": "create-child-tickets",
"data": [{
"templates": "
{%- if ticket.ticket_field_option_title_<FIELD_ID> == '<DESIRED_VALUE>' -%}
<TEMPLATE_ID>,
{%- endif -%}
{%- if ticket.ticket_field_option_title_<FIELD_ID> == '<DESIRED_VALUE>' -%}
<TEMPLATE_ID>,
{%- endif -%}
"
}]
}
The outlined script above is just an example. Be sure to replace field IDs, values, and user IDs with values you need.
Also, the example outlined above is formatted in a way that makes it easy to read for our readers. Please make sure to remove all of the spaces in the actual trigger, like so:
{
"action": "create-child-tickets",
"data": [{
"templates": "{%- if ticket.ticket_field_option_title_<FIELD_ID> == '<DESIRED_VALUE>' -%}<TEMPLATE_ID>,{%- endif -%}{%- if ticket.ticket_field_option_title_<FIELD_ID> == '<DESIRED_VALUE>' -%}<TEMPLATE_ID>,{%- endif -%}"
}]
}
In the above code block, you will notice trailing commas after the template ID. This is required if there will be more than one child ticket added to the string of IDs.
If you decide to use the Liquid Script, be sure to read our quick Liquid guide, which covers some of the most common questions.
Using the optional ticket object
Besides templates and sets properties that the object has, it also has a ticket object, which allows you to override any of the properties you've defined in the template directly from the trigger. This object supports all of the properties that are available in Zendesk Ticket API.
If you have 10 different templates, for example, and the only difference between them is in the subject, you can define new subjects directly in the trigger body. (This is much more convenient than having to define 10 different templates.):
{
"action": "create-child-tickets",
"data": [{
"templates": "123,234",
"ticket": {
"subject": "Our new subject"
}
}]
}
In this case, we will create child tickets from templates 123 and 234, but instead of using the subject defined in the templates, both of these templates will have their subject set to "Our new subject"!
Again, just like with any other example, you can use the Liquid Script in this part as well . It will parse the data available on the parent ticket and dynamically set the properties to your child tickets.
Using the ticket creation objects
Our target allows you to define multiple objects that need to be created, in a single call:
{
"action": "create-child-tickets",
"data": [
{
"templates": "1",
},
{
"templates": "2"
}
]
}
This will create two child tickets, one from template ID 1, one from template ID 2.
You must be thinking - Why would I use this? Isn't it easier to define this like:
{
"action": "create-child-tickets",
"data": [{
"templates": "1,2"
}]
}
This option is useful when you want to use the same template with slight alterations using ticket property:
Our target allows you to define multiple objects that need to be created, in a single call:
{
"action": "create-child-tickets",
"data": [
{
"templates": "1",
"ticket": {
"subject": "Subject #1"
}
},
{
"templates": "1",
"ticket": {
"subject": "Subject #2"
}
}
]
}
With this, we are able to create two tickets with different subjects from the same template!