How to Sync Comments in Freshdesk

    This article shows how to synchronize comments.

    Freshdesk Side Incoming sync

    You can add new comments and keep the existing comments updated using mergeComments comment helper. This method would prepend the comment content with the author of the original comment. This is the default behavior.

    entity.comments = commentHelper.mergeComments(issue, replica)

    Apply received comments without custom formatting

    The comment is added just with the body from the original comment, without the author of the original comment.

    entity.comments = commentHelper.mergeComments(issue, replica, {it})

    Create received comments as internal

    issue.comments = commentHelper.mergeComments(issue, replica, {it.internal = true})

    Manipulate the comments via helper methods

    With the help of commentHelper methods, you can manipulate comments and define how to apply received comments on the local issue.

    // Format each remote comment - add the author name and email
    
    issue.comments = commentHelper.mergeComments(issue, replica,                      
                        {
                           comment ->
                           comment.body =
                              "[" + comment.author.displayName +
                                      "| email: " + comment.author.email + "]" +
                                      " commented: \n" +
                              comment.body + "\n" 
                        }
    )