Update a ticket's subject line

27 Comments

  • Skip Moore

    It depends on the level of complexity you want. You can use a trigger to fire a HTTP target the calls the zendesk ticket api. In the trigger you set the JSON body to something like

    {"ticket": {
       "subject": "this is a test"
      }

    And based on the conditions in the trigger the ticket's subject will change to "this is a test"

     

     

    0
  • Kalpesh Shah

    Hi Skip,

    Thank you for your response. The functionality is not very complex. We would like to append the subject line with star/dollar signs when the customer support agent checks one of the custom check boxes within a ticket.

    I have never used a trigger to fire a HTTP target before and it looks like I don't have that option within "Perform These Actions". i would appreciate any guidance you can provide on this.

    Regards,
    Kalpesh

    0
  • Kalpesh Shah

    Hi Skip,

    I think I found what I was looking for. Thank you for your help.

    Regards,
    Kalpesh

    0
  • Skip Moore

    just one bit of warning the API will replace the whole subject line there isn't a way to append in the API so append a dollar sign to the subject line use this 

     

    {"ticket": {
       "subject": "$ {{ticket.subject}}"
      }

     

    The {{}} are liquid template placeholders and ticket.subject is what the placeholder is requesting 

    0
  • Tal Admon

    Hi Kalpesh,

    If you want to append a prefix to your ticket subject line, you can use the ticket.title placeholder in the trigger's json body:

    {"ticket":{"subject":"[info] - {{ticket.title}}"}}

    Note that it would make sense to add the condition "ticket is... created" to the trigger that calls the target, to get it done once on creation.

     

    0
  • Mart Hough

    Hi Tal / skip

    Would you mind taking a moment to help me implement your solution.

    I'm trying to use this post as a startingpoint;

    Adding a name field to your Help Center ticket form

    But I'm confused..

    I want to append my ticket title with data entered in custom field id 78319308

    Would this give me the following URL?

    https:// {{subdomain}} .zendesk.com/api/v2/users///{"ticket":{"subject":"[{{ticket.ticket_field_78319308}} ] - {{ticket.title}}"}}

    ?

    0
  • Jonathan Nathanson

    Hi all,

    Bit of a tip - the liquid template holder has been updated to perform this functionality. Instead of using {{ticket.subject}} as recommended above, you should use {{ticket.title}}.

    Here's a quick step-by-step to get this set up:

    Create a HTTP notification extension

    Zendesk has a really powerful Application Programming Interface (API) which allows you to do many things, such as updating tickets or downloading user data. This is achieved by sending a "request" to the API by browsing to a specific URL (known as an endpoint).

    We're going to set up an extension in Zendesk, which is programmed to send a request to update a ticket subject line. We'll then call this extension as an action in one of our triggers. This will have the effect of updating the ticket subject line every time our trigger runs.

    1. Click the settings icon

    2. Click "Extensions" under the Settings heading on the left hand sidebar

    3. Click "Add target"

    4. You'll see a number of options - we want HTTP target" - click this to proceed

    5. You'll now need to configure the target to send a JSON request to the API for your Zendesk instance. You'll need to use the following settings:

    Title: Give your target a title - I've gone for "Update subject line of the ticket"

    URL: You need to use the URL to the tickets endpoint of the Zendesk API for your instance. It will be as follows: https://yourzendesksubdomain.zendesk.com/api/v2/tickets/{{ticket.id}}.json.

    Note two things here - the first is you need to replace "yourzendesksubdomain" with your actual subdomain - to find this log in to Zendesk and check the URL in your browser. Secondly, we're using a liquid template placeholder to dynamically insert the ticket number of the ticket we're updating ({{ticket.id}}).

    Method: This is the HTTP request method - we're going to use "PUT" which is a kind of pseudonym for "update" in API jargon.

    Content type: We need to send a "request" which is essentially a coded command that tells the tickets API endpoint to update the subject line. You'll see more about this in a moment - for now we just need to specify the format in which we will code our command, which is JSON.

    Basic authentication: You'll need to supply a username and password for the API call (Zendesk don't want just anyone to be able to update your tickets!) - this will need to be an administrator account in your Zendesk instance. So tick the box and enter those details.

    6. Now we can test - leave the dropdown as "test target" and click Submit. 

    7. A box like the one above will appear asking us to enter the "JSON body" for our API request - this is the coded message we talked abotu earlier. So go ahead and add the following coded message:

    {"ticket": {
    "subject": "ACCESS REQUEST: {{ticket.title}}"
    }
    }

    You may wish to change the ACCESS REQUEST: text to something else - this is what I wanted to prefix my ticket subject line with. You'll notice I have used {{ticket.title}} liquid template holder so that the original subject line of the ticket is kept, and simply prefixed with my additional "ACCESS REQUEST: " text. 

    8. Click submit - if you configured the target correctly in the previous steps and used correct administrator credentials in the authentication section you should see a box like below with a message saying "200 OK" - this is the HTTP response header code meaning your request was successful:

    9. If everything is working for you, close this box, change the drop-down at the bottom of the settings page to "Create Target" and hit submit.

    OK - we've set up the HTTP target. Now we just need to call it in our trigger when we want it to run.

    Calling the HTTP target from your trigger

    10. Go to the trigger you would to use to update the ticket subject line. Once you've configured the conditions for the trigger to run, go to actions and add select "Notify target" from the list of options.

    11. In the second drop-down that appears, select the HTTP target we just created. If you've been following this guide exactly it should be called "Update subject line of the ticket".

    12. Copy and paste the request / "command" that we just tested in to the JSON body section and click save.

    Now your trigger is set up to update the subject line of your ticket whenever it's conditions are met and it fires. Awesome! Give it a test run to make sure everything is working.

    I hope this helps.

    Jonathan

     

     

    6
  • Jessie Schutz
    Zendesk team member

    Thanks for sharing this, Jonathan! If you'd like, it would be awesome if you'd post this in our Tips & Tricks topic!

    0
  • Lee KB

    Huge thank you to Jonathan for the explanation! I'd heard of using http target extensions before but never saw an explanation of how to do it. 

    Note that when you 'test' the extension Zendesk may actually update a random ticket—look in the Response tab and at the bottom you'll see the ticket number of the 'test' ticket Zendesk chose to be the lab rat. (Look for "id":___ for the ticket number.)

     



    1
  • Heather Rommel
    Community Moderator

    @Jonathan Nathanson- wow! This is the best step by step I've seen on doing these. Please DO put this in Tips n Tricks as Jessie mentioned.

    Thank you for the time you put into this!

    0
  • Richard Nuylan

    What does it mean when I'm getting a "HTTP/1.1 401 Unauthorized"? I'm currently using our admin account so it should be able to authenticate credentials right? -Richard

    0
  • Brett Bowser
    Zendesk Community Team

    Hey Tech,

    This error will populate if the incorrect credentials are being used. It may be worth generating an API token to see if that works out instead.

    In some cases, if SSO is set up on the account, the Zendesk password can be different than the passwords the user logs in with via their SSO option.

    I hope this points you in the right direction but please let me know if you continue to experience issues on your end.

    Thanks!

    1
  • Richard Nuylan

    Hi Brett!

    Thank you for looking into this. Unfortunately, I'm still getting an authentication error.

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

    I was trying to implement this tip Jonathan suggested. We wanted to include the ticket ID on the ticket subject like this: 

    {

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

    Regards,

    Richard

    0
  • Brett Bowser
    Zendesk Community Team

    Hey Tech,

    Can you try testing out the credentials you were previously using in our API Console which I've linked for you?

    I'm wondering if you can make a simple API call using your credentials here.

    Let me know!

    2
  • Richard Nuylan

    Hi Brett,

    I was able to do a simple GET ticket query. But whenever I'm trying to do a PUT request it always returns with a 404:

    {
      "error": "InvalidEndpoint",
      "description": "Not found"
    }
    1
  • Bryan - Community Manager
    Zendesk Developer Support

    Hi Richard Nuylan. The tip you referenced uses the Target feature in conjunction with a trigger.

    It looks like what you've described above may be using a different combination of tools or steps. Can you describe exactly where you are getting the above error returned?

    0
  • Richard Nuylan

    Hi Bryan! Yes it is a combination of both based from Jonathan's instructions. But I can't get past step number 8 while testing the target where I keep on getting "HTTP/1.1 401 Unauthorized". I'm using our administrator account and similar settings. Thank you!

    0
  • Bryan - Community Manager
    Zendesk Developer Support

    I see. When you're setting up the Extension/Target, you're selecting 'Test target' and it's then when the error is returned.

    All I can think of is that maybe your account doesn't have passwords enabled? Calling your Zendesk instance in Jonathan's example requires an agent or admin's email and password and that this setting is enabled (it's under Admin > Channels/API):

    If it is enabled, then please submit a ticket. This will be the quickest way to check the details of your account and any access issues, which can't be done here.

    1
  • Richard Nuylan

    Hi Bryan,

    I just checked and the password access settings is currently enabled. I will open a ticket as suggested. Thank you so much. 

    Regards,

    Richard

    0
  • Bryan - Community Manager
    Zendesk Developer Support

    Good luck Richard. If you don't mind, please share here anything that the wider community might benefit from once the solution is found. Thanks!

    0
  • Devan - Community Manager
    Zendesk Community Team

    On Wednesday, February 5, from 10:00am-12:00pm CST, we'll have a special guest team of experts on hand to answer your questions about Support: Triggers and Email Workflows in your Zendesk Support instance for an AMA-style conversation!

    Just click the "new post" button and write up your question. Be sure to be as detailed as possible. The best questions include: 

    • What it is you're trying to do
    • What you've tried so far 
    • Any other context or relevant information
    • Screenshots, if you have them

    Questions posted to this topic in advance of the start time will be answered first thing on the 5th, so if you've got something you want our experts to look at, post it today!

    0
  • Gerty

    Another option to update the subject line using triggers is to create a URL target, in order for the target to work you will need to also generate an API token (under Channels > API) specifically for the URL target.

    Go to Settings > Extensions > add target > URL Target

    Title: Update ticket subject

    URL: https://domain.zendesk.com/api/v2/tickets/{{ticket.id}}.json?ticket[subject]

    Method: PUT

    Attribute Name: ticket[subject]

    Basic Authentication (must be an admin in the tenant): emailaddressofadmin.com/token

    Password: API token generated

    Now, when you go to triggers, under the Notifications category, select Notify Target. The update ticket subject value will appear here. Click on that and a message drop down will appear. You can now modify any ticket subject with custom fields. 

    {{ticket.ticket_field_option_title_360027902511}} - {{ticket.ticket_field_option_title_360027985912}} - {{ticket.ticket_field_option_title_360028041031}} - Term Req

    Submit a test ticket for whatever trigger is to be affected. The subject should be updated as the trigger is applied.

    0
  • Brett Bowser
    Zendesk Community Team

    This is great! Thanks for sharing Gerty!

    0
  • Jason Stoltzfus

    Jonathan Nathanson I know it's been 2 years since you posted this, but this was EXACTLY what my Organization was looking for.

    Thanks for the tip!

    1
  • Ian O'Connor

    Is it possible to use this to method to replace the title with information parsed from Comment Text? My goal is to use the above trigger to replace the subject text of a ticket with a specific string from the Comment Text. 

    Edit: Actually, in thinking about this, I could just run x number of instances of this, where x is the amount of options offered and each option only fires on the instances where the specified string is present.

    0
  • Oliver Tietze

    Ian O'Connor it can be done within 1 instance of HTTP target

    To parse your comment text, you can make use of a series of liquid string and array modifiers

    One example:

    Given a comment of
    "Bla bla anything Reference: 123something bla bla everything" (line breaks may be included)

    using a target to replace the subject with this value
    "Your inquiry with reference {{ ticket.description | split: 'Reference no: ' | last | slice: 0,8 %}}"

    ... will find "Reference no:" in the text and then extract exactly 8 characters that follow this stringthe last occurance of that trigger string;
    Your inquiry with reference 123somet

    2 important notes: Youre putting the above liquid in the JSON fied of the target, so I recommend using split: '...' instead of split: "..." 

    And if there is more than one occurence of "Reference no: " in the comment, the LAST one will be processed (hence 'last' is used to trim down the comment to the last thing that is found behind "Reference no: ")

    For the subject, of course you could combine more than one of these expressions and will it with static text, and of course add the original subject, too (so it doesn't get lost)

    You could also update relevant tickets fields (not only the subject) using this method.

     

    It looks complicated. Once you pay extra attention to every quote and object identifier, it will work pretty well and fancy.

    Oliver

    1
  • Ian O'Connor

    Oliver Tietze That is brilliant. Thank you so much. I truly appreciate your time and help!

    0

Please sign in to leave a comment.

Powered by Zendesk