Table of Contents


The ScriptForge allows you to write applications that run during specific system events. Currently, scripting functionality is supported in the routing engine, where it runs alongside the call setup process. Requests to your application are handled with a messaging bus, and they will be queued if an application can't process them fast enough. Applications that run in the routing engine must be completed quickly to avoid high PDD.

Design Considerations


ScriptForge currently supports JavaScript ES6 (also known as ECMAScript 6 or ECMA6).


For speed enhancement variables in your application may be present between messages, however you should not assume this behaviour. Your application will be automatically distributed across multiple nodes and active variables will not be persistent. If you require persistence across messages you can use the datastore class. The memory of your application may be limited (default to 100MB). You should ensure that you don't try to use more than the allocated amount or your application may crash.

CPU (Time Limit)

There are no hardcoded CPU restrictions placed on any applications, though its run time is limited to two seconds by default.


If a message is not processed in time or fails duing processing, it will reset to an unconsumed state, making it available for further processing. This mechanic is in place to eliminate lost messages with redundancy.


Applications can run across multiple zones or data centers. By default, one process is allowed per script. If you find your application is too intensive or having difficulty scaling to business requirements, greater resource allocation may be required.


Programming environments are locked down to preven human error from changing too much, but we provide classes and help agents to assist clients with more specific functionality. Also, the Knowledge Base contains information about leveragingthis availability.


API code starts in the main() function, and execution will be marked as complete when exit(response) is called. Response is the name of the variable that returned to the instantiating system.

To perform the equivalent of an exception, call err();, which takes a single parameter, such as [404, "Not Found"]. Variables are made available through the vars() function. This is an example of a basic routing application:

function main(){
  var data = vars();

ScriptForge is designed to process one concurrent execution per server by default. It is important to execute exit() as soon as possible, since the server is blocked until this operation completes. It is also important to make sure there are no other branches of code executing after exit(), as this slows down requests, and can causes unexpected termination and time outs for future requests.


As JavaScript libraries are quite extensive and thus outside the scope of this documentation, we have covered only the basics here. More information about intermediate use of libraries is available to our clients on request, however.


All functions return a promise that contains an object with the same key values pairs found here:



A way to send messages from the system;


Random CLI

function main(vars){
  var cliList = ["11111","22222","33333","44444"];
  vars.routing.cli = cliList[Math.floor(Math.random() * cliList.length)];
  return vars;

Checking a DNC List

You can upload number lists for Do-not-Call or white lists in the User Space Database inside the main system. These lists can then be queried from ScriptForge.

function main(vars){
    if (!vars.routing) vars.routing = {};
    return api.lookup.userspaceLookup('DNC', vars.routing.dest_number).then(function(rData){
        return Promise.reject([603, "Denied (DNC)"]);
        if (err[0] == 603) return Promise.reject([603, "Denied (DNC)"]);
        return Promise.resolve(vars.routing);

Performing an ASRPlus Lookup

ASRPlus is a ConnexCS feature for reducing unecessary attempts and providing faster fails on calls. It is most suitable for agressive call-center traffic profiles.

function main(vars){
    if (!vars.routing) vars.routing = {};
    return api.lookup.asrplus(vars.routing.dest_number).then(function(asrplusData){
        if (asrplusData.status && asrplusData.status =='Invalid'){
            return Promise.reject([604, "Number not Found (ASRPlus)"]);
        } else {
            vars.routing.asrPlus = asrplusData;
            return Promise.resolve(vars.routing);

Creating a new script

You can customize your script in the new functionality of Connex and assign it to a specific customer.

  1. Select Script Forge from the side menu.

alt text

  1. Add a script by clicking +.

  2. Fill in the script's name and type, then click Save.

alt text

  1. Select your script from the list.

  2. Enter the code of your script and click the arrow next to Save and Restart.

  3. From the drop down menu, select Save .
  4. Click Start.

alt text

  1. Select the Run button at the top, and the result will be shown onscreen.

If script shows an error, select the arrow button next to Run and add this:


Run the script again:

alt text

Assigning the Script to a customer

You can assign scripts to customers: 1. Select Customer from the menu. 2. Choos a customer from the list by clicking its name. 3. Navigate to the Routing tab 4. Select a rate card from the table.

alt text

  1. A form opens called Route Ingress. Find the ScriptForge field and select your custom script from the list
  2. Click Save.

alt text