Extract flows triggered, raised, dropped from processing path at runtime

At the end of each transaction during a Teneo session we would like to extract some general information about what happened during the session: which trigger became active, which flows and sub flows were raised and dropped, etc. More or less the information you see in try out in the icons under the user input:


We also would like to log the Teneo and solution version as shown in the publish view.

We will use TQL of course, but this requirement is for an additional logging platform. So during the session we want to save this information, and at session end we would log it via an external api.

  1. How can we use groovy to extract trigger/flow path from the processing path?
  2. Which API call returns the solution/teneo version? (could not find one in the api description).

Thanks in advance for any suggestions!

Hi Fred!

As for the first question, I believe the best option is to to this in an End Dialog groovy script, where you use the dialog history to pick out the information you need.
Here’s a groovy snippet which picks out a few fields, but you will need to change the structure to suit the requirements for where you’re sending the information.

def log = []

_.dialogHistory.each { t ->
  def transaction = []
  t.path.each { e ->
    // The type of events that you're interested in, these mirror the names of pathType in Inquire, but in camel case
    if(e.type in ['raiseFlow', 'flowTrigger', 'dropFlow']) {
      def event = [:]
      event['type'] = e.type
      event['flowName'] = e.flowName
      event['flowFolder'] = e.flowFolder
      event['flowId'] = e.flowId
      // Use the elvis operator to get a default value in the event object
      event['subFlow'] = e.subFlow ?: false
def json = new groovy.json.JsonBuilder(log).toString()
// Instead of println you would here send the json to the logging service
println json

As for your second question, the bot has a /status endpoint which with the verbose flag can provide you with this information.
So you can reach it with https://bot-server.example/bot-name/status?verbose and it should give you Version and Current-Solution-Revision .


This looks fantastic! Thanks, Eric.

One question, though. Can we also do this in what we know will be the last transaction?
At the End Dialog location we no longer have access to the calling service. So we would intend to return the information via an output parameter.

Worked out this snippet of groovy code to retrieve the version - any groovy gurus reading this, please feel free to suggest improvements:

// Retrieve Teneo version from status URL
// Result will have format, e.g.: Teneo=6.1.0;Solution-Revision=2342

def sVersion = “”
def sRevision = “”

def url = sTeneoStatusUrl.toURL()

url.eachLine {
if (it.contains(“Version”)) { sVersion = it }
if (it.contains(“Current-Solution-Revision”)) { sRevision = it }

sVersionRevision = sVersion.replace(“Version”,“Teneo”)+";"+sRevision.replace(“Current-”,"")

1 Like

Great, thanks for sharing, Fred! :grinning: (@Fred.Roberts )

1 Like