Contact Log in

Execute JS

During a flow, sometimes you’ll need access to a full programming language to handle custom behaviors. Thankful provides a full Javascript VM for this purpose.

You have no disk or network access, and the VM will be killed after 1 second, which is plenty of time for most loops and workloads. Network access must be through separate Webhook steps.

This VM provides an ECMAScript v5 compatible JS. This means let, const, and other ECMAScript 6 additions are not available.

console.log can be used in the VM to log output, and this output will be visible in the action event in the ticket itself. This can be extremely helpful when debugging. The output from console.log will be visible like this:

Screenshot showing the action event on a ticket

Thankful by default does not pass in or out any memories from the VM. You can specifically pass a variable to the VM using the In Memories and Out Memories sections above and below the JS textarea, respectively. In Memories will be available as variables in the JS VM. The same memory can be both passed in and passed out, indicating that the Execute JS step is modifying the memory.

Using the Parse JSON checkbox, you can have all memories passed into the VM converted to JSON for you. Without this checkbox, you’ll need to run the following before trying access any JS object fields or arrays:

myMemory = JSON.parse(myMemory)

Note that Webhook response bodies can not be parsed as JSON, so you cannot use the Parse JSON checkbox when passing in webhook data. Manually parse the responses in the VM when appropriate.

Ask Support