Automatically add comments to tickets

Although not officially supported by Zendesk due to potencial race condition issues, it is possible to add comments to tickets using a trigger or an automation. This could be particularly useful for non-email channels like Facebook or WhatsApp, where Facebook’s 24-hour rule applies.

Use case: notifying customers outside business hours

Suppose our business doesn’t provide customer support between 7pm and 8am, so we’d like to notify customers who write to us during that period.

We want to notify them once, letting them know no one is currently available to handle their request immediately, but that we’ve received it.

In this case, we’ll need a trigger, not an automation (read about the difference between them).

Here are the sub-tasks we’ll need to complete:


Adding a schedule

We’ll create a new schedule, Support Hours:

Assigning a schedule to the ticket

Now, we’ll ensure office hours are applied to every single ticket.


The URL targets

Now we’re going to create two Zendesk URL targets (one for public comments and another for internal notes) in Extensions, a section you’ll find under Settings. I’ll name them “Comments :: Add public comment” and “Comments :: Add internal note”.

Again, these are URL targets:

Comments :: Add public comment

  • URL: https://yoursubdomain.zendesk.com/api/v2/tickets/{{ticket.id}}.json?ticket[comment][public]=true
  • Method: PUT
  • Attribute name: ticket[comment][body]

Comments :: Add internal note

  • URL: https://yoursubdomain.zendesk.com/api/v2/tickets/{{ticket.id}}.json?ticket[comment][public]=false
  • Method: PUT
  • Attribute name: ticket[comment][body]

Trigger or automation to notify customer

All you have to do now is to create your trigger(s) or automation(s) to notify the target and add a comment to the ticket.

Let’s name our trigger ALL :: C :: Social – Private :: Facebook + Twitter :: Notify user during off-hours (pro-tip: having naming rules/structure is essential for proper help desk organization, also easing administrative work).

Here are its conditions (under ALL and ANY):

As you can see, we’re ensuring it only executes when the ticket is created; when our Support Hours schedule has been applied to it; when we’re not within business hours;

And here are the trigger actions:

I’m adding that tag just in case (it does not affect the workflow)

This is a simplistic approach because many businesses operate under different time zones and/or working hours. If you choose to notify users with triggers, the latter should be positioned after the trigger(s) setting the ticket Schedule.

Although the example in this article is basic, a trigger’s ‘Within business hours?’ condition will still evaluate a schedule on a per-ticket basis, so assigning the correct schedules to the right tickets is crucial.


See it in action

I’ve used a test account to send a Twitter DM out of office hours.

As you can see in ticket Events, the admin user you chose to authenticate the target with is the one leaving the automatic reply (and the “By Web Service” note confirms it’s a comment posted via API).

Of course, the customer will not see anything related to this admin user. The comment will be sent under the Twitter account you’ve integrated, so everything should look normal for users.


Disclaimer: use with moderation

Do not abuse these features, as they’re not natively supported by Zendesk, mostly because native business rules respect a cycle which updates via API do not, meaning there may be resulting race conditions.

Also, please remember these automated comments do not replace agents. I’d recommend using them for very specific situations only, as opposed to a generalized usage.

For starters, I’d recommend refraining from adding automated public comments for any email-based channels. In other words, try using these targets for channels where you can’t email the ticket requester using native business rules.

For example:

✔️ You usually receive a few Facebook private messages during off-hours. You trigger a single public comment informing these users of your schedule, that you’ll address their request as soon as possible, etc.

❌ You create an automation that adds an internal note to all tickets without any activity in the last hour.

So please ensure the triggers that notify these targets have enough conditions to avoid firing repeatedly, and that what you create makes sense in the long run. In addition to contributing to your API rate (which is limited), get too many failures and your target might be deactivated.


Header photo: Ioana Cristiana via Unsplash

Leave a Reply

Your email address will not be published. Required fields are marked *