change ticket category when message body contains some keywords

Hello

Is it possible to change automatically category for the ticket, when it contains some particular keywords in body? 

Routine should be: when category changes to fex. Aspa - it will trigger script, to find out wether message containes word fex. Superoffice. If exists, it automatically changes category to something else fex. Programm.

Thanks for help

RE: change ticket category when message body contains some keywords

Hi Ingar,

Sure, it's possible.

Create a script that triggers on "Request changed category" for example. (Alternatively you can use the Requests changed system script, whatever floats your boat - but I would recommend using the trigger)

Then start off by checking the new category to see if it's in a category where you want to execute the script.

Then you have to go through one or more messages belonging to the ticket and parse them, looking for a text string (e.g. "SuperOffice").

If you find an occurence of the word you change the category to some other category.

Av: Hans Wilhelmsen 10. apr 2018

RE: change ticket category when message body contains some keywords

Thanks Hans

This is already great news, that it is possible. I start to figure out a prefect script now :). Maybe you have some raw sceleton of this kind of script to help me a bit?

Thanks

Av: Ingar Mölder 10. apr 2018

RE: change ticket category when message body contains some keywords

Hi Ingar,

do you only want the program to check the last message, or all messages on the ticket?

Should it check every time a ticket changes a category, and for all categories? 

How do you want to maintain the words-to-category relation (i.e, how are we supposed to know which word will trigger which category)? Extrafield on the category table, perhaps?

What if a word contains words pointing to different categories? Are you going to use a ranking system?

There's a lot to this that you probably need to consider before starting to develope.

 

If you need help, we can always give you a little nudge, but it would be nice to know in which direction you intend to go.

 

// Simen

 

Request changed category

Av: Simen Mostuen Iversen 11. apr 2018

RE: change ticket category when message body contains some keywords

Hi Simen and thanks for your help.

I made a little drawing of what i am looking for, but i can change my thinking about automatically trigger a script, if it is too hard to do. As you can see from my drawing, from 1 to 4 it is pretty basic stuff. Tickets comes to predifined category Mauri, where other service users does not have access.

Then a Robot starts its doings (5 in pic). It will check from excel file, where there is sales responsible for the company and if exists, it will forward this ticket to him/her and closes the ticket. At the same time it changes category Mauri/Handled where service users also has access for further possible usage. (5a in pic)

If Robot does not find a match from excel file, it will change a category to Aspa (visible for service users), leaves owner to unassigned. 

At this stage, if it is possible to trigger a word match script. If match will be found, then change category, if not, leave ticket as it is.

If triggering will be hard, would be nice to have fex a button or something, which searches throuhgt unassigned tickets in certain category and do the same thing.

What comes to words, it should find, there is quite big list of particular words, separated with comma or semicolon. I loved your idea about extra field in category table. It will be user frendly to add more words.

About rankings: there is basically only one category, we would like to transfer some tickets, containing a particular word / words, so at least in the beginning all words should be equaly important. Whatever word it will find from the list, then it does the transfer.

If you can help me to start this would be nice. Thanks.

 

Service processes with automated category change

Av: Ingar Mölder 11. apr 2018

RE: change ticket category when message body contains some keywords

I completely agree here. Get the contents of the excel file into an extra table. Makes it easier and faster to search through/match and to maintain.

I'll see if I can write some pseudo code for it if I get the time, but just to get one thing clear:

This should happen when a new ticket is created, right? Is that the only time it will happen? If it is, then the task could be assigned to an e-mail filter instead.

Av: Hans Wilhelmsen 11. apr 2018

RE: change ticket category when message body contains some keywords

Get the variables for ticket and message id
String messageId = getVariable("messageId");
String ticketId = getVariable("ticketId");


Create a searchengine that fetches the ej_message.html_body for the messageId and put the contents into a string. Then perhaps call htmlConvToText() on that string to remove all HTML.

Fetch all words from your list/excel file/extra table and put them into a string array.

Loop through the words to search for and see if they are present in the message. (Using find() for example). (Could be better ways to do this).

At this point you want to make a decision if you want to continue searching or do some action if you found it - in which case you will always do something on the word that appears first in the array.

Forward a mail based on the word you found. (If the words you find should be associated with an e-mail address you might want to populate them into a map instead of an array, which also makes this process easier).

Load the ticket and change the category and status, then save it.

Av: Hans Wilhelmsen 11. apr 2018

RE: change ticket category when message body contains some keywords

Thanks Hans for help.

You were asking: This should happen when a new ticket is created, right? Is that the only time it will happen? If it is, then the task could be assigned to an e-mail filter instead

This is a problem, because we have so called MauriRobot, who handles tickets after they come to service, so word cleaning will be done after its handling a tickets. In my scetch, where i Wrote "Trigger Word Search" is the place, where Robot decides, that this ticket does not belong to sales representative but to customer service instead, then it changes category. So i thought, that trigger will do the word search towards ticket in question every time, when criterions are true, which are Category = Aspa, owner = unassigned. So whenever robot changes category to aspa, script checkes, whether there is no assignment and does the job.

Hope i explaned it properly. Thanks for a raught boundaries. I am not very good at scripting, but hopefully i get some result :).

Thanks for help.

Av: Ingar Mölder 11. apr 2018

RE: change ticket category when message body contains some keywords

Hi

How the script should look like, if insted of triggereing "word search" by doing something, it will use mail filter. Key words could be also hard coded in script. There is approximately 20 different words to compare.

So basically when e-mail comes in, it will check  content of the mail and if criterions match, category and owner will be changed.

Thanks

Av: Ingar Mölder 20. apr 2018