Trip Tasker is an AI-powered travel planning application built on Cloudflare's platform. It helps users discover destinations, create detailed itineraries, find local attractions, check weather, and schedule trip-related tasks using natural language conversation.
This project meets all Cloudflare AI assignment requirements:
- β
LLM: Uses Llama 3.3 70B (
@cf/meta/llama-3.3-70b-instruct-fp8-fast) via Cloudflare Workers AI. - β
Workflow/Coordination: Implemented using Durable Objects (
TripPlanneragent) and specialized API routing inserver.ts. - β User Input: Modern React chat interface with real-time streaming and a proactive welcome greeting.
- β
Memory/State: Persistent state management via Durable Object
ctx.storage(KV) for saved trips and Agent state API for session memory.
- π¬ Interactive Chat Interface: Natural language conversation with the AI travel assistant
- π Destination Discovery: Search for travel destinations based on keywords and interests
- π Itinerary Planning: Generate day-by-day trip plans for any destination
- πΊοΈ Places of Interest: Find must-see attractions and landmarks in specific cities
- π€οΈ Weather Information: Get weather updates for travel destinations (with human confirmation)
- πΎ Persistent Memory: Reliable save/load system for trip plans using Durable Object storage.
- π Dark/Light Theme: Modern UI with theme switching.
- β‘ Real-time Streaming: Live response streaming for natural conversation flow.
- π οΈ Auto-Repair Logic: Defensive client-side logic to ensure legacy trip data never crashes the UI.
This application is built on a distributed Cloudflare architecture, leveraging the "Brain & Routing" pattern to separate AI logic from web interfaces.
- Role: Serves as the primary intelligence engine for itinerary generation and destination discovery.
- What it does: Parses natural language, invokes specialized travel tools, and generates human-like responses in real-time.
- Model: Llama 3.3 70B Instruct (
@cf/meta/llama-3.3-70b-instruct-fp8-fast). - Location: Implementation found in
src/agent.ts:L60-L63. It uses theworkers-ai-providerto connect directly to Cloudflare's GPU network.
- Role: Manages the state and provides consistent coordination for the AI agent.
- What it does: Acts as a stateful entity that lives on the Cloudflare edge. It maintains the AI's "short-term memory" (conversation history) and handles complex RPC operations like "Save Chat" and "Restore History."
- Location:
- The coordination logic is in the
TripPlannerclass insrc/agent.ts. - The interface and routing logic that connects the web to this coordinator is in
src/server.ts.
- The coordination logic is in the
- Role: The primary entry point for users to interact with the system.
- What it does: Provides a real-time, responsive chat interface built with React. It handles message streaming, manages the "Saved Trips" sidebar, and processes tool confirmations (e.g., confirming before a weather lookup).
- Location:
- Main UI logic:
src/app.tsx. - Reusable components:
src/components/. - Global styles and design system:
src/index.css.
- Main UI logic:
- Role: Ensures that user data persists across browser sessions and AI restarts.
- What it does:
- Saved Trips: Persists user itineraries in Durable Object
ctx.storage(KV-based). - AI Memory: Synchronizes the backend AI brain with the frontend message history using a specialized restoration API.
- Saved Trips: Persists user itineraries in Durable Object
- Location:
- Persistence logic:
src/agent.ts(methods likesaveChatAsTripandrestoreChat). - API endpoints for memory sync: Found in
src/server.tsunder/api/trip-plans/saveand/api/trip-plans/restore.
- Persistence logic:
- Node.js 18+ and npm
- Cloudflare account (free tier works)
- Wrangler CLI (installed via npm)
git clone <your-repo-url>
cd cf_ai_triptaskernpm installThe project uses Cloudflare Workers AI and Durable Objects. To ensure you have a clean authentication state, please follow these steps:
- Logout of any existing sessions:
npx wrangler logout - Login to your Cloudflare account:
Follow the browser prompts to authorize Wrangler.
npx wrangler login
Start the development environment:
npm run devIMPORTANT: Once the command is running, click the local link provided in your terminal (typically http://localhost:5173) to open the Trip Tasker interface.
This will concurrently:
- Start the Vite frontend server.
- Start the Cloudflare Worker/Durable Object dev server (Miniflare/Wrangler).
- Handle AI requests via Cloudflare Workers AI.
Deploy the worker and the frontend:
npm run deployThis will:
- Build the frontend (React app)
- Deploy the Worker and Durable Objects
- Publish to Cloudflare Pages
User: "Find me beach destinations"
Trip Tasker: [Searches and suggests beach destinations like Santorini, Bali, etc.]
User: "Plan a 5-day trip to Tokyo"
Trip Tasker: [Generates day-by-day itinerary with morning, afternoon, and evening activities]
User: "What are the best places to visit in Paris?"
Trip Tasker: [Lists popular attractions like Eiffel Tower, Louvre Museum, etc.]
User: "Remind me to book flights in 2 hours"
Trip Tasker: [Schedules a delayed task that will execute in 2 hours]
User: "Schedule a daily reminder to check visa requirements"
Trip Tasker: [Creates a recurring cron task]
cf_ai_triptasker/
βββ src/
β βββ app.tsx # React chat UI component
β βββ server.ts # TripPlanner Durable Object agent
β βββ tools.ts # AI tool definitions (search, itinerary, etc.)
β βββ utils.ts # Helper functions for message processing
β βββ styles.css # Global styles and theme
β βββ components/ # Reusable UI components
βββ public/ # Static assets
βββ wrangler.jsonc # Cloudflare Workers configuration
βββ package.json # Dependencies and scripts
βββ README.md # This file
βββ PROMPTS.md # AI prompts used during development
- Contains the
TripPlannerclass that extendsAIChatAgent - Handles chat messages, tool execution, and state management
- Implements database operations for trip plans and user preferences
- Uses Llama 3.3 via Workers AI provider
- Defines all available AI tools:
searchDestinations: Find travel destinationsgetItinerary: Generate day-by-day plansgetPlacesOfInterest: Find attractionsgetWeatherInformation: Weather lookup (requires confirmation)getLocalTime: Get local time for a locationscheduleTask: Schedule reminders and tasksgetScheduledTasks: List all scheduled taskscancelScheduledTask: Cancel a scheduled task
- React component for the chat interface
- Connects to the Durable Object agent via
useAgenthook - Handles message rendering, tool confirmations, and user input
- Implements theme switching and UI state management
- Cloudflare Workers configuration
- Defines Durable Object bindings for
TripPlanner - Configures AI binding for Workers AI
- Sets up SQLite migrations for the agent
Run the test suite:
npm testRun code quality checks:
npm run checkThis runs:
- Prettier (code formatting)
- Biome (linting)
- TypeScript (type checking)
This project was developed with AI assistance. All prompts used during development are documented in PROMPTS.md.
- Cloudflare Agents Documentation
- Cloudflare Workers AI
- Cloudflare Durable Objects
- Cloudflare Pages
- AI SDK Documentation
MIT
Built using:
- Cloudflare Agents platform
- Cloudflare Workers AI (Llama 3.3)
- React and Vite
- AI SDK by Vercel