Add a Tag to a New ticket if attachment is present

42 Commentaires

  • Kuldeep Patidar

    Hi @...,

    Thanks for confirming. I feel strongly about information and love learning more on this. If possible, can you please help me in building that markup to achieve my goal.

    Edit: I think we need to use “tickets/update_many” endpoint here.

    I'm afraid as I have minimum knowledge of markup, so not sure how the correct code/request should look like.

    I truly appreciate your valuable support!!

    Regards.

    Kuldeep

    0
  • Anita Rajkumar

    Awesome resolution Ash! :)

    0
  • sebastian

    Thanks Ashish and Terry!

    Did anyone yet check how to also trigger images pasted directly in the email text? The trigger in itself works fine but it seems images pasted into the text are not stored as attachments in the ticket JSON. Anyone checked out already how to catch those images as well?

    0
  • Dave Dyson
    Zendesk Community Manager
    I'm not sure there's a way to do that, but since it seems adding options to the creation of views might obviate the need for these solutions, and since the method of updating a ticket via a trigger and target is not supported and can be unreliable, and since HTTP targets are being deprecated soon in favor of Webhooks, I think it might be helpful to our product team if one of you could post your use case to our Feedback - Ticketing System (Support) topic, using our Product Feedback Post Template to format your feedback. Our product team watches that space, and the more we can learn about your needs, the better. Thanks!
     
    0
  • Dean Kongslie
    Community Moderator

    I have a question. I am using a webhook to set the subject of a ticket depending on various data in the form's fields. The subject does get updated using this trigger, but I want the subject to update before the email goes out on a newly created ticket. When I run the following webhook as the very first trigger on our instance (ahead of the notify requester of new proactive ticket) the email still goes out with the subject as it was when I submitted the ticket originally, not as is since being updated by this webhook.

    What am I doing wrong?

    The endpoint that this webhook is looking at is a PUT and domain/api/v2/tickets/{{ticket.id}}.json

    {"ticket":
    {"subject": "{% if ticket.ticket_field_360041372052 != null and ticket.ticket_field_360041372052 != '' and ticket.ticket_field_360044340271 != null and ticket.ticket_field_360044340271 != '' and ticket.ticket_field_360041327151 != null and ticket.ticket_field_360041327151 != '' %}TSG Reporting – Order Follow Up - {{ticket.ticket_field_360041372052}} - {{ticket.ticket_field_360044340271}} - {{ticket.ticket_field_360041327151}}{% elsif ticket.ticket_field_360041372052 != null and ticket.ticket_field_360041372052 != '' and ticket.ticket_field_360044340271 != null and ticket.ticket_field_360044340271 != '' and (ticket.ticket_field_360041327151 == null or ticket.ticket_field_360041327151 == '') %}TSG Reporting – Order Follow Up - {{ticket.ticket_field_360041372052}} - {{ticket.ticket_field_360044340271}}{% elsif ticket.ticket_field_360041372052 != null and ticket.ticket_field_360041372052 != '' and (ticket.ticket_field_360044340271 == null or ticket.ticket_field_360044340271 == '') and (ticket.ticket_field_360041327151 == null or ticket.ticket_field_360041327151 == '') %}TSG Reporting – Order Follow Up - {{ticket.ticket_field_360041372052}}{% elsif ticket.ticket_field_360041372052 != null and ticket.ticket_field_360041372052 != '' and (ticket.ticket_field_360044340271 == null or ticket.ticket_field_360044340271 == '') and ticket.ticket_field_360041327151 != null and ticket.ticket_field_360041327151 != '' %}TSG Reporting – Order Follow Up - {{ticket.ticket_field_360041372052}} - {{ticket.ticket_field_360041327151}}{% elsif (ticket.ticket_field_360041372052 == null or ticket.ticket_field_360041372052 == '') and (ticket.ticket_field_360044340271 == null or ticket.ticket_field_360044340271 == '') and ticket.ticket_field_360041327151 != null and ticket.ticket_field_360041327151 != '' %}TSG Reporting – Order Follow Up - {{ticket.ticket_field_360041327151}}{% elsif (ticket.ticket_field_360041372052 == null or ticket.ticket_field_360041372052 == '') and ticket.ticket_field_360044340271 != null and ticket.ticket_field_360044340271 != '' and ticket.ticket_field_360041327151 != null and ticket.ticket_field_360041327151 != '' %}TSG Reporting – Order Follow Up - {{ticket.ticket_field_360044340271}} - {{ticket.ticket_field_360041327151}}{% elsif (ticket.ticket_field_360041372052 == null or ticket.ticket_field_360041372052 == '') and ticket.ticket_field_360044340271 != null and ticket.ticket_field_360044340271 != '' and (ticket.ticket_field_360041327151 == null or ticket.ticket_field_360041327151 == '') %}TSG Reporting – Order Follow Up - {{ticket.ticket_field_360044340271}}{% endif %}"}
    }
    0
  • Eric Nelson
    Zendesk Developer Advocacy
    Hey Dean,

    Do you mind opening up a ticket so that our team can take a look at your account? When opening that ticket, if you could provide some examples where this is happening - it'd be apprecitated.

    Thanks so much!

     
    0
  • Fabio

    Hi ASHISH DIVAY,

    what does the first line do? 

    {% for comment in ticket.public_comments offset:0 limit:1 %}

    I'm curious if this 'offset' and 'limit' stuff only checks the latest comment? But I have no idea how it works. ;-) 

    I'm asking because let's say I want to see if there's a way to check if there is more than one attachment in the whole ticket conversation. I assume I would need to adjust the line mentioned above and also include some kind of counter instead of this '> 0 %' thing in line 2? 

    0
  • Tipene Hughes
    Zendesk Developer Advocacy

    Hi Fabio,

    ASHISH DIVAY might want to jump in here to offer more clarification but from my understanding of how this is written, you're correct that the offset:0 and limit:1 specifies that only the most recent ticket comment will be evaluated against. You can increase the limit to evaluate against more comments in the ticket.public_comments array. 

    The next line is evaluating the actual size of the attachment, not the attachment count on that ticket comment so for you to be able to check if there are multiple attachments, you will need to implement some type of counter to track how many attachments are present on the ticket, and apply the tag depending on that. 

    Here's a link to the docs which might be helpful to you:

    https://shopify.github.io/liquid/tags/control-flow/

    I hope this helps!

    Tipene

    0
  • Alon

    ASHISH DIVAY (or anyone else who is knowledgeable) - I could use some assistance with this.

     

    I set up my webhook and trigger according to all the comments. The trigger is firing as it should, but every ticket is getting tagged as if it has an attachment. Any idea why that may be? 

    0
  • Cheeny Aban
    Zendesk Customer Care
    Hi Alon, 

    I created a ticket on your behalf. Don't worry! one of our colleagues will get in touch with you regarding this issue.
    0
  • Tyler Comfort

    Terry Ehrhard ASHISH DIVAY

    This was woking fine for us, but it stopped and I've been unable to get it working again.  I'm using a target with a basic authenticion using token.  I know that the authentication is working fine b/c I've tested it without the liquid markup and it updates the ticket (I'm using the update many endpoint).

    Something is off with the code. I keep getting the unable to parse json error.  I've tried copying as a single line, multiline. Not sure if Zendesk changed something.  

     

    {"ticket":
    {% for comment in ticket.comments offset:0 limit:1 %}
    {% if comment.attachments.size > 0 %}
    {"additional_tags":["attachments_yes"]}
    {% else %}
    {"additional_tags":["attachments_no"]}
    {% endif %}
    }
    {% endfor %}

     

     

    0
  • Alon

    Hey Tyler Comfort,

    As per another suggestion here, changing ticket.comments to ticket.public_comments may work for you here. The second line would look like this:

    {% for comment in ticket.public_comments offset:0 limit:1 %}

    0

Vous devez vous connecter pour laisser un commentaire.

Réalisé par Zendesk