text
stringlengths
0
59.1k
VOLTAGENT SERVER STARTED SUCCESSFULLY
════════════════════════════════════════════
βœ“ HTTP Server: http://localhost:3141
VoltOps Platform: https://console.voltagent.dev
════════════════════════════════════════════
[VoltAgent] All packages are up to date
```
The [VoltOps Platform](https://console.voltagent.dev) link opens automatically, allowing you to interact with and debug your WhatsApp AI agent in real-time.
![List tool](https://cdn.voltagent.dev/examples/with-whatsapp/1-start-server.png)
### Understanding the Agent Architecture
Let's explore the WhatsApp order AI agent components and understand how they work together.
The WhatsApp order AI agent includes three essential tools:
1. **List Menu Items** - Fetches available food items from the database
2. **Create Order** - Processes and saves customer orders
3. **Check Order Status** - Retrieves order tracking information
**Understanding VoltAgent Tools:** In VoltAgent, tools are the actions your agent can perform. Think of them as functions that your AI agent can call when needed. Each tool has a single responsibility, validates inputs with Zod, returns structured responses, and surfaces clear errors so runtime behaviour stays predicta...
Let's examine each tool:
### List Menu Items Tool
This tool retrieves available menu items from the database:
<details>
<summary>View code</summary>
```typescript
import { createTool } from "@voltagent/core";
import { z } from "zod";
import { supabase } from "../../lib/supabase";
export const listMenuItemsTool = createTool({
name: "listMenuItems",
description: "Lists all menu items from the Supabase database",
parameters: z.object({
limit: z.number().optional().default(100).describe("Number of items to fetch"),
offset: z.number().optional().default(0).describe("Number of items to skip"),
}),
execute: async ({ limit, offset }) => {
try {
const { data, error } = await supabase
.from("menu_items")
.select("*")
.range(offset, offset + limit - 1)
.order("id", { ascending: true });
if (error) {
throw new Error(`Failed to fetch menu items: ${error.message}`);
}
return {
success: true,
data: data || [],
count: data?.length || 0,
message: `Successfully fetched ${data?.length || 0} menu items`,
};
} catch (error) {
return {
success: false,
error: error instanceof Error ? error.message : "Unknown error occurred",
data: [],
};
}
},
});
```
</details>
![List tool](https://cdn.voltagent.dev/examples/with-whatsapp/list-tool.png)
**What this tool does:** Fetches menu items from Supabase with optional pagination, returning a structured response that keeps error handling and schema validation in one place so the agent can safely show the menu whenever a conversation starts.
## Create Order Tool
This tool processes and saves customer orders to the database:
<details>
<summary>View code</summary>
```typescript
import { createTool } from "@voltagent/core";
import { z } from "zod";
import { supabase } from "../../lib/supabase";
export const createOrderTool = createTool({
name: "createOrder",
description: "Creates a new order with the items and delivery address from working memory",
parameters: z.object({
items: z
.array(
z.object({