JavaScript Node

This node is used to perform Java / JSON actions. For example, you can parse the output from a previous action, and use it to get the array list of values for a variable, so the user can see the updated information.

The screenshot below illustrates that after getting the user order details from the Fedexlink in the form of variable called ‘orderDetails’, it is fed as the input parameter for the Java node and the script parses to get the next level specific detail from the previous ‘orderDetails’ variable.

Usage Notes :

  • As an output of the Script Node, you can send text messages, carousels, or messages with option prompts. You can also branch the flow based on the script's result.

  • Additionally, the Script Node allows you to set attributes, which can then be used in later steps of the workflow.

JavaScript code generating Rules:

  • Use only var for variable declaration

  • Do not use the arrow function

  • Do not use ES6 conventions

Format for using Built-In variables in the JavaScript Node

identify the type of the variable in a JavaScript Node

Displaying a Message using a Workflow Variable

Eval Function

URL encoding String

Anchor tag in JS node

Generating Phrases from your Bot

Review the following example to learn how your bot can create phrases using the JavaScript Node.

Given Intent name is: Query Service Orders Available slot variables to be used when creating phrases that will train the Intent and trigger this Intent when the user asks questions that include: anyNumber - captures any number branch - list of branch names date - any date if user asks order - service order can be replace with this variable route - list of routes available

Remember to use the slot variables while generating phrases such as ${slot_variable_name}.

Examples:

  1. user query - view service orders

  1. user query - view service orders last month from main branch

  1. user query - view service orders in august from main branch

  1. user query - show service order 213089 details

Now your bot can generate phrases that use these variables.

Get Intents from Text

Payload

ActionNode

Response

Swap Keys and Values in JSON

Use application/x-www-form-urlencoded Header

  1. Use the HTTP Action node

  2. Pass the Body (as a String) as a variable to the HTTP request node.

LLM Format

JavaScript for an LLM Node

Parsing response:

LLM Nearby Restaurant Locations Prompt

LLM Nearby Tourist Locations Prompt

LLM Nearby Hospital Locations Prompt

LLM Distance and Time between 2 locations Prompt

Analytics

Pie Chart JS Code

Bar Chart JS Code

Table JS Code

Get User Profile Details Action Node

Generate RAG Answer Action

More Examples :

Displaying Information from a Database into a Dynamic Card

For displaying ALL table columns:

For displaying Specific table columns:

For displaying the card Selected by user

Current Date format

Sample JavaScript: (Support integrations)

Adding Dyanmic Arraylist(as String) to JSON Body

ArrayList for Airtable Listing Records

Date Format

Amount in US Format

Date to Epoch

sTable Formatting from JSON in JS Node

Random Number Generator

Flatten JSON from given ArrayList

Join Array with Commas

Unique Array while Iterating through JSON

Last updated

Was this helpful?