Custom JavaScript code in no-code automation

Custom JavaScript in nana800 goes into the run custom script block: it runs JavaScript or TypeScript right inside the scheme and passes the result to the next blocks. It works the other way too: the nana800-code-action npm library starts a scheme from the code of your website, app or server. Both blocks are free, you pay only for the other blocks of the scheme and its hours.

Build it in the builder
  • Block run: $0
  • Free every month: $3.50
  • No card needed

What you can do

  • Reshape data your own way: pick fields from an API answer, filter a list, count an order total
  • Write JavaScript or TypeScript with await and return, use the lodash library and the wait(ms) pause function
  • Read the results of all earlier blocks and the project variables in your code
  • See console.log output in the block result, up to 1,000 lines, to track down bugs
  • Start a scheme from your own code in Node.js 18+, in a browser or in React Native with the nana800-code-action npm library
  • Pass any data from your code to the scheme and, if you want, wait until it finishes

Blocks in the builder

  • Custom script

    Action · free

    Runs JavaScript or TypeScript code in an isolated sandbox. Whatever return gives back lands in result and is available to the next blocks. The block also returns logs, success and error_text. This block is free.

  • Start from code (trigger)

    Trigger · free

    Starts the scheme with a call from your code through the nana800-code-action npm library or a plain POST request with your API key. The data you pass arrives in the scheme in the payload field. You can make the call wait for the scheme answer.

How to set it up

  1. 1

    Add the script block

    Create a scheme in the builder with the button trigger for testing and add the run custom script block. Write your code in the script field and return the result with return, for example return { total: 5 }.

  2. 2

    Use data from earlier blocks

    Block results are available in the NODES object by block name, and project variables are in GLOBAL_ENV. Network, timers and Node.js modules are closed in the sandbox: make API calls with the request block and parse its answer in your code.

  3. 3

    Turn the scheme on and check the result

    Turn the scheme on, press the button trigger and open the block result: result holds what your code returned, logs holds the console.log lines and error_text the error message. Fields from result go into the next blocks.

  4. 4

    Start the scheme from your code

    Add the code action from code with npm library trigger to the scheme. Create an API key in the nana800 settings, install the library with npm i nana800-code-action and call startTriggerAction with the key, the scheme ID, the trigger block name and your data in payload.

  5. 5

    Keep the scheme on

    While the scheme is off, a call from code will not start it. An enabled scheme costs $0.0042 per hour. The API key is tied to your account, so call the scheme from your own server, not from page code that visitors can see.

Templates with this service

  • Telegram chat bot with an auto reply

    A Telegram chat bot template with no code: the bot receives messages and photos from customers and replies at once. You only need a token, free balance monthly.

Frequently asked questions

The run custom script and code action from code with npm library blocks are free. You pay for the other blocks of the scheme and for the time it is on: $0.0042 per hour. Your balance is topped up to $3.50 for free every month, no card needed. A scheme kept on around the clock for a month spends most of that on scheme hours.

The whole script, including await and wait, has to finish in 5 seconds, and continuous computing without pauses in 500 ms. Memory is up to 64 MB, the result is JSON up to 8 MB, logs up to 1,000 lines. If a limit is hit or the code throws, the block returns success = false with the error text, and the scheme goes on.

No. The script runs in an isolated sandbox with no network, timers or Node.js modules: require, fetch, setTimeout and process are not available. For requests, put the request block before the script and parse its answer in the script. The lodash library is available.

Create the API key in your nana800 account settings, in the API key section. The scheme ID is in the address of the scheme in the builder, after /scheme/. The block name is the name of the code action from code with npm library trigger in your scheme.

A webhook is a public address: a request can come from anywhere, and it can send data back with the webhook response block. Starting from code checks your API key, so a stranger cannot start the scheme. If your code needs data back from the scheme, use a webhook.

No. Most schemes are built from blocks with fields. A script helps when data has to be reshaped by your own rules, and starting from code is for developers who want to call a scheme from their own app.

Build your first scheme for free

Sign-up is free and needs no card. Every month the balance is topped up to $3.50 for free, enough for about 3,500 runs of basic blocks.

Build it in the builder