Skip to main content

Available Examples

The template project includes 30+ working tools demonstrating all major patterns and use cases.

Learning Path

1

Start Simple

Weather Tool - External API integrationShows how to call external APIs and handle responses
2

Platform APIs

User Data Tools - Simple platform API usageLearn how to use Lua’s built-in APIs
3

CRUD Operations

Products Tools - Complete CRUD patternCreate, read, update, delete with pagination
4

Vector Search

Custom Data Tools - Semantic searchMost powerful feature! Build searchable knowledge bases
5

Complex Workflows

Baskets Tools - Multi-step processesHandle complex business logic and state

Tool Categories

External APIs (1 tool)

Tools that integrate with external services:

GetWeatherTool

File: GetWeatherTool.tsWhat it does: Fetches real-time weather using Open-Meteo APILearn:
  • Making HTTP requests
  • Handling API responses
  • Error handling
  • No API key required

Platform APIs (27 tools)

Tools using Lua’s built-in platform APIs:
  • get_user_data - Retrieve user info
  • update_user_data - Update profile
Learn: Basic platform API usage

Integrations (2 tools)

Payment Tool

Stripe payment link creationLearn: Environment variables, external services

Create Post Tool

Simple exampleLearn: Basic tool structure

Quick Reference

ToolComplexityBest For Learning
CreatePostTool⭐ EasyTool basics
GetWeatherTool⭐⭐ MediumExternal APIs
UserDataTools⭐ EasyPlatform APIs
ProductsTools⭐⭐ MediumCRUD operations
CustomDataTools⭐⭐⭐ AdvancedVector search
BasketsTools⭐⭐⭐ ComplexWorkflows
OrderTools⭐⭐ MediumOrder management
PaymentTool⭐⭐⭐ AdvancedIntegrations

How to Use These Examples

Approach 1: Copy and Modify

  1. Find similar tool (e.g., CustomDataTool.ts for searchable data)
  2. Copy the file
  3. Rename (e.g., ArticleTool.ts)
  4. Update names, descriptions
  5. Modify logic for your domain
Time: 15-30 minutes per tool

Approach 2: Learn Pattern, Build New

  1. Read an example tool
  2. Understand the pattern
  3. Close the file
  4. Build your own from memory
  5. Refer back if stuck
Time: 30-60 minutes per tool Learning: Deeper understanding

Approach 3: Mix and Match

  1. Keep useful examples as-is
  2. Delete irrelevant ones
  3. Add your custom tools alongside
  4. Deploy mix of examples + custom
Time: Variable Best for: Quick prototyping

Testing Examples

# Test conversationally (primary method)
lua chat

# Try in sandbox mode:
# - "What's the weather in Tokyo?"
# - "Show me your products"
# - "Find movies about space"

# Test individual tools (optional)
lua test

# Select a tool:
# - get_weather: Enter "London"
# - search_products: Enter "laptop"
# - search_movies: Enter "thriller"

Common Patterns Demonstrated

Example: GetWeatherTool.ts
const response = await fetch(apiUrl);
const data = await response.json();
return transformedData;
Example: ProductsTool.ts
import { Products } from 'lua-cli';
const products = await Products.search(query);
Example: BasketTool.ts
// Step 1: Create
const basket = await Baskets.create({...});

// Step 2: Add items
await Baskets.addItem(basket.id, {...});

// Step 3: Checkout
const order = await Baskets.placeOrder({...}, basket.id);
Example: PaymentTool.ts
import { env } from 'lua-cli';
const apiKey = env('STRIPE_API_KEY');

Next Steps