Scripting

Throughout the lifetime of your bot, you may need to execute scripts and code. For example, at the start of the conversation you might want retrieve and store the timezone of the user, so you can personalize the greeting message and also use the timezone in other flows. Or inside a flow, you might want to run a script validates if a user provided a valid account number.

Groovy

Scripts in Teneo are written in Groovy or Java code. Apache Groovy is similar to Java but with an easier to learn syntax. More details on Groovy can be found here: http://groovy-lang.org.

For a quick overview basic Groovy scripts that come in handy when using Teneo, see the Groovy basics page. If you're looking for something more like a tutorial, we quite like this one: https://www.timroes.de/2015/06/27/groovy-tutorial-for-java-developers/.

Teneo engine scripting API

In many cases you may need to accces to internal engine and request data in your scripts. You may for example want to use the user's input in a script or store a request parameter in a global variable. The Teneo engine scripting API provides access for scripts to internal engine data as well as request parameters. For more details, please refer to the Engine scripting API Reference.

Where to add your code?

You can add scripts at various places in a solution, depending on when you want the script to be executed. Some places have already been covered:

This chapter will cover additional areas where you can add and use scripts or that are revelant when working with scripts.

Was this page helpful?