If description contains certain words

Hi,
Would it be possible to get MSP to look for a list of know words in the body of an email and to allocate it to a specific queue?

For example, if the email contains softphone, it routes it to a UC queue, if it includes switch then networks for example?

Thanks

Gavin

Sure, you could use RegEx to match email.body if it finds that word, take action appropriately.

Personally, I like to do this in 2 steps. First, I attempt to extract the word/words. Then, I check to see if that extraction is empty. This lets me setup a faux-boolean I can act on.

For example, here I’m looking at the body and extracting the email and organization. While I put it in a global variable, you could use custom if in the same rule. For me, I’m extracting words after a pattern, whereas you would just be extracting the word “softphone” itself. Go crazy and look for multiple patterns such as ‘softphone’ ‘soft phone’ ‘mobile phone’ whatever.

Next, I look at that extraction I just made, and by checking if global.AlertDetails.email != null I know whether or not I actually found something.

I “fake” the boolean by storing a string value of TRUE, but I could put any value there as all i care about is is it empty or not, later on.

With those two steps, completed, I can now check global.HaveEmail != null anytime I needed to know if I had email… In your case, you would check global.IsSoftPhone != null or something similar.

You either put this at the top of your entire ‘create ticket’ workflow which creates the ticket and assigns the queue, or more appropriately, you would decouple the ticket creation from the queue assignment. The decoupling also works as just a secondary step to change whatever queue you assigned in the ticket creation.

First, you make the ticket. Then your next step is to Update the Ticket. Check to make sure you have a ticket and it’s a softphone with this rule in the *Only Perform this action if condition * custom.Ticket.id != null && global.IsSoftPhone != null in that step, you retrieve the ticket from the last step and set the queue equal to the UC queue.

Hi Duncan,

Thank you for the detailed response.

Using your method, would it be possible to match on a bunch of specific words like softphone, SIP, Voice, Mitel and 8x8 for example and pick a specific queue?

Thanks

Gavin

Sure. You would build a regex which would look for one of more words. In my example, I was looking for 2 distinct things, the email and organization. I used that intermediate step of checking if something was empty and assigning a new variable. You don’t need to do that and can just validate whether its empty or not. Since I had 2 different things being returned, I could have 0, 1, or 2. Rather than having to check the position in the returned array, I just used the intermediate step to make things cleaner for me to remember what was what. I do it on single returns as well, just because I like to be consistent in my code.

So for you, you could go with something like /\b(?<telecom>softphone|SIP|Voice|Mitel|8x8)\b/gmi. In plain english this is saying "Go see if you can find any of these entire words anywhere in this message. I want it to be case insensitive. If you find a match, store it in the capture group “telecom”

In the end, you’ll either have something captured or nothing captured.

Here’s a example text (regex101.com) and you’ll see what matches and what doesn’t, showing you how only whole words match and that case insensitive works too.

Checking if custom.AlertDetails.telecom != null means you found at least one match.

Adding the extra step of rendering that as a variable with that faux TRUE, you could instead have custom.IsTelecom !=null, if that makes sense. Guess I could have just called the capture group “IsTelecom” in your case and it would have done the same thing. :slight_smile: Don’t mean to over complicate it. I was pulling my example out of a multiple step process for me, and yours is straight forward.

If Travis has input on a better way, would love to hear it. I don’t see alot of cross-customer chatter on here, so just trying to help out.

Thank you for the detailed response.

I am guessing I can just keep adding to those words as I want to fine tune them further? Also, when entering the regex into MSP, it doesnt like the gmi part, is there a way to look for words in any case?

Regards

Gavin

Yes, you can keep building that out with as many phrases/keywords as you want, which is what makes this approach so flexible.

the /i does the search as case-insensitive, which is why in my screenshot you see “voice” matching, even though “Voice” is in the pattern.

the /m tells it to look across multiple lines.

the /g is normally used for global to tell it search for all occurrences, not just the first one… in your case, you can actually just skip that because you only need 1 to hit and you don’t care which one. In MSPInt, I believe the checkbox for “Return all matches” is what turns on that /g flag and could be why it doesn’t like it when you add it manually.

So your rule would look like this (validated the regex syntax was accepted without the ‘g’):