Teneo Developers Community

Count how often input hits safety net

I’m counting the number of times an input hits the safety net. How can I query the final value in TQL?

Hi Amber. This is a very good question. In TQL you cannot directly query the final value of a variable. Only particular instances. But there is a way to set it up. Just define a second global variable and assign the value of the counter in a script at End Dialog.

So if your counter is safetyNetCounter:

  1. Define a second variable finalSafetyNetCounter
  2. At global scripts - end dialog, have this script: finalSafetyNetCounter = safetyNetCounter.
  3. Publish your solution
  4. In TQL you can run a report, e.g. show all session along with final counter: listAll s.id, s.sv:n:safetyNetFinalCounter

I hope this helps! There are of course some queries you can do on safetyNetCounter directly. And there is a more involved way to solve this using a groovy adorner. Please let me know if you need more help.

Kind regards,

Hi Fred,

thanks for your answer! How can I do queries the safetyNetCounter directly?



Here is one query you can try with your counter as is:

Show all sessions exceding a threshold of 3 hits:

la s.id: t.e.sv:n:safetyNetCounter > 3

But keep in mind that some other queries will not work as you might expect:

These actually list all sessions, because every session has an instance of the counter at 0 or <3, etc.:

listAll s.id: t.e.sv:n:safetyNetCounter == 0
listAll s.id: t.e.sv:n:safetyNetCounter < 3

So really the only thing you can check for this way is exceeding some threshold. That could be useful if you want to find sessions that went badly, to find ways to improve your system.