In this article, you'll learn how to change things in a parent ticket base on actions taken in a sub-ticket.
For example, let's say you wanted to post every comment that was made by an agent in a sub-ticket back to the parent ticket as a private comment.
There are 3 steps to make this happen.
Step 2: Get the ID for the Parent Ticket ID field
Step 1: Creating the webhook
1. Enable API
The first step for creating a webhook is to ensure you have enabled API access which is required in order to get a successful authentication.
1.1 Navigate to the Admin Center.
1.2. Select Apps and integrations, then select Zendesk API.
1.3. Select Settings, then enable Token access.
If this is your first time using the Zendesk API, you may be prompted to accept the terms and conditions before this page is visible.
2. Create an API token
2.1. From the same screen, select Add API token.
2.2. Select Copy so that you can use this as the password within the next step, then select Save.
3. Create webhook
3.1 To create a webhook you'll first need to navigate to the Admin Center like this.
Then from the left menu go into webhooks like this:
3.2 Then select Actions, then from the drop-down menu, select Create webhook.
3.3 Now, input the following configuration:
UI Element | Input |
Name | Update many |
Description | A webhook for updating a many tickets. (optional) |
Endpoint URL | https://YOURSUBDOMAIN.zendesk.com/api/v2/tickets/update_many.json |
Request method | PUT |
Request format | JSON |
Important: Make sure you replace YOURSUBDOMAIN with your Zendesk URL ;-)
Also important: Make sure to not alter the URL in any other way.
This is what it should look like:
Select Basic authentication, then input your credentials.
If you created an API token (as per this article), this is where you would paste it as the password and add /token to the end of your email, otherwise, you can use your normal email and password. In either case, Basic authentication should be selected.
Finally, click to Create the webhook.
Step 2: Get the ID for the parent ticket field.
In order for the child ticket to send information to the parent, we'll need to reference the ID of the parent ticket. To do this, from the Admin Center, under Fields, search for the Parent Ticket ID field like this:
Then copy and save the ID next to the Parent Ticket ID field. You will need to use this in step 3.
Step 3: Creating the trigger
Ok you're almost there. To create a trigger simply click on Triggers in your Admin Center, and at the top right click on Add Trigger like this:
Then name your trigger something like "Update parent task"
Next under "Meet all of the following conditions" set the rules when you want the trigger to fire. For example, you may want it to only fire on tickets with an actual parent ticket, so you could add the rule:
"Parent Ticket ID" - "Present"
You may only want to update the parent ticket when the sub-ticket is updated by the agent so you would add the rule:
"Current user" - "Is" - "Agent"
Finally based on the example we used at the start if you're wanting to update the parent ticket with a comment made on the sub-ticket, you'll probably want to check that one has actually been made with this rule:
"Comment" - "Is" - "Present (public or private)"
So your trigger rules might look something like this:
Finally under "ACTIONS" is where you set the rule to notify the webhook you created in step 1.
You will need to add the rule:
"Notify active webhook" - "Update many"
Then the JSON body section is where you define what you want to happen.
Since we'll be wanting to update the parent ticket we need to specify it by referencing the ticket field ID we collected in step 2.
Your code might look something like this:
{
"tickets": [
{
"id": "{{ticket.ticket_field_81189308}}"
}
]
}
Where 81189308 should be replaced with your ticket field ID collected in step 2.
Once you've added in that code, you can start adding other rules to do stuff to the parent ticket. For example, if you wanted to change the status to open it would look like this:
{
"tickets": [
{
"id": "{{ticket.ticket_field_81189308}}",
"status": "open"
}
]
}
You can actually do anything you like to the parent ticket, and the full API documentation can be found on the Zendesk KB here: https://developer.zendesk.com/rest_api/docs/core/tickets
For our example, we're wanting to post a private comment on the parent ticket of what was said on the sub-ticket, so the JSON will look like this:
{
"tickets": [
{
"id": "{{ticket.ticket_field_81189308}}",
"status": "open",
"comment": { "body": "Comment from subticket: {{ticket.id}} - {{ticket.latest_comment}}", "public": false }
}
]
}
Here's what the Actions part of your trigger might look like:
Once you're happy with what you're doing to the parent ticket, simply click to Create the trigger at the bottom right.
Sweet! You're now ready to test out your new workflow.
Just create a ticket, then create a sub-ticket and do something to the sub-ticket which will match the conditions of the trigger above.