Add comment in service desk ticket based on restriction in jira software issue

I need help on a script that can be used in exalate plugin to check if a comment is added with a restriction in jira software issue then it should add as internal note on synced service desk ticket and if it is added without any restrictions then it should be added as a customer comment in synced service desk ticket.
This is required for Jira cloud and not Jira On Premises

Regards,
Mayuresh

I tried this script but it is not working :-
if (!firstSync && replica.projectKey == issue.projectKey){
issue.comments = commentHelper.mergeComments(issue, replica, {
comment →
comment.executor = nodeHelper.getUserByEmail(comment.author?.email)
comment.body = comment.author.displayName + " commented: " + comment.body + “\n”
if (comment.role != “Engineer”){
comment.internal = true}
else{comment}
})
}