Skip to main content

Documentation Index

Fetch the complete documentation index at: https://documentation.uponai.com/llms.txt

Use this file to discover all available pages before exploring further.

Overview

The Code Tool lets your agent run JavaScript code inline during a call. It’s ideal for lightweight tasks like data transformation, formatting, and simple read-only API lookups without needing to set up a custom function endpoint.

Setup

1

Add the tool

In your agent’s Functions section, click Add Function and select Code Tool.
2

Name and describe it

Give the tool a unique name and a clear description so the LLM knows when to invoke it.
3

Write your JavaScript

Use the available globals in your script:
GlobalDescription
dvAccess agent dynamic variables as strings
metadataCall metadata passed via API
fetch(url)Make HTTP requests
console.log()Debug output
Standard built-ins (Math, JSON, Date, Array methods) work normally. require and import are not available.
4

Extract response values

Map JSON paths from your script’s return value to dynamic variable names for use later in the conversation.
5

Configure speech

Optionally set what the agent says while the code runs or after it completes.
6

Update your prompt

Tell the agent when to invoke the tool:
When the user provides their order number, call the format_order_lookup tool to retrieve their details.

Configuration Options

SettingDefaultRange
Timeout30 seconds5–60 seconds
Response cap15,000 characters
Speech after executionEnabled

When to Use Code Tool vs. Custom Functions

Do not use Code Tool to access internal systems, write to production databases, or handle sensitive credentials. Both dv and metadata are stored as plaintext in call records.
Use Code Tool forUse Custom Functions for
Data formattingInternal system access
Simple calculationsDatabase writes
Read-only public API callsSensitive credentials
Routing logicAudit logging
Payment processing