Question

How can I capture a keyword in the body of a reply to a ticket?

  • 20 December 2022
  • 4 replies
  • 151 views

Userlevel 1
Badge +1

I’m trying to scan a response to a ticket for the keyword “proceed”. Is there something wrong with the expression I’m using? It works when I use a test case. 

 

What I have built is: 

  1. When a change is detected
  2. Web Request: Fetch ticket conversations from https://***.freshservice.com/api/v2/tickets/{{ticket.id_numeric}}/conversations
  3. JSON Parser: parse response body to get “body” field
  4. Expression Builder: 
    regexMatch('{{P3.root.conversations.conversations_object.incoming}}', 'true') && regexMatch('{{P3.root.conversations.conversations_object.body_text}}', '(?i)proceed')

However when this runs, it fails to detect the word “proceed”

Logs show the keyword in the response body:

 

 


4 replies

Userlevel 2
Badge +3

Do you have screen shots of your JSON parser and expression/condition nodes?

As far as I know, the “Expression has failed” messages mean the expression itself failed due to some kind of error, not that it ran successfully and returned false.  If you review the execution logs, it should give some detail in there (here’s an example of a condition node of ours with true, false, and failure results)
 

 

We use a workflow rule to close resolved tickets if the requester includes #close in their reply.

We trigger the rule when the requester replies or adds a note, then check the ticket.latest_public_comment field.  This way we don’t accidentally trigger if we find an older message in the conversation that has the keyword - we only want to check the latest reply (I assume that can be done via API too though).

I wasn’t finding good documentation for the regex system FS uses, so I just converted to lower case and used indexOf instead.  Not sure if something like that would work for your use case or not!

 

Userlevel 6
Badge +11

Hi @thusep8652 

Not sure if you’ve solved your issue or not but here’s what worked for me - very similar to Mike’s solution above.

I’m trying to scan a response to a ticket for the keyword “proceed”. Is there something wrong with the expression I’m using? It works when I use a test case. 

https://community.freshworks.com/freshservice-11247/liquid-filter-to-extract-information-from-an-email-body-into-fields-27914

My only suggested edit to @mike.b  would be to set the Expected Output = Number and to remove the >-1 because that’s going to need an IF stmt to make use of it.

 

indexOf(toLowerCae('{{ticket.latest_public_comment}}'),'proceed',0)

 

This will return the position of “proceed” in the field  -  if there are none it will return -1 as the result.

However, it won’t be able to differentiate “Proceed” from “Do not proceed”

Using a hash to identify an action word like Mike B is suggesting will help keep the WF from running inappropriately - especially if the action email is coming from internal or someone you can work with to mod the contents.

 

HTH

Bryn @ CYDEF.ca

 

Userlevel 2
Badge +3

My only suggested edit to @mike.b  would be to set the Expected Output = Number and to remove the >-1 because that’s going to need an IF stmt to make use of it.

 

Since the expression is part of a condition node it’s expecting a boolean output, so that’s why the `> -1` part.

Even though it says it’s expecting a string in the screenshot… I think that’s just a Freshservice quirk, it won’t actually let you change it for a condition node.

 

But yeah, if you were in a normal expression node, then the setup as pictured wouldn’t work!

Userlevel 6
Badge +11

Yeah I noticed that restriction too when using an expression in the WF condition node. 

It took me a moment to realize you don’t need to build an [IF] stmt in Boolean mode bc that setting is just attempting to assess the whatever statement you’ve entered as either T or F.

Reply