Automatic ticket creation for task list item (beta)

Also see: Duplicating conversations & attachments into child tickets

 

To have a task automatically create a ticket when it's added to the ticket, first you will need to turn this feature on by clicking on the tasks admin icon on the left of the screen. Then switch it on under 'settings' like this:

SweetHawk__-_Agent.png

Important: please click Save settings to commit any changed settings.

Next... to define the details of the ticket you want to create, under the 'Task lists' tab, go into the desired list, then click the 'edit' button next to the task you want.

SweetHawk__-_Agent_2.png

Finally, in the popup screen, in the 'ticket data' section, you will need to provide some JSON that defines the details of the ticket to be created like this:

SweetHawk__-_Agent_3.png

To have a ticket automatically created, you can start by defining a minimal JSON structure in the Ticket data field:

{}

This will create a ticket with default values: the subject will be set to the task list item's name, the description will be just '.' and created as Internal Note.

If you'd like to set other fields, this can be done like this:

{
  "subject": "Printer fire",
  "priority": "high",
  "tags": ["printer", "fire", "smoke"],

  "comment": {
    "body": "Some smoke is coming out!",
    "public": true
  }
}

You can use liquid markup inside the values to copy values from the parent ticket:

{
  "requester_id": "{{ticket.requester.id}}",
  "comment": {
    "body": "Get back to {{ticket.requester.email}} regarding {{ticket.subject}}",
    "public": false
  }
}

You can set custom fields like this:

{
  "subject": "Printer fire",
  "custom_fields": [
    { "id": 12345678, "value": "custom_field_value" },
    { "id": 12345679, "value": "Here's a value" },
    { "id": 12345680, "value": "{{ticket.ticket_field_12345680}}" }
  ]
}

Please note that multi-select fields cannot be set by value because of the JSON representation. The correct JSON can be generated using the following code:

{
  "custom_fields": [
    { "id": 123, "value": [{% for value in ticket.ticket_field_123 %}"{{value}}"{% if forloop.last == false %},{% endif %}{% endfor %}] }
  ]
}

Or set the form and subject to match the parent ticket like this: 

{
  "subject": "{{ticket.title}}",
  "ticket_form_id": "{{ticket.ticket_form_id}}"
}

Should you wish to copy tags from the parent ticket, please use the code below:

{
  "tags": [{% for value in ticket.tags %}"{{value}}"{% if forloop.last == false %},{% endif %}{% endfor %}]
}

If you want to combine setting specific tags and copying the parent ticket tags as well, you can modify the code like this:

{
  "tags": ["my_custom_tag", {% for value in ticket.tags %}"{{value}}"{% if forloop.last == false %},{% endif %}{% endfor %}]
}

If you want to copy the entire conversation of the parent ticket including attachments you can use this code: 

{
  "comment": {
    "html_body": "{% for comment in ticket.public_comments %}<hr><b>{{comment.author.name}}</b> - {{comment.created_at_with_time}}</br></br>{{comment.value_rich}}{% for attachment in comment.attachments %}<a href='{{attachment.url}}'>{{attachment.filename}}</a></br>{% endfor %}</br>{% endfor %}",
    "public": true
  }
}

Alternatively, if you want to copy ONLY the attachments you could use this code: 

{
  "comment": {
    "html_body": "{% for comment in ticket.public_comments %}<b>{% for attachment in comment.attachments %}<a href='{{attachment.url}}'>{{attachment.filename}}</a></br>{% endfor %}</br>{% endfor %}",
    "public": true
  }
}

Because the JSON used is identical to the format Zendesk uses to create tickets, more information about the fields you can use can be found in Zendesk's API documentation.

 

Have more questions? Submit a request

30 Comments

  • 0
    Avatar

    How i can create newline in comments body?

    something like: "body": "Get back to {{ticket.requester.email}} <br/> regarding {{ticket.subject}}"

     

  • 0
    Avatar

    For newlines, please use "\n" (backslash N) so in your example: "body": "Get back to {{ticket.requester.email}}\nregarding {{ticket.subject}}"

  • 0
    Avatar
    Thomas D'Hoe

    Is it also possible to take the attachments of the parent ticket over in the child tickets?

     

  • 0
    Avatar

    Hi Thomas, currently it isn't possible to replicate the attachments over in the children tickets. I think the key thing to for us to get right if we were able to build this functionality is being able to specify attachments to be copied since often there are many superfluous attachments that are just noise. Copying all of those attachments to many tickets would simply amplify the noise. 

  • 0
    Avatar

    Can you leave comments in the code? I have several fields I am putting in with custom data fields and I would like to note which custom field is on each line. Is there a leading character that indicates comments like -- or // ?

  • 0
    Avatar

    Hi George, you can't technically use comments in JSON but you can use this trick to add meta information for your own purposes:

    {
      "custom_fields": [
        { "id": 12345680, "value": "{{ticket.ticket_field_12345680}}", "field_name": "My custom date field" }
      ]
    }

    By using another node like "field_name" you can effectively add comments, as any JSON fields other than the documented ones will be preserved but ignored.

  • 0
    Avatar

    @Thomas - regarding copying attachments from the parent ticket into the child. We've made a couple of changes to make this possible now. If you just want to copy the attachments you can use this code: 

    {
      "comment": {
        "html_body": "{% for comment in ticket.public_comments %}<b>{% for attachment in comment.attachments %}<a href='{{attachment.url}}'>{{attachment.filename}}</a></br>{% endfor %}</br>{% endfor %}",
        "public": true
      }
    }

    If you want to copy the entire conversation of the parent ticket including attachments you can use this code: 

    {
      "comment": {
        "html_body": "{% for comment in ticket.public_comments %}<hr><b>{{comment.author.name}}</b> - {{comment.created_at_with_time}}</br></br>{{comment.value_rich}}{% for attachment in comment.attachments %}<a href='{{attachment.url}}'>{{attachment.filename}}</a></br>{% endfor %}</br>{% endfor %}",
        "public": true
      }
    }

  • 0
    Avatar

    Hi Peter,

    Q:

    Is it possible to copy Ticketfields, ticketdescription, ... from a parent ticket to a subticket when a tasklist is manually added to the task app?

    By example:

    Tasklist A with task 1,2,3 is added to a ticket in the task app (without creating subtickets). 

    The agent decides to make a ticket from task 2. Is it possible (are already a function) that at that moment the ticketfields, ... from the parent ticket are copied to this subticket "task 2".

    Thanks for looking at this.

  • 0
    Avatar

    Hi Thomas, unfortunately, you can only automatically create sub-tickets with predefined ticket settings at the point a task list template is added to a ticket. You're currently not able to push ticket settings at the point you manually convert a task list item into a sub-ticket.

  • 0
    Avatar

    Aloha Peter,

    I'm very new to Tasks. It's freaking awesome!

    I'm wondering if it is possible populate a specific requestor in a sub-ticket.

    The current use of that is a payroll reminder

    {Parent Ticket 1} Employer Payroll Semi-Monthy:

    Ticket 1 Tasks:

    • {TICKET 2}: Employee 1 Reminder
      • Ticket 2 Tasks
      • Receive time
      • Approve time
      • Record in books
    • {TICKET 3}: Employee 2 Reminder
      • Ticket 3 Tasks
      • Receive time
      • Approve time
      • Record in books
    • Run payroll
    • Schedule Direct Deposits
    • Generate Checks
    • Adjust Liabilities
    • Submit payroll reports

    I'd be cool to have the sub-tickets 2 and three have pre-filled requestors that were the current (manually entered in the ticket data section).

    Also, can we have the subt-ickets be pre-assigned to a group?

    I hope that's not as clear as mud.

     

    Example: 

    {
    "requester": "{371296XXXXXX}"
    "subject": "Timesheet Reminder",
    "priority": "normal",
    "comment": {
    "body": "Friendly reminder for submitting your timesheet",
    "public": true
    "Agent Email": true
    }
    }

    Edited by Nick Croghan
  • 0
    Avatar
    Hi Nick, Glad you're liking the Tasks app :-) It is possible to pre-define who the requester of an automatically created sub-ticket is. However, it would not be possible using a text field. You would either have to reference the requester relative to users on the parent ticket. For example, this might be...
     
    "requester_id": "{{ticket.requester.id}}",

    or

    "requester_id": "{{ticket.assignee.id}}",
     
    ...which would set the requester of the sub-ticket to either the requester of the parent ticket or the assignee of the parent ticket respectively. 
     
    Alternatively, you would need to specify the user id as per the example that you outlined above. However, as it’s an ID and not a placeholder you would not need to place any brackets around it. This would be the same if you wanted to specify the group it. So setting both the user ID and the group ID would look like this:
     
    "requester_id": 7360949508,
    "group_id": 29642428,
  • 0
    Avatar

    Hi Peter & Sweethawk team.

     

    We're experimenting with this flow and it's pretty neat. What we'd love to be able to do would be defer the ticket creation/linking until the item on the task list has been checked off.

     

    In our case, we have a team that is creating a ticket and working through a list. Towards the end of that list, we need to create a linked ticket and have it go to another team, but only after the prior tasks are complete. We could do this with a regular task, but we'd be unable to display the linked ticket in this manner.

     

    Is this something on the roadmap for this feature?

     

    Thanks!

  • 0
    Avatar

    Hi Dan, you could potentially get this working by specifying a tag to be added on the final task that gets completed before the sub ticket needs to be automatically created.

    Then, at the point the tag is added, you could fire a trigger that automatically adds a task list to the ticket. That task list would only contain one task, and that task would contain the details for the sub-ticket to automatically be created (as per this article). 

    If you need a bit of assistance getting this going, shoot a ticket through to support@sweethawk.co and I'll give you a hand. 

  • 0
    Avatar

    Love this feature!

    We're trying to add the organization name to the Subject of the child case that is created, however, it's not working, here's what we have:

    "subject": "{{ticket.organization.name}}",
    "requester_id": "{{ticket.asignee.id}}",
    "group_id": 20506297,
    "priority": "normal",
    "tags": ["dont_bump", "task_beta"],
    "type": "task",
    "comment": {
    "body": "Ticket created by Task Automation Beta",
    "public": false

    When we do this, instead of adding the Organization Name as the Subject, it adds "Ticket created by Task Automation Beta" from the Body!

    Also, is it possible to rename the task itself?  When created it's the name of the task, but when creating the child case we'd like to add the Organization name in there too.

    Thanks in advance, Craig

     

  • 0
    Avatar

    Hi Craig, sometimes ticket.organization is blank and therefore the subject remains blank, which causes the subject to be populated from the description.

    Edited by Vincent Brendel
  • 0
    Avatar

    That did the trick, thank you.

    Is it also possible to have the process re-name the task as shown below?  At the moment they all appear as "Escalate to Operations BETA", could it be renamed to "{{ticket.organization.name}} escalation"?

  • 0
    Avatar

    Hi Craig, sorry as per right now it's not possible. We're working on a feature to show more info from the child ticket in the task view, it sounds like that would help in this case.

  • 0
    Avatar

    Hi,

    Is it possible to replicate the custom ticket fields from the parent ticket to the child ticket?

    Thanks,

    Chee

  • 1
    Avatar

    Hi Chee, yes it is possible to copy the contents of custom ticket fields from the parent ticket into a child ticket, but only at the point that the child ticket is created as per the above article. Once the child ticket exists the only way to copy information over at that point is manual.

    Edited by Peter Godden
  • 0
    Avatar

    Hi Peter,

    Any reasons to why I keep having duplicate tickets being created over and over as seen below?

     

     

    Thanks,

    Chee

  • 0
    Avatar

    Hi Chee, I've created a ticket to help you out with this one. I believe there is an issue with the logic you've set where a task list is automatically being added on ticket creation, and a task within that list has been set to automatically create a ticket that contains the same task list. 

    Edited by Peter Godden
  • 0
    Avatar

    Hello Peter,

    I am using the Beta ticket creation from task list and I am stuck with the assignee of the created ticket.

    I would like that the created ticket to be assigned to a group and not an agent. So in the JSON I set the group_id. But the tickets are assigned to me (the admin) automatically even with the assignee_id set to null :

    {
    "subject":"New ticket created automatically",
    "group_id":36000XXXX, // the group id I would like the ticket to be assigned to
    "assignee_id":null,
    "submitter_id":"{{current_user.id}}",
    }

     

    If you have any idea to solve this.

    Thank you for your help.

     

     

     

  • 0
    Avatar

    Hi Maxence, you can keep the assignee set to none while specifying the group by setting the assignee like this: 

    "assignee_id": "",
  • 0
    Avatar

    Thank you, I also had to modify a trigger that did the assignment automatically that I didn't noticed in the first place.

  • 0
    Avatar

    Hi,

    The last Tasks is not setup to be Automatic, however, the tickets are still being created automatically whenever I select the Task from the Drop Down list of Tasks:

     

    Is there a way to not allow it to create automatically? 

    Chee

  • 0
    Avatar

    Hi Chee, whether a task list is added manually or automatically has no bearing on whether a sub-ticket is created as part of a task within it. In other words, automatically adding a task list to a ticket is a completely different function from specifying that tickets be created at the point a task list is added.

    Defining sub-ticket details is set on each individual task within a task list. If you don't want a sub-ticket to be created, you will need to remove the sub-ticket details from the task in question. For more information on how to control automatically created sub-tickets see this article.

     

  • 0
    Avatar

    Hi,

    Thank you Peter for the comment. I was able to identify the issue.

    I have another question. Is there a way to always pull all comments, whether the main ticket has only Internal comments? I am receiving errors when I attempt to create a Sub-ticket with only internal comments.

    Also, is it possible to auto update the main ticket with an internal comment if there is a new comment on the sub-ticket?

    Thanks,

    Chee

  • 0
    Avatar

    Hi Chee, yes you're able to update the parent ticket based on actions or comments in the sub-ticket with a workaround that we've documented here: https://support.sweethawk.co/hc/en-us/articles/115001684412-Do-stuff-in-a-parent-ticket-based-on-sub-ticket-actions-advanced- 

    Regarding your other query, I've generated a ticket to continue working through this as I'll need to see both the code and the error messages.

  • 0
    Avatar

    Hi Peter,

    We currently have our child tickets set to Internal, "Public: False", this would allow a Child Ticket Comment to be set as an Internal comment. I also noticed that when the Public is set to false, the next comment will default to an Internal comment, unless I click on 'Public Reply'.

    Is there a way to keep the comments as an Internal Comment and set the next initial comment to Public Reply? The reason for being is that if I set "Public: True", the next default comment will be set to Public reply, but that will set the first Child Ticket comments as Public, which is not how we would like it to be. 

    Thanks,

    Chee

  • 0
    Avatar

    Hi Chee, Zendesk's native functionality is that when a private ticket is created, any new comment always defaults to private also unless manually stipulated by the agent updating the ticket. It is not possible to change this functionality in Zendsek. The tasks app only allows you to define ticket details at the point of creation and it does not allow you to alter any subsequent actions. So the only workaround for what you're looking to achieve here is for agents to continue to manually set the next comment to 'public'. 

Please sign in to leave a comment.
Powered by Zendesk