Many of your scripts will depend on internal Teneo data. You may for example want to use the user's input in a script, or find out what the name is of the flow that is currently processed or you need to manipulate and answer text using a script. For that you can use the Engine scripting API. This API gives you access to detail provided in the requests as well as the current state of the dialog.
The two classes that you will use mostly in your scripts are:
The Engine scripting API Reference provides details on all classes and methods as well as the scopes in which they can be used. Below you will find some examples of Engine scripting API calls that are commonly used in Teneo solutions.
engineEnvironment.getParameter('userTimeZone')
Usually called in the either global Begin dialog or the global Pre-pocessing script. A more detailed guide can be found here: How to store input parameters.
_.setSessVarLifespan('coffeeTypeInFocus',2)
_.getUserInputText()
or, slightly shorter:
_.userInputText
_.getOutputText()
_.getOutputURL()
if (channel == 'slack' && _.getOutputURL()) {
_.setOutputText(_.getOutputText() + '\nMore details: ' + _.getOutputURL())
}
Note: outputs can only be manipulated in the global Post-processing script.
if (something == true) {
_.outputParameters.clear()
}
Note: outputs can only be manipulated in the global Post-processing script.
_.putOutputParameter('openMic', 'true')
Note: the value of outputs parameters should always be Strings. Outputs can only be manipulated in the global Post-processing script.
_.getDialogHistoryLength()
You would typically add this script to the On-drop script of the flow that should clear the stack.
if( _.activeFlows.size()>1) {
for ( item in _.activeFlows[0..-2]){
for (flow in item) {
flow.abort()
}
}
}
You can get the contents of a file stored in the /script_lib folder in the Resource file manager like this:
def fileContents = groovy.io.FileType.class.getClassLoader().getResource(resourceFilename).text
You can programmatically end or kill an engine session like this:
engineEnvironment.setSessionTimeout(0)
The VA session timeout period can be set in a script.
engineEnvironment.setSessionTimeout(n)
Was this page helpful?