Custom Object Placeholders and Object Triggers in Zendesk

Custom Object Placeholders and Object Triggers in Zendesk

This article explores the new capabilities for Custom Objects with the new support for object triggers and dynamic placeholders.

When I wrote my Custom Objects series earlier this year, one of the main items I missed in building out flows was the ability to use the values of custom object fields when using macros or triggers.

For example, while you could use a macro that said "Thanks for contacting us about {{product.name}}", we couldn't use the same to e.g. reference the purchase date or product type of the selected record.

Similarly, if we have a user contacting us, and we need to contact that users' company main contact person, we couldn't create a side conversation for {{ticket.organization.main_contact.email}}.

Luckily, this has now changed with the release of placeholders for Custom Objects

Announcing placeholders for lookup relationship fields
Announced on Rollout starts Rollout ends July 9, 2024 July 9, 2024 July 10, 2024 Zendesk is pleased to announce powerful new placeholders on lookup relationship fields for tickets, ticket requ…

Let's put this into practice.

Overview

Imagine we're the support department for a small movie theater. We've got a series of movies playing and store those movies in Custom Objects so we can easily provide information to our customers.

Similarly, we also leverage custom objects to store mobile ticket purchases in Custom Objects so we can quickly reference a customers' bookings.

In our demo scenario we've got a customer contacting us requesting information about a movie playing in the theater. They decide they like the movie, and purchase tickets.

We'll use a combination of macros and custom object triggers to handle this scenario.

Using placeholders in Macros

Custom Object

As mentioned above, we've got a list of movies stored in Custom Objects. Each movie has a title (name), director, summary, genre and a list of actors.

To make the demo easy to setup, I used the new Data Importer in the Admin Center to import a set of movies.

This new importer allows you to import CSV files and create and/or update organizations and custom objects in bulk in your instance. For example, the csv table below can be imported into our custom object and it would create all movies.

name director genre external_id
Inception Christopher Nolan science_fiction 1
The Dark Knight Christopher Nolan action 2
Forrest Gump Robert Zemeckis drama 3
Titanic James Cameron romance 4

If I'd later import a similar file, but this time add columns for summary and actors then the importer would update the existing movies, as long as the external_ids match.

Ticket Fields

Our ticket form for this scenario has a custom field to log the Movie the customer is interested in. Since our movies live in custom objects we're using a lookup field, linked to the Custom Object, instead of a text field to store this value. This way we can reference the chosen movie in our flows and macros.

The Macro

Macros in Zendesk are an easy way for agents to reply with a predefined text. They've always supported placeholders to reference a requesters' name, custom field values or an assignee's name in the macro text, making the replies more personal and contextual.

If for example you want to use a requesters' name in a macro, you can use {{ticket.requester.first_name}}. Or if you want to print the Order Number stored in field 123456789 you can use {{ticket.custom_fields.custom_fields_123456789}}.

With the new placeholders for custom objects we can do a couple of fun things in our macros. Let's assume we have the following movie stored in our objects, and we have a lookup field on our ticket form with ID 123456789:

name,director,genre,external_id
"Inception","Christopher Nolan","science_fiction","1"
  • {{ticket.ticket_fields_123456789.name}} will return Inception,
    which is the name of the custom object.
  • {{ticket.ticket_fields_123456789.external_id}} will return 1,
    which is the external id of the custom object.
  • {{ticket.ticket_fields_20080718149010.custom_fields.director}} will return Christopher Nolan,
    which is the value of the custom field director on the custom object.
  • {{ticket.ticket_fields_20080718149010.custom_fields.genre.title}} will return Science Fiction,
    which is the value (not the tag) of the dropdown field genre on the custom object.

You can find a full overview of all placeholders in this support article:

Zendesk Support placeholders reference
What’s my plan? Zendesk Support placeholders are containers for dynamically generated ticket, user, and custom data. The format is a data reference contained within double curly brackets. Since yo…

Our macro will have the following content:

Hey {{ticket.requester.first_name}},
It seems you're interested in knowing more about {{ticket.ticket_fields_20080718149010.name}}

Here's some info:
Director: {{ticket.ticket_fields_20080718149010.custom_fields.director}}
Genre: {{ticket.ticket_fields_20080718149010.custom_fields.genre.title}}

Summary
{{ticket.ticket_fields_20080718149010.custom_fields.summary}}

Some actors you might know
{{ticket.ticket_fields_20080718149010.custom_fields.actors}}

Putting it all together

With the setup complete, we can test out our flow.

  1. We get an email from a customer interested in the Gladiator movie.
  2. The agent goes to the ticket fields and selects Gladiator in the Movie lookup field.
  3. They then select the macro that returns movie information.
  4. The comment field gets filled with our macro text, with all the placeholders replaced with the information stored in our custom object.

Conclusion

As you see above, we can leverage all the available fields in our custom object in our trigger and create rich replies with a lot of contextual data.

There's however still a few scenarios that aren't possible yet. Currently our placeholders all make a single hop. We can return a movies' title or director as shown in the macro above.

But imagine the director field is a lookup field itself that references a user in Zendesk. That user has an email, age, Oscars won and other custom fields.

What we currently can't do yet is returning a director's age or Oscars won in a macro. Something like {{movie.custom_fields.director.custom_fields.oscars}} is not possible for now.

We can return these so called second hops for ticket requesters and organizations though. So something like {{ticket.requester.custom_fields.manager.email}} would return the email of a customers' manager, stored in a lookup user field on that user.

Object Triggers

Macros are one of the scenarios where we can leverage placeholders. A second feature in Zendesk that supports them is Object Triggers.

Object triggers are a new feature in Zendesk that allows you to automate processes based on changes in custom objects.
Similar to how a Ticket trigger gets fired when a ticket gets updated or created, object triggers run when the same action happens on a custom object.

What's possible

Why would you use this? Well, custom objects are mainly used to store associated data on top of tickets, users or organizations. If you use Zendesk to handle support tickets, and you sell Service Contracts to customers, you can leverage custom objects to store the contract data (types like gold or silver, renewal date, associated services,..) and link it via a lookup field to an organization.

Similarly, in an asset management scenario you might link newly purchased assets to users or locations.

Object triggers can be used in these scenarios to automate processes on top of your records. When a service contract is renewed, or is about to expire, you can use an object trigger to send out a notification to the customer.
Or when you've received the new laptop or license for an employee, you can send out the serial code or confirmation to the employee when you log the asset in your custom object records.

Conditions

Object triggers can fire when certain conditions are met:

  • A custom object of a specific type is created or updated
  • A custom object field has (or hasn't) got a certain value
    (e.g. order status is updated to shipped)
  • A lookup field attached to the object is linked to a certain other record
    (e.g. manager is John)
Understanding object triggers
What’s my plan? In addition to using custom objects related to tickets in ticket triggers, you can also define triggers that run any time an object’s record is created or updated. These are called…

Actions

Once the conditions are met we can:

  • Update a value of the custom object
    (e.g. set notified to true)
  • Notify someone via email, webhook, or text
    (e.g. ticket requester, the assignee, or a linked user via lookup fields)

Example flow

To show how object triggers work in practice, we'll continue our previous demo scenario. This time the customer is interested in buying tickets for their movie of choice, Gladiator.

Custom Object

Just like with the movies earlier, we first create a Custom Object to store movie tickets sold. Each ticket has a name, date, time, number of tickets and other related data associated with it.

One of the fields to note is the Buyer field. This is a lookup field that links to users in our Zendesk instance and is used to link ticket to their respective buyers.

Custom Object trigger

Now that we have our object, we can leverage the new custom object triggers. These live in a separate tab under Objects and Rules > Triggers in your Admin Center.

Our goal with our trigger is to send an email to the customer when new tickets are purchased by them.

To start, we setup a condition that looks at our Movie Ticket object, and used the is created condition.

Next, we'll add an action to notify via email. Since each record has an associated buyer, we can select them as a recipient. The system will automatically use their primary email address to send out the email.

💡
Emails send out via this way are send via [email protected] and not your regular support addresses!

My email body will contain the following payload:

Hey,

Thanks for buying tickets for {{custom_objects.movie_ticket.custom_fields.movie}}.

The show starts at {{custom_objects.movie_ticket.custom_fields.time}} on {{custom_objects.movie_ticket.custom_fields.date | date: '%Y-%m-%d'}}

You bought {{custom_objects.movie_ticket.custom_fields.number_of_seats}} seats for a total of {{custom_objects.movie_ticket.custom_fields.total}}$

You'll notice the format of the placeholders here are a bit different than those used for macros. Since they run on objects rather than tickets, we need to use a custom_objects.object_type syntax. Since our movie ticket object has an identifier of movie_ticket (as set when we created the type), we can call all custom fields in the object via {{custom_objects.movie_ticket.custom_fields.field_key}} .

  • {{custom_objects.movie_ticket.custom_fields.movie}} returns the associated movie stored in a lookup field.
  • {{custom_objects.movie_ticket.custom_fields.total}} returns the value of the a custom field called total.
  • {{custom_objects.movie_ticket.name}} returns the name of the record.
Since we're using a date field, we can use some formatting syntax to turn the date returned into a nice 2024-07-04 instead of an ugly long date via {{custom_objects.movie_ticket.custom_fields.date | date: '%Y-%m-%d'}}

Putting it all together

So, back to the demo.
Our customer has read the summary and information about Gladiator and now decides he wants tickets for the movie.

The agent goes into custom objects and registers a new set of tickets by logging the user, movie (both lookup fields) and all associated data.

They let the customer know they'll book the tickets, and once they add the record our object trigger will fire and send out a, separate, email to the customer with the contents of our object trigger email configured earlier.

Conclusion

The object trigger example used in this article might not be that realistic since most purchases will be handled by a proper sales platform. But for the sake of demonstration it serves its purpose on explaining how we can leverage object triggers to react to changes to the custom object records.

Since we can use the custom objects API to add records, you might imagine scenarios were we import or update records (like service contracts) based on external platforms, and Zendesk will then take care of the rest.

💡
One nice option that this also enables is the concept of a proactive ticket. By combining an internal webhook in Zendesk and the {{custom_object.movie_ticket.buyer.email}} placeholder, we can create a new ticket via API in the Zendesk instance. Useful for scenarios where we want to reach out for a contract renewal or other automated alert.

Wrap up

Custom Objects launched last year and opened up a world of new possibilities in Zendesk. Over the last year updates like these placeholders, but also better API search, bulk import and update of elements and better permission levels made the platform that more powerful.

If you want to get insights in what's possible with Custom Objects on top of the examples in this article, take a look at my original series via the link below:

Announcing the Custom Objects series for Zendesk
Introducing is a four-part series on Zendesk’s new Custom Objects feature. These articles cover setup, data import, using Custom Objects in forms and with agents, expanding user profiles, and displaying Custom Objects in Help Center forms.

The only big missing piece for me is any end-user access to Custom Objects. You can make objects available in the bot via API calls but making them available in forms on the Help Center still requires custom code for now. Although from what's been announced and shown at Zendesk Relate in April, end-user available lookup fields are coming this year.