Recent searches


No recent searches

Support Tip: How to change the ticket Subject using a trigger



Posted Oct 14, 2019

Note: comments added before August 2022 referred to the previous version of this article, when this could be achieved using targets/extensions (which were replaced with webhooks).

The "Email user" action allows us to set the subject/title of the email notification to the requester. The ticket Subject doesn't change, however.

Although there isn't a straightforward trigger action to modify the ticket Subject, we do have a way to achieve this with a Notify active webhook action.

Here's how to do it:

1. Create a webhook to update tickets

Go to Admin Center » Apps and Integrations » Webhooks and create a new webhook (under Actions, on the top-right corner).

Complete the required webhook fields:

  • Name. The name of your webhook (e.g. "Update Ticket")
  • Endpoint URL: https://yoursubdomain.zendesk.com/api/v2/tickets/{{ticket.id}}.json (make sure to replace 'yoursubdomain' with your own subdomain)
  • Request method: PUT
  • Request format: JSON
  • Complete the Authentication method (use an administrator's credentials)

2. Add webhook action to your trigger

Edit the trigger you want to modify the ticket Subject.

Under Actions, add a Notify active webhook action.

Input the following in the JSON body part of the trigger action:

{"ticket": {"subject": "Your new subject is here!"}}

Example:

That's it! Now you have a trigger action that updates the Ticket Subject.


0

50

50 comments

In regards to getting this to work, what if we only have "Token Access" enabled for our API access?  Is it possible to pass in the token as part of the authentication, or do we need to enable "Password Access" for the API?

Thanks!

0


Actually, I just answered my own question and got this to work following the basic format of authentication using the token.

username = userEmailAddress/token

password = tokenValue

I was able to successfully get this working.  Hope the above helps anyone else trying this.

0


I have provided my admin credential but receiving following error while submitting Test Target in HTTP Target configuration :

{"error":"Couldn't authenticate you"}




0


Hi @..., have you tried changing your password, and try again? Does it also fail if you use another admin's credentials? If the problem persists I'd suggest opening a support ticket with Zendesk.

0


@...

If you have access to the API section in your admin dashboard I would give that a try. 

You can then use a UN of an admin followed by "/token" for the Username and the API token as the Password.

It would look something like, "azhar@example.com/token" "verylongapitokenforpassword"

0


image avatar

Nicole Saunders

Zendesk Community Manager

@... - One of our agents took a look and will be responding to you shortly. However, we removed your screenshots as some of the information was a little risky to post in a public forum and we wanted to protect your account security. 

0


Sorry I didn't  update that Authentication issue gone after re-login. Currently looking solution for something else i.e. I was able to update the ticket subject using trigger and API call but using the same configuration, I was not able to update custom field.

Wanted to know how to update a custom field using same API call and trigger.

 

Expression used in JSON body of the trigger :

{"ticket": {"subject": "Subject changed for Mr. {{ticket.requester.first_name}}"}} --> It was successful

{"ticket": {"subject": "{{ticket.ticket_field_360042501834}}"}} --> It was successful

{"ticket": {"subject": "{{ticket.ticket_field_option_title_360042588434}}"}} --> It was successful

{"ticket": {"customField:custom_field_360042588434": "Chat"}} --> It was UNSUCCESSFUL

{"ticket": {"ticket_field_option_title_360042588434": "Press"}} -> It was UNSUCCESSFUL

0


image avatar

Sergey

Zendesk Customer Care

Hi Azhar,

You can update ticket fields using the following syntax (https://developer.zendesk.com/rest_api/docs/support/tickets#setting-custom-field-values) -

{"ticket": {"custom_fields": [{ "id": ticket_field_id_here, "value": "some_value" }]}}

Hope this helps. Our API documentation can answer most of your API related questions, so give that a go.

0


Thanks Sergei. It worked.. :)

0


Hi Sergie,

What I noticed recently is that whenever I am trying to set custom ticket field with the above mentioned JSON expression,  it is updating fine for a single word value but not working for multiple word value.

Could you please help on this?

E.g. :

{"ticket": {"custom_fields": [{ "id": 360042537054, "value": "Careers" }]}}  --> Working Fine

{"ticket": {"custom_fields": [{ "id": 360042537054, "value": "Product Feedback or Questions" }]}}  --> Not working fine

0


Hi, everyone!

Here I share the way I came up with the solution to, for example, remove all single quotes (') from ticket title using Liquid:

{% assign ticketTitle = ticket.title | remove:"'" %}
{
"ticket": {
"subject": "{{ ticketTitle }}"
}
}

I hope it can help someone with same need I had.

Best wishes,

Renato

1


This is a not a great work around IMHO, but thanks for suggesting it.  When will we get a real trigger to modify the subject of existing tickets at Update or at Create time? 

  1. There risk is Admin Bob set this up using his account, and every time his password expires , this will *break*.  
  2. If a service account is used for this work around, you must pay for that license to fill this feature gap (OUCH!) 
  3. If the Trigger leveraging the Extension/Target is configured incorrectly any updates from an agent that use the trigger will come from the account tied to the credentials used for the extension/target.  

 

1


@...

I totally understand what you are saying. 

That being said, I believe that your first point can be remedied by using a token instead of a password. 

Here is a link to the documentation on that. https://developer.zendesk.com/rest_api/docs/support/introduction#api-token

This would also mean that you "could" avoid getting a service account in this case.

Again I totally understand what you are saying but I wanted to let you know that there were some workarounds to the workaround. ;)

0


I need some help with this one. we can't seem to be able to get the extension to actually go through. has there been a change to this by chance?

0


image avatar

Brett Bowser

Zendesk Community Manager

Hey Juan,

Any chance you could provide a screenshot of the target/extension you've set up so we can take a look? Feel free to omit your subdomain or any other information :)

Let me know!

0


Hello Brett

I'm interested by your method,

I would like to set a custom field instead of the subject

If it's possible, what should i wirte instead of subject in then JSON expression :

{"ticket": {"subject": "Your text goes here"}}

Thanks !

0


image avatar

Sergey

Zendesk Customer Care

Hu Bruno,

Wanted to share this handy article, that will demonstrate what you are after: https://develop.zendesk.com/hc/en-us/articles/360059146153#setting-custom-field-values

You can use this syntax, in particular:

{
"ticket": {
"subject": "Hello",
"comment": { "body": "Some question" },
"custom_fields": [{ "id": 34, "value": "I need help!" }]
}
}

Note, that if you will not pass Subject attribute/value combination at the time of creating a ticket, system will take some text from your Comment attribute and use that as a subject.

0


image avatar

Lou

The Product Manager Whisperer - 2022Community Moderator

Great tip. I actually used it to append to the ticket subject. This allows us to add a customer ticket # to the subject from a ticket field automatically to stop email loops.

If anyone is interested, here's the JSON:

{"ticket": {"subject": "{{ticket.title}} [{{ticket.ticket_field_360042479912}}]"}}

0


image avatar

Devan La Spisa

Zendesk Community Manager

Hello @...,

Glad this tip helped you out! Also, thanks for sharing with the community your tip on our tip! :D

Best regards.

0


It would be great if we could just use triggers or automation to append or set the ticket subject. I can do this with a Macro but it would save tons of time if it could be done automatically (without having to use JSON)!  

5


image avatar

Lou

The Product Manager Whisperer - 2022Community Moderator

Mary Gleich-Matthews

The JSON is really simple for this one. Here it is for just setting a subject with no "special" edits:

{"ticket": {"subject": "YOUR SUBJECT HERE"}}

0


I agree, I would love to be able to update the subject (and the native due date field) with a trigger!

0


Hi All,

i am trying to create a webhook with end point url as https://yoursubdomain.zendesk.com/api/v2/tickets/{{ticket.id}}.json (i replaed your domain with our Zendesk domain) however it returns with an error

If someone can help please!

0


image avatar

Lou

The Product Manager Whisperer - 2022Community Moderator

Prakash Sati

The URL looks good. Where are you seeing this error?

0


I have this in the JSON body of my trigger: {"ticket": {"subject": "Subject changed by {{ticket.requester.first_name}}"}}

The subject is still not updating when a customer changes the subject on the email. Please advise.

0


image avatar

Lou

The Product Manager Whisperer - 2022Community Moderator

Sharon Franco

What does the event for that say? Is the trigger firing? If not, we'll need to look at the conditions.

0


Hi Lou thanks for your help with this. The trigger was fired, the Events displays "Message pushed to webhook trigger -trigger name-"

The Condition is "Status is not New" and the Action is as follows:

0


image avatar

Lou

The Product Manager Whisperer - 2022Community Moderator

Sharon Franco

I'm sorry I missed this. I'm curious. What are the conditions of the trigger? I can't think of a way to have a condition where the requester changed the subject, so not sure if you can accomplish your goal.

0


What am I doing wrong here? Any insight? I just want to add "Action Required" to the subject line for certain situations. I set up the conditions to only apply to specific tags associated with individual macros and in order to only have it run once per ticket I have it adding that "added_action_required" tag which stops the trigger from running multiple times.

The json should be correct. Did something change with webhooks? I also had it set up to change the subject if customers wrote in from a specific web form on our help center (basically change the subject line to "New submission on {{web form name}}" and that also doesn't seem to be working anymore.

0


image avatar

Pedro Rodrigues

Community Moderator

Hi Kevin Froleiks, all is looking good indeed. Can you please double-check under your Admin Center, in Apps and Integrations » Webhooks » then click your webhook and check the status? Could be some issue with authentication, for example.

1


Please sign in to leave a comment.

Didn't find what you're looking for?

New post