Overview
SaaS onboarding assistant using your product API + Lua Data API for documentation search. What it does:- Guide new users through setup
- Answer product questions
- Create user accounts
- Configure settings
- Search documentation
Complete Implementation
src/index.ts
Copy
import { LuaAgent, LuaSkill } from "lua-cli";
import {
SearchDocsTool,
CreateUserTool,
GetUsageTool,
ConfigureSettingsTool
} from "./tools/SaaSTools";
// SaaS onboarding skill
const saasSkill = new LuaSkill({
name: "saas-onboarding",
description: "SaaS product onboarding and user assistance",
context: `
This skill helps new users get started with our SaaS product.
- search_docs: Find answers in product documentation
- create_user: Create new user accounts
- get_usage: Check usage statistics and limits
- configure_settings: Help users configure their settings
Guide users through setup step-by-step.
Search documentation before creating support tickets.
`,
tools: [
new SearchDocsTool(),
new CreateUserTool(),
new GetUsageTool(),
new ConfigureSettingsTool()
]
});
// Configure agent (v3.0.0)
export const agent = new LuaAgent({
name: "saas-onboarding-assistant",
persona: `You are a friendly SaaS product onboarding specialist.
Your role:
- Guide new users through product setup
- Help users understand features and capabilities
- Assist with account configuration
- Answer product questions
- Provide usage tips and best practices
Communication style:
- Friendly and enthusiastic
- Patient and encouraging
- Clear and step-by-step
- Supportive and helpful
Best practices:
- Break complex setup into simple steps
- Celebrate user progress and milestones
- Proactively offer relevant documentation
- Suggest features based on user's use case
- Provide keyboard shortcuts and tips
- Encourage exploration of features
When to escalate:
- Technical integration issues
- Custom enterprise requirements
- Billing or payment questions
- API or developer support`,
skills: [saasSkill]
});
v3.0.0 Pattern: This demo now uses
LuaAgent to configure the agent’s persona, welcome message, and skills.src/tools/SaaSTools.ts
Copy
import { LuaTool, Data, env } from "lua-cli";
import { z } from "zod";
// 1. Search Documentation (Lua Vector Search)
export class SearchDocsTool implements LuaTool {
name = "search_docs";
description = "Search product documentation";
inputSchema = z.object({
query: z.string()
});
async execute(input: z.infer<typeof this.inputSchema>) {
const results = await Data.search('product_docs', input.query, 5, 0.7);
return {
articles: results.data.map(entry => ({
title: entry.data.title,
content: entry.data.content.substring(0, 300),
url: entry.data.url,
relevance: entry.score
}))
};
}
}
// 2. Create User Account (Your SaaS API)
export class CreateUserTool implements LuaTool {
name = "create_user";
description = "Create new user account";
inputSchema = z.object({
email: z.string().email(),
name: z.string(),
company: z.string(),
plan: z.enum(['starter', 'professional', 'enterprise'])
});
async execute(input: z.infer<typeof this.inputSchema>) {
const apiKey = env('SAAS_API_KEY');
// Call YOUR SaaS API
const response = await fetch('https://your-saas-api.com/api/users', {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(input)
});
const user = await response.json();
return {
userId: user.id,
email: user.email,
setupUrl: `https://your-app.com/setup?token=${user.setupToken}`,
message: `Account created! Check ${user.email} for setup instructions.`
};
}
}
// 3. Get User Usage (Your SaaS API)
export class GetUsageTool implements LuaTool {
name = "get_usage";
description = "Check account usage and limits";
inputSchema = z.object({
userId: z.string()
});
async execute(input: z.infer<typeof this.inputSchema>) {
const apiKey = env('SAAS_API_KEY');
const response = await fetch(
`https://your-saas-api.com/api/users/${input.userId}/usage`,
{
headers: { 'Authorization': `Bearer ${apiKey}` }
}
);
const usage = await response.json();
return {
plan: usage.plan,
apiCalls: `${usage.apiCalls.toLocaleString()} / ${usage.limits.apiCalls.toLocaleString()}`,
storage: `${usage.storage}GB / ${usage.limits.storage}GB`,
users: `${usage.users} / ${usage.limits.users}`,
daysUntilRenewal: usage.daysUntilRenewal
};
}
}
Environment Setup
Copy
# .env
SAAS_API_KEY=your_saas_api_key
SAAS_API_URL=https://your-saas-api.com
Key Features
Custom API
YOUR SaaS backend
Vector Search
Semantic doc search

