Skip to main content

Processing $session and $client data overflow in the script

caution
There is a limit on the amount of data stored in the $session and $client objects. If this limit is exceeded, the current script is aborted and the bot stops responding to the client.

You need to handle the $session and $client object data overflow events in your script to prevent it from being aborted.

Limits

The following limits are set by default:

  • soft: 100 KB;
  • hard: 1000 KB.
tip
Please note that these limits are set per object. This means that 100 KB of data are available for the $client object under the soft limit and 100 KB more data are available for the $session object.

Overflow handling

If the soft limit is reached but the hard limit is not exceeded, data will continue to be saved to the $session and $client objects. The script will receive the following events when the soft limit is reached: event: sessionDataSoftLimitExceeded and event: clientDataSoftLimitExceeded.

If the new data exceed the hard limit, they are not saved to the $session and $client objects. The script will receive the following events when the hard limit is reached: event: sessionDataHardLimitExceeded and event: clientDataHardLimitExceeded.

Example of data overflow handling in the script:

state: Text
q!: *
script:
$session.text = $parseTree.text // save session data
a: You said: {{$parseTree.text}}.

state: Delete
event: sessionDataSoftLimitExceeded // process the “soft limit reached” event
script:
delete session.text; // session data are deleted when the soft limit is reached