Zenbot also enables you to use general Javascript code instead of simple expressions to calculate any variable's value. Thus you are not limited with expressions syntax and built-in functions and can use your own code on well known Javascript programming language for this purpose.

Little snippet

<input pattern="repeat($Number)">
  <var name="Numbers">
        var result = '';
        for (var i = 0; i < $Number.lenght; i++) {
          result += $Number[i] + ' ';
  <output value="There are your numbers $Numbers"/>

This simple code shows how you can use Javascript code to calculate a “Numbers” variable value.

There is a special inner tag script you have to insert inside the var tag. Note that you have to use CDATA to prevent XML parser from processing the inner Javascript code.

  Note that you must not use "return" keyword in your Javascript.

Inline mode

You can also define your Javascript code in more compact mode:

<var name="MyVar" value="javascript: new Date().getTime()"/>

Just place “javascript:” keyword in the value attribute of your var tag before the Javascript code. Thus Zenbot will evaluate such code to obtain an actual variable's value.

JS files

You can define some parts of re-usable javascript functions in separate files with “.js” extension. You are free to place such files in any folders inside your Bitscript project. Zenbot loads it on start.

For example you can create a file named “common.js” with content like

function say(txt) {
  return txt;

And then use this function inside your Bitscript

<var name="SayResult" value="javascript: say($Text)"/>

Referencing external variables

In the code above you can see how you can reference some external variables inside your Javascript code. Zenbot converts each variable from patterns for you, so you can work with them as with a regular object and arrays in Javascript.


Javascript code in Zenbot runs inside a safe “sandbox”. Thus you cannot use any sort of network functions or file system's abstractions.

  You can use GET and POST actions of Zenbot to perform some network activity.