Nected Docs
Try Nected For Free
  • 5 min QuickStart Guide
  • Getting Started
    • Introduction
    • Core Concepts
    • Use Cases
    • Tech Architecture
    • FAQs
  • INTEGRATIONS
    • Overview
    • Integrations Libraries
      • PostGres
      • MySQL
      • Oracle
      • MS SQL Server
      • Snowflake
      • MongoDB
      • RedShift
      • REST API
      • Google Sheets
      • Slack
    • Managing Integrations
  • DATASETS
    • Overview
    • Managing Dataset
  • Rules
    • Overview
    • Rule Types
      • SimpleRule
      • DecisionTable
      • Ruleset
      • Rule Chain
    • Rule Conditions
    • Rule Actions
    • Concepts
      • Rule Result
      • Test & Publish Rules
    • Add Input Attributes
      • JSON Input Attributes
      • List Input Attributes
  • Triggers
    • Trigger Rule via API
    • Trigger Rule via WebHook
    • Trigger Workflow via API
    • Trigger Workflow via WebHook
    • Scheduler
    • Rule Response Format
  • Workflow
    • Overview
    • Managing Workflow
    • Add Node
      • Action Nodes
        • Rule Node
        • Workflow Node
        • Custom Code Node
        • Database Node
        • REST API Node
      • Control Nodes
        • Loop Node
        • Delay Node
        • Response Node
        • Set Variables Node
        • Switch Block
    • Test & Publish Workflows
  • CODE AND DATABASE QUERIES
    • JavaScript Editor
    • Formula Editor
    • JSON Editor
    • List Editor
    • Excel-like Function
  • Embedded System
    • White-Labelling
    • Embeddable View
  • Self Hosting
    • Overview
    • Infrastructure Sizing
    • New Installation
      • Docker
      • Kubernetes
        • Set Up Kubernetes Cluster on AWS EKS
    • Additional Configuration
      • High Availability
      • Email Setup Guide
    • Upgrade Nected Version
  • Security
    • API Authentication
      • OAuth as part of Authentication under REST API
    • Role Based Access Control (RBAC)
    • SOC 2 Type 2, GDPR, ISO Compliance
  • Audit
    • Audit Trail
    • Approval Flow
    • Version Control & Rollback
    • Import/Export
  • Management API
    • Audit Log API
    • Global Variable API
  • References
    • Attribute Library
    • Global Variables
    • Pre-Configured Tokens
    • Pre-Configured Operators
    • NULL Value Handling/Behavior
    • Troubleshooting Errors
      • Multiple Tabs/Users Edits
      • Limits in Nected
    • Allowed Status Combinations
    • Environments
    • Usage Widget
    • Gen AI
  • ACCOUNT SETTINGS
    • Workspace Setting
      • Date Format and Timezone Settings
Powered by GitBook
On this page
  • How to Access Gen AI?
  • Overview of GenAI Features
  • 1. Explain Code
  • 2. Ask AI
  • Conclusion
  1. References

Gen AI

PreviousUsage WidgetNextWorkspace Setting

Last updated 9 months ago

Nected’s GenAI feature is designed to help you minimize the struggle of writing custom conditions using JS Code and Formula Editors. It has two options Ask AI and Explain Code. Ask AI to help in your coding challenges while Explain Code provides a full explanation of your written code in the editor.

How to Access Gen AI?

To access the Gen AI you can go to the and available under additional data and data type options within Rules.

Similarly, it can be accessed in Workflows through the , , and .

See the image below for a better understanding:

Once you've selected from the options, you will see the editor screen where you can find two key features of GenAI:

Overview of GenAI Features

As discussed above, GenAI has two features: Explain Code and Ask AI. Below is the definition of each:

1. Explain Code

Located after the "Functions" option, this button explains code snippets in plain text. Just click on it, and the code present on the screen will be explained.

Let’s understand this feature taking a scenario below:

Code Example:

*{{.customInput.asset_price}}-({{.customInput.asset_price}}*{{.outputData.dynamic_discount}});*

Explanation given by GenAI:

The code calculates the result of the formula: 100 - (100 * 0.1). It multiplies 100 by 0.1, subtracts the result from 100 and returns the final value. The tokens used in the code are '{{.customInput.asset_price}}' which has an 'executableValue' of 100 and 'meta' of 'numeric', and '{{.outputData.dynamic_discount}}' which has an 'executableValue' of 0.1 and 'meta' of 'numeric'. These tokens can be accessed in the code as variables containing their respective executable values.

2. Ask AI

Positioned on the right side of the screen, this feature provides coding assistance. You can copy-paste code or write a query to generate an answer.

Let’s take some use-case scenarios of Ask AI:

→ Helps in Troubleshooting

Ask AI can assist in identifying potential issues by analyzing your code, suggesting improvements, or offering troubleshooting tips directly within the editor.

Example Scenario: You have written a complex formula or script and need help identifying why it's not working as expected.

Prompt given:

The following formula isn't giving the expected result. Can you identify the issue?

let finalPrice = basePrice + (basePrice * taxRate) - (basePrice * discount);
if (finalPrice < 0) {
finalPrice = 0;
}

Result:

The issue is with the order of operations when calculating the final price. Instead of subtracting the discount directly from the base price, we should calculate the taxed price first and then apply the discount.

→ Get Suggestions on complex conditions

Use the Ask AI feature to get code snippets or logic suggestions tailored to your needs.

Example Scenario: You want to implement a dynamic discount system that supports multiple coupons.

Prompt Given: Write logic for applying dynamic discounts based on coupons, allowing multiple coupons to be applied.

Result:

const coupons = {
  'FIRST_PURCHASE': 10,
  'WEEKEND_SALE': 15,
  'FREESHIPPING': 5
};

function applyCoupons(items, appliedCoupons) {
  let totalDiscount = 0;

  appliedCoupons.forEach(coupon => {
    if (coupon in coupons) {
      totalDiscount += coupons[coupon];
    } else {
      throw new Error('Invalid coupon code');
    }
  });

  return items.reduce((total, item) => total + item.price, 0) - totalDiscount;
}

const items = [
  { name: 'Item 1', price: 50 },
  { name: 'Item 2', price: 30 },
  { name: 'Item 3', price: 20 }
];
const appliedCoupons = ['FIRST_PURCHASE', 'WEEKEND_SALE'];

const finalPrice = applyCoupons(items, appliedCoupons);
console.log('Final Price after applying coupons:', finalPrice); //75

→ Generating Formula Expressions

In cases where you need to create formulas involving multiple variables, the Ask AI can help generate accurate expressions, saving time and reducing errors.

Example Scenario: You want to calculate a final product price by considering multiple variables, such as base price, tax rate, and multiple discounts.

Prompt Given: Create a formula to calculate the final price after applying a tax rate and two different discount percentages.

Result:

function calculateFinalPrice(initialPrice, taxRate, discount1, discount2) {
let priceAfterTax = initialPrice * (1 + taxRate);
let priceAfterDiscount1 = priceAfterTax * (1 - discount1);
let finalPrice = priceAfterDiscount1 * (1 - discount2);
return finalPrice;
}

Conclusion

With the GenAI features seamlessly integrated into the formula and JavaScript editors, coding challenges become simpler and more efficient. Whether you’re defining complex conditions, generating expressions, debugging, or simply seeking to understand existing code, the GenAI is there to guide you.

Note: The GenAI feature in Nected is available within the and editors

The above code is generalised and can be adapted to work with different input formats e.g .

Formula
JavaScript
tokens
formula editor
JS editors
Code node
Response node
Set Variable node
The above image is for the JS Code Editor; the same applies to the formula editor.