text
stringlengths
0
59.1k
price NUMERIC(10, 2) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX idx_menu_items_category ON public.menu_items(category);
```
### Orders Table
```sql
CREATE TABLE public.orders (
id SERIAL PRIMARY KEY,
customer_phone VARCHAR(20) NOT NULL,
customer_address TEXT NOT NULL,
total_amount NUMERIC(10, 2) NOT NULL,
status VARCHAR(20) NOT NULL DEFAULT 'preparing',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX idx_orders_status ON public.orders(status);
```
### Order Items Table
```sql
CREATE TABLE public.order_items (
id SERIAL PRIMARY KEY,
order_id INTEGER REFERENCES orders(id) ON DELETE CASCADE,
menu_item_id INTEGER REFERENCES menu_items(id) ON DELETE CASCADE,
quantity INTEGER NOT NULL DEFAULT 1,
price NUMERIC(10, 2) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX idx_order_items_order_id ON public.order_items(order_id);
CREATE INDEX idx_order_items_menu_item_id ON public.order_items(menu_item_id);
```
### Sample Menu Data
```sql
INSERT INTO menu_items (category, name, description, price) VALUES
('Pizza', 'Margherita', 'Fresh tomatoes, mozzarella, basil', 12.99),
('Pizza', 'Pepperoni', 'Pepperoni, mozzarella, tomato sauce', 14.99),
('Burger', 'Classic Burger', 'Beef patty, lettuce, tomato, onion', 10.99),
('Burger', 'Cheeseburger', 'Beef patty, cheese, lettuce, tomato', 11.99),
('Drinks', 'Coke', 'Coca-Cola 330ml', 2.99),
('Drinks', 'Water', 'Mineral water 500ml', 1.99);
```
#### Supabase Client Configuration
The example already includes a `lib/supabase.ts` file that initializes the Supabase client:
```typescript
import { createClient } from "@supabase/supabase-js";
// Supabase configuration - add these to your .env file
const supabaseUrl = process.env.SUPABASE_URL || "";
const supabaseAnonKey = process.env.SUPABASE_ANON_KEY || "";
export const supabase = createClient(supabaseUrl, supabaseAnonKey);
```
This file provides a Supabase client instance that all the tools use to interact with the database. Make sure your environment variables are properly set in the `.env` file.
#### Start the development server
```bash
npm run dev
```
Once your server starts successfully, you see:
```bash
════════════════════════════════════════════
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