Documentation Index Fetch the complete documentation index at: https://docs.heylua.ai/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Lua CLI provides built-in APIs for common operations, so you don’t have to build everything from scratch.
import { Agents , User , Data , CDN , Products , Baskets , Orders , Templates } from 'lua-cli' ;
Agents Invoke another agent through the full chat pipeline
User Per-user persistent storage for state, preferences, and workflow data
Data Custom data with vector search
CDN File upload and retrieval
Products E-commerce product catalog
Baskets Shopping cart management
Templates Template messaging (WhatsApp)
Agents API
Agent-to-agent invocation — call a target agent through its full processing pipeline (billing, persistence, skills, preprocessors, postprocessors) from any sandbox code.
import { Agents } from 'lua-cli' ;
// Simplified — returns plain text
const reply = await Agents . invoke ( 'support-agent' , 'What is the refund policy?' );
// Full options — returns structured output with usage and tool info
const result = await Agents . invoke ( 'legal-agent' , {
prompt: 'Review this clause for risks.' ,
threadId: 'contract-456' ,
systemPrompt: 'Be concise.' ,
});
Use Cases
Full API Reference Complete Agents API documentation
User API
Persistent per-user storage that survives across conversations and sessions. Store any data — onboarding state, workflow progress, preferences, cart contents, verification results — as direct properties on the user object.
import { User } from 'lua-cli' ;
const user = await User . get ();
// Write any property — it persists across conversations
user . onboardingStep = 'verified' ;
user . plan = 'enterprise' ;
user . collectedData = { company: 'Acme' , role: 'admin' };
user . lastInteraction = new Date (). toISOString ();
await user . save ();
// Read it back anytime (even days later, in a different conversation)
const returning = await User . get ();
console . log ( returning . onboardingStep ); // 'verified'
console . log ( returning . plan ); // 'enterprise'
export class CheckOnboardingTool implements LuaTool {
name = "check_onboarding" ;
description = "Check and advance the user's onboarding progress" ;
inputSchema = z . object ({});
async execute ( input : any ) {
const user = await User . get ();
const step = user . onboardingStep || 'not_started' ;
if ( step === 'complete' ) {
return { message: `Welcome back, ${ user . name } ! You're all set up.` };
}
return {
currentStep: step ,
completedSteps: user . completedSteps || [],
message: `You're on step: ${ step } . Let's continue!`
};
}
}
Full API Reference Complete User API documentation
Data API
Store and retrieve custom data with semantic search capabilities.
Key Features
🗄️ Custom Collections : Store any JSON data
🔍 Vector Search : Semantic similarity search
📊 Filtering : Query by field values
📄 Pagination : Handle large datasets
Quick Example
import { Data } from 'lua-cli' ;
// Create with search indexing
await Data . create ( 'movies' , {
title: 'Inception' ,
director: 'Christopher Nolan' ,
year: 2010
}, 'Inception Christopher Nolan 2010 sci-fi thriller dreams' );
// Semantic search
const results = await Data . search ( 'movies' , 'mind-bending thriller' , 10 , 0.7 );
// Finds "Inception" even though query doesn't contain exact words!
Use Cases
Knowledge Base
Customer Notes
Product Recommendations
await Data . create ( 'kb_articles' , {
title: 'How to reset password' ,
content: 'Step by step guide...' ,
category: 'Account'
}, `password reset account help` );
const results = await Data . search ( 'kb_articles' ,
'forgot my password' , 10 , 0.7 );
await Data . create ( 'customers' , {
name: 'John Doe' ,
company: 'Acme Corp' ,
notes: 'Interested in enterprise plan'
}, `John Doe Acme Corp enterprise` );
const results = await Data . search ( 'customers' ,
'enterprise customers' , 20 , 0.6 );
await Data . create ( 'products' , {
name: 'Wireless Headphones' ,
description: 'Noise cancelling...' ,
category: 'Electronics'
}, `wireless headphones noise cancelling bluetooth` );
const results = await Data . search ( 'products' ,
'best headphones for travel' , 5 , 0.75 );
Full API Reference Complete Data API documentation
CDN API
Upload and retrieve files from the Lua CDN.
Key Features
📤 Upload Files : Store any file type
📥 Retrieve Files : Get files by ID
🖼️ Image Optimization : Automatic WebP compression
🤖 AI Integration : Use with AI for image analysis
Quick Example
import { CDN } from 'lua-cli' ;
// Upload a file
const file = new File ([ buffer ], 'document.pdf' , { type: 'application/pdf' });
const fileId = await CDN . upload ( file );
// Retrieve by ID
const retrievedFile = await CDN . get ( fileId );
console . log ( retrievedFile . name ); // 'document.pdf'
Use Cases
Document Storage
Image Analysis
User Uploads
// Store a document
const doc = new File ([ content ], 'report.pdf' , {
type: 'application/pdf'
});
const fileId = await CDN . upload ( doc );
// Save reference
await Data . create ( 'documents' , {
title: 'Q4 Report' ,
fileId: fileId ,
uploadedAt: new Date (). toISOString ()
});
// Get image from CDN
const file = await CDN . get ( imageFileId );
const buffer = Buffer . from ( await file . arrayBuffer ());
// Analyze with AI
const analysis = await AI . generate (
'Describe this image.' ,
[{ type: 'image' , image: buffer , mediaType: file . type }]
);
// Save user upload
const file = new File ([ userData ], 'profile.jpg' , {
type: 'image/jpeg'
});
const fileId = await CDN . upload ( file );
// Update user profile
await User . update ({ avatarFileId: fileId });
Full API Reference Complete CDN API documentation
Products API
Manage e-commerce product catalog.
import { Products } from 'lua-cli' ;
// Search products
const products = await Products . search ( 'laptop' );
// Create product
await Products . create ({
name: 'MacBook Pro' ,
price: 1999.99 ,
category: 'Computers' ,
sku: 'MBP-14-001' ,
inStock: true
});
// Get by ID
const product = await Products . getById ( 'product_abc123' );
Full API Reference Complete Products API documentation
Baskets API
Shopping cart management for e-commerce.
import { Baskets , BasketStatus } from 'lua-cli' ;
// Create basket
const basket = await Baskets . create ({
currency: 'USD' ,
metadata: { source: 'web' }
});
// Add items
await Baskets . addItem ( basket . id , {
id: 'product_xyz' ,
price: 29.99 ,
quantity: 2 ,
SKU: 'PROD-001'
});
// Checkout
const order = await Baskets . placeOrder ({
shippingAddress: { ... },
paymentMethod: 'stripe'
}, basket . id );
Basket Statuses
ACTIVE
CHECKED_OUT
ABANDONED
EXPIRED
Currently being used for shopping
Converted to an order
User left without checkout
TTL exceeded
Full API Reference Complete Baskets API documentation
Orders API
Order creation and management.
import { Orders , OrderStatus } from 'lua-cli' ;
// Create order
const order = await Orders . create ({
basketId: 'basket_abc123' ,
data: {
shippingAddress: { ... },
paymentMethod: 'stripe'
}
});
// Update status
await Orders . updateStatus ( OrderStatus . FULFILLED , order . id );
// Get orders
const userOrders = await Orders . get ( OrderStatus . PENDING );
Order Statuses
PENDING
Created, not yet confirmed
CONFIRMED
Confirmed, being processed
FULFILLED
Completed and delivered
CANCELLED
Cancelled by user or system
Full API Reference Complete Orders API documentation
Templates API
Send template messages across different channels. Currently supports WhatsApp templates.
import { Templates } from 'lua-cli' ;
// List WhatsApp templates
const result = await Templates . whatsapp . list ( channelId , { search: 'order' });
// Get specific template
const template = await Templates . whatsapp . get ( channelId , templateId );
// Send template message
await Templates . whatsapp . send ( channelId , templateId , {
phoneNumbers: [ '+447551166594' ],
values: {
body: { customer_name: 'John' , order_number: '12345' }
}
});
Use Cases
📦 Order notifications - Shipping updates, delivery confirmations
📅 Appointment reminders - Healthcare, salon, service bookings
🎉 Marketing campaigns - Promotions, announcements
🔐 Authentication - OTP codes, verification messages
Full API Reference Complete Templates API documentation
Combining APIs
Most real-world applications combine multiple APIs:
E-commerce Flow Example
export class QuickCheckoutTool implements LuaTool {
async execute ( input : any ) {
// 1. Search for product
const products = await Products . search ( input . productName );
const product = products . products [ 0 ];
// 2. Create basket
const basket = await Baskets . create ({ currency: 'USD' });
// 3. Add product
await Baskets . addItem ( basket . id , {
id: product . id ,
price: product . price ,
quantity: input . quantity
});
// 4. Create order
const order = await Baskets . placeOrder ({
shippingAddress: input . address ,
paymentMethod: 'stripe'
}, basket . id );
return {
orderId: order . id ,
total: basket . common . totalAmount
};
}
}
CRM with Custom Data Example
export class CreateCustomerTool implements LuaTool {
async execute ( input : any ) {
// Get current user
const user = await User . get ();
// Create customer record
const customer = await Data . create ( 'customers' , {
name: input . name ,
email: input . email ,
company: input . company ,
createdBy: user . email ,
createdAt: new Date (). toISOString ()
}, ` ${ input . name } ${ input . company } ${ input . email } ` );
// Log interaction
await Data . create ( 'interactions' , {
customerId: customer . id ,
type: 'created' ,
notes: 'Initial contact' ,
timestamp: new Date (). toISOString ()
});
return { customerId: customer . id };
}
}
API Comparison
API Best For Key Feature Agents Multi-agent orchestration Full pipeline invocation with auth & billing User Per-user persistent state Schemaless key-value store across sessions Data Custom schemas Vector search CDN File storage Upload/retrieve files Products E-commerce Pre-built catalog Baskets Shopping carts TTL & status Orders Order tracking Status workflow Templates Proactive messaging WhatsApp templates
Next Steps
API Reference Complete API documentation with examples
Tool Examples See working examples using all APIs
Build Your First Skill Step-by-step tutorial
Environment Variables Learn about configuration management