logo

Custom Code Tools & Sandboxed Execution

Code Tools allow you to add custom JavaScript logic directly into your Omnisetu LLM workflows — performing math calculations, data transformations, and custom business logic in a secure sandbox.

Overview

Programmable In-Workflow Intelligence

Combine conversational AI with custom JavaScript snippets. Execute fast, secure computations inside an isolated sandbox runtime without building external webhooks.

Native JavaScript Execution

Write standard JavaScript functions that receive structured inputs from the LLM and return clean result objects.

Isolated Sandbox

Runs inside high-speed isolated sandboxes with 128MB RAM, 3000ms timeout controls, and zero network side-effects.

Zero Network Overhead

Instant calculations without waiting for network round-trips to external microservices.

Execution Flow

How Code Tools Work

LLM agents run isolated JavaScript calculations in a secure sandbox.

STEP 01

User Request

User asks for a query requiring computation (e.g. 'Calculate cart total').

STEP 02

LLM Bot Intent

LLM identifies that custom calculation logic is required.

STEP 03

Code Tool Call

Passes structured input variables to the configured Code Tool.

STEP 04

Sandbox Execution

Runs JavaScript function inside secure 3000ms sandbox.

STEP 05

Result Output

Returns calculated result JSON (e.g. Subtotal, Tax, Grand Total).

STEP 06

LLM Response

LLM incorporates calculated output into a natural final response.

Interactive Demo

Code Execution Preview

See how a custom JavaScript snippet receives LLM variables, executes business logic, and returns formatted data.

Custom Math & Cart Calculation

Example: Shopping Cart Subtotal, Shipping, & Tax

When a customer asks for order pricing, the LLM agent extracts the cart items and destination, passing them as inputs into the Code Tool.

INPUT VARS:cartItems, shippingCountry
EXECUTION TIME:14 ms
calculateCartTotal.js
Isolated Sandbox

function main({ cartItems, shippingCountry }) {

// Compute cart subtotal

const subtotal = cartItems.reduce(

(total, item) => total + (item.price * item.quantity), 0

);

// Shipping rate logic

const shippingCost = shippingCountry === "US" ? 5.99 : 14.99;

const taxRate = 0.08;

const tax = subtotal * taxRate;

const grandTotal = subtotal + shippingCost + tax;

return {

subtotal: subtotal.toFixed(2),

shippingCost: shippingCost.toFixed(2),

tax: tax.toFixed(2),

grandTotal: grandTotal.toFixed(2),

currency: "USD"

};

}

Execution Output (14ms){ subtotal: "45.00", shippingCost: "5.99", tax: "3.60", grandTotal: "54.59", currency: "USD" }
SUCCESS

Security Overview

Isolated Sandbox Environment

Built for high-performance isolated computation with strict security controls.

Language

JavaScript (ES2024)

Runtime

Isolated Sandbox

Execution Limit

3000 ms Max

Memory Allocation

128 MB RAM

Network Access

Restricted (No External Calls)

Built-in Utilities

Math, Date, JSON, RegExp, Array

Use Cases

What You Can Build with Code Tools

12 essential computation and data processing capabilities for your LLM agents.

Math Calculations

Perform complex arithmetic, formulas, and numeric scores.

Currency & Pricing

Calculate cart subtotals, tax rates, discounts, and order totals.

Shipping & Rates

Compute shipping costs dynamically based on zone and weight.

Data Formatting

Normalize phone numbers, format currency strings, and clean text.

Date & Time Parsing

Format timestamps, compute age, and calculate date differences.

Regex Parsing

Extract emails, policy numbers, order IDs, and regex matches.

Data Validation

Verify input schema, postal code formats, and required fields.

Array & Object Tools

Filter, map, reduce, and manipulate JSON structures.

Custom Business Rules

Apply proprietary company logic, tiers, and decision matrices.

Data Transformation

Reformat LLM payloads into downstream automation structures.

Conditional Logic

Execute multi-branch decision trees based on user properties.

String Manipulation

Sanitize HTML tags, truncate strings, and join text fragments.

Comparison

Code Tool vs Function Tool

Code Tools handle internal computation & formatting. Function Tools handle external APIs & network operations.

Code Tool (Internal Computation)

Internal Computation & Processing

Designed for JavaScript logic, math, date formatting, regex parsing, and JSON transformation inside the sandbox without network calls.

  • Calculate order subtotal, shipping, & tax
  • Format dates & sanitize string inputs
  • Validate payload schema & regex patterns
Function Tool (External Network)

External API & Network Operations

Designed for external REST API integration, CRM updates, booking appointments, and querying live external databases.

  • Call CRM REST APIs (HubSpot, Salesforce)
  • Book appointments & reserve calendar slots
  • Retrieve live user records & order statuses

Frequently Asked Questions

Code Tools allow you to add custom JavaScript logic directly into your Omnisetu LLM workflows. They are designed for tasks that require calculations, data transformation, validation, parsing, formatting, or custom business logic without needing an external API.
Code Tools execute inside an isolated sandbox environment. It enforces a 3000ms max execution time, 128MB memory limit, restricted network access, and provides built-ins like Math, Date, JSON, RegExp, and Array.
Code Tools are designed for internal computation, data processing, and math calculations (without network access). Function Tools are designed for external API calls, CRM updates, and network operations.
Yes! You can use full JavaScript array methods (reduce, map, filter), string parsing, regex, and object transformations to format data before sending responses back to the LLM.

Your competitors are already automating. Are you?

Stop wasting time switching between messaging apps. Omnisetu unifies WhatsApp, Instagram, Email, and every channel into one workspace — with 24/7 AI that qualifies leads and answers questions automatically.

No credit card required · 14-day free trial · Cancel anytime