Encouragement functionality in Teneo Web Chat


A Teneo based Virtual Assistant is a client-server software. The server side is a Teneo engine, a web application that receives HTTP requests and serves responses. The client side can be any kind of frontend or a middleware implementing the communication logic required by the Teneo engine.

Communication logic of Teneo Web Chat

Teneo Web Chat (TWC) is a web frontend for Teneo engine. In its basic implementation it sends user inputs to Teneo engine and displays the engine’s responses. TWC has an extensive API to create extensions. With these extensions one can modify the core logic of the frontend.

User inactivity: encouraging user to go on chatting

A common scenario is a user interacting with a Virtual Assistant (VA) and then leaving the interaction with the VA still open to do something else. In such cases the user can be reminded about the interaction that s/he started and encouraged to continue chatting with the VA. Apart from making the VA look more interactive, this can increase the VA usage rate and generate thus better results both for the user and for the enterprise that have implemented the VA in its web pages.

Adding encouragement to your project

In order to implement the encouragement functionality in your VA project in Teneo, you should add the extensions file “twcEncouragementExtension.js” after the TWC core and before its initialization code in the pages your TWC is installed in:

<script src="path/to/teneo-web-chat.js"></script> 
<script src="path/to/twcEncouragementExtension.js"></script> 
window.addEventListener('load', () => { 

Furthermore, you should configure in your solution an encouragement sequence, which is a JSON array of encouragement entries looking as one of these ones:

  • {"delaySeconds": 300, "text": "I see you've got distracted with something else. Let's continue our conversation."}

  • {"delaySeconds": 200, "text": "I see you've got distracted with something else. I am closing our chat. Ask me something if you want to restart our conversation.", "command": "disableUserInput"}

  • {"delaySeconds": 40, "command": "reset"}

Here the “delaySeconds” property defines the delay in seconds of the message contained in the “text” property and/or of the command specified in the “command” property. These delays are counted from the latest response received by TWC from Teneo engine for the first entry in the array and from the action of the previous encouragement entry for each other entry.

As an illustration, let’s consider the following encouragement sequence:


  {"delaySeconds": 300, "text": "I see you've got distracted with something else. Let's continue our conversation."}, 

  {"delaySeconds": 200, "text": "Hey! Are you still there?"}, 

  {"delaySeconds": 60, "text": "I see you've got distracted with something else. I am closing our chat. Ask something if you want to restart our conversation.", "command": "endSession"}


It describes the following scenario.

If the user has not submitted anything during 300 seconds after the Teneo engine’s response, either by submitting a text or by clicking a Call to Action (CTA), TWC displays the message “I see you’ve got distracted with something else. Let’s continue our conversation”. If the user makes an input, the conversation continues its original path. But if the user waits 200 seconds more without submitting anything, TWC displays the message “Hey! Are you still there?”, If the user submits something within 60 seconds after this message, the conversation continues. If not, TWC displays the message “I see you’ve got distracted with something else. I am closing our chat. Ask something if you want to restart our conversation” and kills the existing session via the command “endSession”. If the user now submits something, a new conversation session is started.

The following commands are currently implemented and can be used:

  • endSession” terminates the backend session without closing TWC (this command may only be present in the last entry of an encouragement sequence);

  • reset” terminates the backend session and closes TWC (this command may only be present in the last entry of an encouragement sequence);

  • disableUserInput” disables the user input field of TWC;

  • enableUserInput” enables the user input field of TWC.

The commands “disableUserInput” and “enableUserInput” are useful in scenarios where you just want to disable the user input for certain Teneo engine outputs and enable it again afterwards without displaying any encouragement text.

An encouragement sequence should be delivered from Teneo engine (the solution) to TWC as the value of the output parameters “encouragements” or “nodeEncouragements”. Both output parameters accept the same kind of values, in the same format. The difference consists in how the encouragement is applied.

If an encouragement sequence is returned in the “encouragements” output parameter, it is “memorized” by TWC till TWC is closed or till this value is overwritten by a new “encouragements” value. Thus, once you have outputted a non-empty encouragement sequence via “encouragements”, this sequence will be actioned for all the subsequent user inputs, and there is no need to output it over and over again with each Teneo engine response. In this way, if you want to deactivate the encouragements starting from a certain output, you just output an empty sequence, [].

There are some cases, though, where you might want to change the encouragement sequence or even disable the encouragement for one specific interaction and use the normal encouragement sequence for the other ones. This can be achieved by outputting your one-time encouragement sequence in the output parameter “nodeEncouragements”. This sequence will be applied till the next user input only. The user inputs coming afterwards will be subjected to the sequence outputted previously via “encouragements” or to none if nothing has previously been outputted via “encouragements”.

This encouragement implementation is compatible with the TWC state persistence logic and works correctly when the user navigates or refreshes the page. It is also compatible with CTAs (buttons, clickable lists, forms etc) in the outputs. Although displaying an encouragement message moves the currently active CTAs in the dialog history deactivating them, the eventual CTAs from the previous Teneo engine output are copied in this case again in the output right after the encouragement message and the user can interact with them.


One should avoid putting questions in encouragement messages since users answering them might trigger unforeseen Teneo interpretations. Also, encouragement messages may not contain CTAs.


Encouragement is a relatively simple, but useful functionality prompting the user to continue interacting with the VA. Combined with commands it provides a flexible way to display messages to the user and execute some of the TWC functions without interfering with the dialog flow itself.


Great article! :slight_smile: Are there any further extensions available for Teneo Web Chat? And if so, is the code uploaded somewhere on GitHub?

Hi. Currently we have extensions for agent chat handover integrations for Genesys Cloud Chat (Pure Cloud), LiveChat Inc and Mitel Chat. The goal of these extensions is to transfer the dialog from a Teneo virtual assistant to a human chat agent on these chat providers, whereas TWC acts as a frontend to the corresponding agent chat systems. So from the user’s perspective the virtual assistant is replaced by a real person in TWC at some point during the dialog. These extensions are stored on our website though. They usually contain one single JavaScript extensions file and multiple Groovy code snippets to be used in their corresponding places inside your Teneo Solution. We can add more extensions in the future.