Scripts

InSkill Scripts are the way to connect to external systems for integration, or to run custom logic to process your data. Scripts are part of each product and can be edited in Product Settings

Product Scripts are javascript code that can be run

  • at the beginning of a task (context augmentation) usually to gather information from an IoT system, historian, etc.
  • at the end of a task (session finished) usually to send results of the task to another system, or email to support, etc.

You can edit and test scripts without making them active. When they are active, they will automatically run when tasks execute.

To develop a script, choose the event (eg. Session Finished) that will trigger the script. Below the script is json data of a task. You can edit this to reflect any data you want the script to process. Or you can Select Task from History to choose an existing task that has already run, to populate the json data. This way you are testing with the exact data set of a previous task.

When you click the Run Script button, the script runs and the result is displayed below.

For security reasons, all scripts run in a safe sandbox that limits the actions in a script. There are some predefined objects that represent the task context, optionally the asset if one is associated with this task, and some other objects. You cannot install additional packages.

The task's context (called a session or ds) contains information about the running task. For example, ds.task is the name of the task, and ds.getData("pressure") returns the value of the variable "pressure".

console.log() prints information in the result area when you test. (Automatically run scripts don't print anything)

The following packages are included:

  • request - make https requests to cloud services
  • moment - convert timestamps into date and time
  • moment_timezone - timezone aware
  • crypto - functions to sign requests, etc.

What’s Next