Create New Ticket With Two Comments

7 Comments

  • Greg Katechis
    Zendesk Developer Advocacy
    Hi Jackson! There is no way to accomplish this with one API call. You would need to create the ticket first and then update the newly created ticket with the other comment in a second call.
    1
  • Stephen Belleau
    Community Moderator

    Jackson Atkins I don't believe this is possible 😞

    Per https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_comments/ The Ticket Comments API has no endpoint to create comments.

    Comments are created with the Tickets API https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/

    which only accepts comment as an object, not array.

    Some thoughts:

    1. If the purpose is to remind agent about steps for a request type, perhaps you can create the Subject with a unique keyword/string for that request type. The Subject gets automatically searched with the Knowledge Capture app, which could return articles containing steps for handling this request type. Assuming you use Guide for internal knowledge.

    2. Otherwise, perhaps create the ticket with public comment and some kind of tag or custom field to capture type of request, and then use that tag/field to trigger a webhook update, or ZIS, or a custom ticket app to perform the private comment and/or apply a macro...

    1
  • Jackson Atkins

    Thanks for the responses. I thought this might be the case but I wanted to check and see if I missed something. Sometimes the API reference allows you to do things that are not documented. 

    What I'm planning to do then is create a custom field with the type of request. Then, I'll have a webhook fire on all new tickets. I'll read the custom field and have the bot post a private comment to the ticket based on the ticket type (basically your option 2). 

    I just wanted to make sure I couldn't handle it in one request before going through the trouble of implementing all of this.  

    0
  • Chris Green

    Greg Katechis - I'm trying to add multiple comments to tickets through the API as well. I have first created the ticket in ZD through the API and am then trying to update the ticket to add an additional comment, but something isn't working, or maybe I just have the format of the request incorrect?

    See below:

     

    0
  • Tipene Hughes
    Zendesk Developer Advocacy

    Hey Chris Green,

    You'll just need to amend the format of the request body slightly. Here's an example that will add an additional comment to the ticket:

    {
        "ticket": {
          "comment": {
            "body": "This is an updated reply on Tuesday",
            "public": true
          }
        }
    }

    Here's a link to the docs that go in to more detail:

    https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#update-ticket

    I hope this helps! Feel free to reach out with any questions.

    Tipene

    0
  • Chris Green

    That did it, thanks Tipene Hughes

    0
  • Ryan Winter

    I found this post when looking for similar functionality on ticket creation.  While technically correct, the tickets endpoint only accepts one comment, there is a workaround for creating multiple comments upon ticket creation. 

    If you use the import tickets endpoint then you can add multiple comments 

    • POST /api/v2/imports/tickets

    If you follow the link above you will see the format looks like this:

    {
        "ticket": {
          "assignee_id": 19,
          "comments": [
            {
              "author_id": 827,
              "created_at": "2009-06-25T10:15:18Z",
              "value": "This is a comment"
            },
            {
              "author_id": 19,
              "public": false,
              "value": "This is a private comment"
            }
          ],
          "description": "A description",
          "requester_id": 827,
          "subject": "Help",
          "tags": [
            "foo",
            "bar"
          ]
        }
      }

    It is worth noting a couple of quirks of the endpoint.  This will not activate any triggers or notifications by design.  It will also add the "description" value as a comment even if there is a comment on the ticket (unlike the tickets endpoint which omits the description in favor of any comment that is present).  

    Hope this helps anybody that finds this ticket after the fact.

    0

Please sign in to leave a comment.

Powered by Zendesk