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}}" }
  ]
}

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

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

 

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

15 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
Please sign in to leave a comment.
Powered by Zendesk