text
stringlengths
0
59.1k
agents: {
agent,
},
server: honoServer({
configureApp: (app) => {
// WhatsApp webhook verification (GET)
app.get("/webhook/whatsapp", async (c) => {
return handleWhatsAppVerification(c);
});
// WhatsApp webhook message handler (POST)
app.post("/webhook/whatsapp", async (c) => {
return handleWhatsAppMessage(c, agent);
});
// Health check endpoint
app.get("/health", (c) => {
return c.json({
status: "healthy",
service: "whatsapp-ordering-agent",
timestamp: new Date().toISOString(),
});
});
},
}),
logger,
voltOpsClient: new VoltOpsClient({
publicKey: process.env.VOLTAGENT_PUBLIC_KEY || "",
secretKey: process.env.VOLTAGENT_SECRET_KEY || "",
}),
});
```
**Key points:**
- `honoServer` provides lightweight HTTP handling for webhook integration
- `/webhook/whatsapp` handles both Meta verification and message processing
- `/health` endpoint enables uptime monitoring and load balancer checks
- VoltOps client integration for observability and debugging
- Custom server configuration allows WhatsApp-specific routing
- Async handlers support concurrent message processing
## Running the AI Agent
Once deployed, your AI agent handles natural conversations.
![agent-works](https://cdn.voltagent.dev/examples/with-whatsapp/agent-work.png)
Here are example interactions:
### Example Conversation 1: First-time Order
```
Customer: Hi
Agent: Welcome to our restaurant! 🍕 I'm here to help you order delicious food. Would you like to see our menu?
Customer: Yes please
Agent: Here's our menu:
**Pizza**
• Margherita - Fresh tomatoes, mozzarella, basil ($12.99)
• Pepperoni - Pepperoni, mozzarella, tomato sauce ($14.99)
**Burgers**
• Classic Burger - Beef patty, lettuce, tomato, onion ($10.99)
• Cheeseburger - Beef patty, cheese, lettuce, tomato ($11.99)
**Drinks**
• Coke - Coca-Cola 330ml ($2.99)
• Water - Mineral water 500ml ($1.99)
What would you like to order?
Customer: I'll have 2 pepperoni pizzas and a coke
Agent: Great choice! I've added:
- 2x Pepperoni Pizza ($29.98)
- 1x Coke ($2.99)
Your current total is $32.97. Would you like anything else?
Customer: No that's all
Agent: Perfect! Please provide your delivery address.
Customer: 123 Main Street, Apt 4B
Agent: Thank you! Order #1057 confirmed!
📍 Delivery to: 123 Main Street, Apt 4B
💰 Total: $32.97
⏰ Estimated delivery: 30-45 minutes
We'll notify you when your order is on the way!
```
### Example Conversation 2: Checking Order Status
```
Customer: What's the status of my order?
Agent: Let me check your recent orders...
I found your order #1057: