Skip to main content
WARNING You're browsing the documentation for an old version of Deskpro. Consider updating to Deskpro Horizon.

Variables in custom phrases

in Editing Templates
Authors list
Published: 23 Mar 2017|Last updated: 23 Mar 2017

You can’t use the standard variables that you would use in a template in a phrase. For example, if you include {{ ticket.agent.display_name }} in a custom phrase, it will not be replaced with the agent’s name, as it would be in a template.

You can access variable content from your custom phrases, but you don’t include the variable in the custom phrase directly.

Instead, you define a phrase variable that applies only within the custom phrase, then when you include the phrase in a template, you pass the value of the standard variable to the phrase variable.

For example, suppose you have created a custom phrase called custom.ticket.auto-notification-agentin which you want to reference the name of the currently assigned agent.

We’ve already said that you can’t include the usual {{ ticket.agent.display_name }} variable.

Instead, you’d include a phrase variable, like this:

<p>Your ticket has been assigned to {{agent-name}}.</p>
copy

{{agent-name}} is the phrase variable. The choice of the ‘agent-name’ part is arbitrary - we could have called it {{name}} or {{agent}} or {{var}} (but it’s better to pick a meaningful name in case you or someone else comes back to edit the phrase later). The important thing is that you use the same name when you’re referencing the phrase in your template, as we will see.

Note

Note

Unlike standard variables, the phrase variable should not have a space between the curly brackets and the name; {{agent-name}} will work, but {{ agent-name }} will not.

In your email template, instead of referencing the custom phrase the usual way, like this:

{{ phrase('user.emails.greeting') }}
copy

you would do this:

{{ phrase('custom.ticket.auto-notification-agent', { agent-name: ticket.agent.display_name }) }}
copy

When an email is sent using the template, this passes the current value of ticket.agent.display_nameto the {{agent-name}} variable within the custom phrase.

Custom phrase with multiple variables Copy link to Custom phrase with multiple variables to clipboard

Of course, a custom phrase may contain more than one phrase variable.

Say your custom phrase contains both {{agent-name}} and {{id}} as phrase variables. In your template, you would write:

{{ phrase('custom.ticket.auto-notification-agent', { agent-name: ticket.agent.display_name, id: ticket.id }) }}``
copy
HelpfulUnhelpful
next pageDate & time settings
previous pageUseful template variables

Please log in or register to submit a comment.