import { LuaSkill } from "lua-cli";const coffeeSkill = new LuaSkill({ name: "coffee-shop-skill", description: "Coffee shop assistant with menu, ordering, and loyalty features", context: ` This skill helps customers of Java Junction Coffee Shop. - Use show_menu to display available drinks and food - Use create_order to take customer orders - Use check_loyalty_points to show rewards balance - Use redeem_reward to apply loyalty discounts Always mention daily specials. Ask about size preferences for drinks. `, tools: [ new ShowMenuTool(), new CreateOrderTool(), new CheckLoyaltyTool(), new RedeemRewardTool() ]});
The context field guides the AI’s decision-making. Write it like instructions to a smart assistant:
Copy
context: ` This skill manages customer orders for a coffee shop. Tool Usage: - show_menu: Use when customers ask what's available. Returns drinks and food items. - create_order: Use when taking an order. Confirm items and sizes first. - modify_order: Use to add/remove items. Ask which item to modify. - finalize_order: Use when order is confirmed. Returns total and wait time. Guidelines: - Always ask about size for drinks (small/medium/large) - Mention daily special when showing menu - Confirm total before finalizing - Ask about dietary restrictions for food items`
Optional async function that determines if the tool should be available
Copy
async condition(): Promise<boolean>
Use for premium features, feature flags, channel-specific tools, or user-specific availability.Access the current channel via Lua.request.channel and raw webhook data via Lua.request.webhook?.payload - see Lua API.
In v3.0.0, you configure your entire agent using LuaAgent:
Copy
import { LuaAgent, LuaSkill } from 'lua-cli';// Create your skillconst coffeeSkill = new LuaSkill({ name: "coffee-shop-skill", description: "Coffee shop assistant", tools: [/* your tools */]});// Create agent (v3.0.0 pattern)export const agent = new LuaAgent({ name: "coffee-assistant", persona: `You are a friendly barista at Java Junction Coffee Shop.Your role:- Help customers browse the menu- Take and confirm orders- Suggest popular items- Answer questions about ingredientsCommunication style:- Warm and welcoming- Enthusiastic about coffee- Patient and helpful- Always mention daily specials`, skills: [coffeeSkill]});
New in v3.0.0: Use LuaAgent to configure persona, welcome message, and skills together in one unified configuration.
const dataSkill = new LuaSkill({ name: "data-management-skill", description: "Complete CRUD operations", tools: [ new CreateTool(), new ReadTool(), new UpdateTool(), new DeleteTool(), new SearchTool() ]});
const integrationSkill = new LuaSkill({ name: "external-integrations-skill", description: "Third-party service integrations", tools: [ new SendEmailTool(), // SendGrid new ProcessPaymentTool(), // Stripe new GetWeatherTool(), // Weather API new TrackShipmentTool() // Shipping API ]});