Replacer scripts

The Replacer Script lets you swap out core actions with your custom script.

You must be very exact with both input and returned data. With the replacer scripts the input data and the returned data is different for every script. however there are several common aspects

All Replacer scripts will be based in a data block that will contain specific information. You will also find the current company available on the bbCore library.

Setup

A script is setup in the manifest of a script with :

{
      "name":"TestAdminScript",
      "description":"An example script",
      "type":"Replacer",
      "actions": ["UrlShortener"],
      "log_type": "Tail",
      "enabled": true,
      "handler": "shorten"
    }
On Success

On successfully running, your script is expect to return any expects results in a result params. The result object may be a simple text string, an array, or a complex object, depending on the function, for example:

callback(null, {result: 'My returned text'})

Is the action has no data required as a result, i.e. it is a fire-and-forget action, you should instead just pass back an success value

callback(null, {success: true})

On Failure Fallback

If you scripts fails for some reason, you can choose to fall back the default action, which is also what will happen if your scripts errors unexpectadly

callback(null, {fallback: true});

Script types
Script ActionDescriptionInput Params (data)Response Values
UrlShortenerA custom URL shortener, pass in the the URL to shorten and expected to return the new URL to useurl: textresult: text
SMSSenderA request to a send an SMS to a mobile numbermessage: text,
recipient: text
success: bool
Examples

Some example apps that demonstrate Replace scripts