Solved

Remove tags with Automation

  • 23 September 2021
  • 8 replies
  • 275 views

I have an automation that adds an ‘inbox’ tag to all messages and notes where I am the owner of the ticket or when a ticket is assigned to me. I would like to add another automation to remove that tag when I respond or add a note to the ticket. 

I am doing this to simulate an email inbox since the only activity view (that I know of) is the dropdown at the top of the screen that is incomplete and not very user friendly. 

icon

Best answer by hemanth.ramya 24 September 2021, 14:18

View original

8 replies

Userlevel 5
Badge +8

Hello @jscott2021!,

 

At the moment, we do not have a predefined action in automation to remove the tags in tickets. However, we can make use of Freshdesk API, Update a Ticket and trigger a webhook using Ticket updates automation to remove all the tags associated with the ticket. A sample automation rule for your requirements is shared below, hope this helps! 

 

 

Cheers,

Freshworks Community Team

Badge +2

This code seems to be working for me to remove a specific tag:

 

{
"tags":[{% assign oldTagList = ticket.tags | split: ", " %}{% for thisTag in oldTagList %}{% unless thisTag == "TAG_TO_REMOVE" %}"{{thisTag}}"{% if forloop.last == false %},{% endif %}{% endunless %}{% endfor %}]
}

 

 

Userlevel 1
Badge +1

This code seems to be working for me to remove a specific tag:

 

{
"tags":[{% assign oldTagList = ticket.tags | split: ", " %}{% for thisTag in oldTagList %}{% unless thisTag == "TAG_TO_REMOVE" %}"{{thisTag}}"{% if forloop.last == false %},{% endif %}{% endunless %}{% endfor %}]
}

 

I faced two problems with this code:

  1. If i have more than one TAG and the TAG I’m looking for is the last one, it doesnt work
  2. I receive following email again and again:

 

BTW What a cool idea and solution (y). hope you can help me to solve my problems :)

Badge +2

All I can think would be to check for extraneous whitespace.

Can you post your code?

https://webhook.site/ is helpful for troubleshooting to see exactly what is being sent to the webhook. 

Userlevel 1
Badge +1

All I can think would be to check for extraneous whitespace.

Can you post your code?

https://webhook.site/ is helpful for troubleshooting to see exactly what is being sent to the webhook. 

it’s your code from July 20th:

{
"tags":[{% assign oldTagList = ticket.tags | split: ", " %}{% for thisTag in oldTagList %}{% unless thisTag == "Waiting" %}"{{thisTag}}"{% if forloop.last == false %},{% endif %}{% endunless %}{% endfor %}]
}

i only adapted the “TAG_TO_REMOVE”

Userlevel 1
Badge +1

{
"tags":[{% assign oldTagList = ticket.tags | split: ", " %}
    {% for thisTag in oldTagList %}
        {% if forloop.last == false and forloop.first == false %},
        {% endif %}
        {% unless thisTag == "Waiting" %}"{{thisTag}}"
        {% endunless %}
    {% endfor %}]
}

 

i moved the forloop last to the top and included the forloop.first. due this webhook only runs if the tag is there this works for me :)

This is exactly what I’m looking for as well, but unfortunately I keep getting the failure emails showing ‘Request body has invalid json format’. Any ideas? I’ve tried both options in this thread (full text below).

{
"tags":[{% assign oldTagList = ticket.tags | split: ", " %}
    {% for thisTag in oldTagList %}
        {% if forloop.last == false and forloop.first == false %},
        {% endif %}
        {% unless thisTag == "action" %}"{{thisTag}}"
        {% endunless %}
    {% endfor %}]
}

 

I’ve also tried this and get the same error

{
"tags":[{% assign oldTagList = ticket.tags | split: ", " %}{% for thisTag in oldTagList %}{% unless thisTag == "action" %}"{{thisTag}}"{% if forloop.last == false %},{% endif %}{% endunless %}{% endfor %}]
}

 

 

Userlevel 1
Badge +1

there was still a bug in my code so this is the final version which works doesnt matter on which position the tag in the list is:

{
"tags":[
    {% assign TagToDelete = "TAG_TO_REMOVE" %}
    {% assign oldTagList = ticket.tags | split: ", " %}
    {% assign TagCounter = 1 %}
    {% for thisTag in oldTagList %}
        {% unless thisTag == TagToDelete %}
            "{{thisTag}}"
        {% endunless %}
        {% assign TagCounter = TagCounter | plus: 1 %}
        {% if forloop.last == false and thisTag != TagToDelete %}
            {% unless forloop.length == TagCounter and oldTagList.last == TagToDelete %}
                ,
            {% endunless %}
        {% endif %}
    {% endfor %}]
}

 

last and only problem is that i receive those emails:

 

Reply