Do stuff in a parent ticket based on sub-ticket actions (advanced)

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 1: Create a webhook

Step 2: Get the ID for the Parent Ticket ID field

Step 3: Create a trigger

 


 

Step 1: Creating the webhook

 

Note: Before creating the webhook you may need to follow point 1 & 2 of this article on webhooks if you haven't already done so. 

To create a webhook you'll first need to navigate to the Admin Center like this. 

mceclip0-2.png

Then from the left menu go into webhooks like this:

mceclip1-1.png

Then select Actions, then from the drop-down menu, select Create webhook.

mceclip2-2.png

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:

Zendesk_Admin_Center.jpg

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.

mceclip7-2.png

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:

Zendesk_Admin_Center.jpg

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:

Zendesk_Admin_Center.jpg

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:

SweetHawk__-_Agent_4.png 

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:Zendesk_Admin_Center.jpg

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.

 

 


Was this article helpful?
3 out of 3 found this helpful

Comments

15 comments

  • This has worked perfectly and absolutely improves our workflow. 

    Thank you Peter.

    Top Tip: When getting the ID in Step 2 if you use Firefox to browse to the URL instead of Chrome, it'll display in a more user-friendly format.

    Craig 

    1
  • Thanks for the tip Craig! ... yes, I think for Chrome I had to install this plugin to make it look nice.

    0
  • Not real useful if you have MFA turned on for all accounts.

    0
  • Hi Hugh, if you have MFA (Multi-Factor Authentication) turned on, when setting up your target, you'll need to use a token instead of the normal username and password. 

    To create a token goto 'Channels' -> 'API' and click to add one. Once created, copy it somewhere safe because you'll never have access to it again. 

    Then, over in the target, for password, paste in your token. 

    ...and for username, put in your email address with a /token after it like this.

    peter@company.com/token

    If you have any troubles getting it going shoot an email through to support@sweethawk.co :-)

    0
  • Hey Peter,

     

    Is there any way to have this update check off a task in the parent ticket? I've tried adding the tag associated to the task I want to mark complete as part of the update, but it doesn't seem to change the task state on the parent.

     

    Thanks!

    0
  • Hi Dan, the only task in a parent ticket that you're able to check off within the sub-ticket is it's own task (ie. the task linked to the sub-ticket) which is done by marking the sub-ticket as 'solved'. 

    So, while you can do just about anything else to the parent ticket, checking other tasks is unfortunately not currently possible.

    0
  • Hi Peter, 

    Is there a way to only have parent tickets assigned to certain groups open instead of all groups in Zendesk?

    Thank you, 

    0
  • Dear all,

    I've been following the instructions here but I have not been able to have this trigger working. I have added two conditions: it must contain one specific tag and the parent ticket must be created with a specific form.

    I don't know if that's the issue. Another question I have is regarding the Parent Ticket ID. The explanation does not make it clear if we talking about the parent ticket FORM or a ticket field in the parent ticket (i.e Step 2: Get the ID for the parent ticket field.). Could you please clarify that?

    That's the JSON I've added to the trigger:

    {
    "tickets": [
    {
    "id": "{{ticket.ticket_field_360000592272}}",
    "comment": { "body": "Comment from subticket: {{ticket.id}} - {{ticket.latest_comment}}", "public": false }
    }
    ]
    }

     

    In which 360000592272 is the parent ticket form ID. I got it from the ticket form URL. Is it the same?

    Sorry for sending so many questions, but this feature can help me a lot.

    Thanks.

     

    0
  • Thanks for posting Waldemar. I see you also have a ticket open for this question so we'll continue to work through this with you over on the ticket. 

    0
  • Dear all,

    Is it possible to automatically upload to the parent ticket files attached to the sub ticket?

    0
  • Hi Waldemar, to include attachments you just need to replace the comment placeholder with {{ticket.latest_comment_formatted}}.

    You are more than welcome to submit a request with us if you have any follow-up questions.

    0
  •  How do I put the last comment on the new line?
    Please see JSON below at the point of ((NEW LINE))

    {
    "tickets": [
    {
    "id": "{{ticket.ticket_field_81189308}}",
    "status": "open",
    "comment": { "body": "Comment from subticket: {{ticket.id}} - ((NEW LINE)) {{ticket.latest_comment}}", "public": false }
    }
    ]
    }

    0
  • Hi Carly, you can use \n to create a new line. Example:

    "comment": {
    "body": "Line 1. \n Line 2. \n Line 3.",
    "public": false
    1
  • Hi Guys,

    I have been asked to add the sub tickets subject to the comment I tried this but it didn't work. Can you please advise?

    {
      "tickets": [
        {
        "id": "{{ticket.ticket_field_14673171178393}}",
        "status": "open",
        "comment": { "body": "Subticket: {{ticket.id}} Ticket Subject: {{ticket.subject}} \n Has been closed by {{current_user.first_name}}. \n \n Last comment: \n {{ticket.latest_comment}}", "public": false }
        }
      ]
    }

    0
  • Hi Carly, thanks for posting. While we have already resolved this directly for you in Zendesk ticket, for the benefit of anyone else reading, the placeholder to use in this instance would be {{ticket.title}} instead of {{ticket.subject}}.

    0

Please sign in to leave a comment.