Skip to content

About

A smart AI Travel Agent built with the Google Gemini API. It leverages advanced AI to help users plan trips, find flights and hotels, and generate detailed daily itineraries through natural conversation.

Resources

Stars

12 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

37 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒ AI Travel Agent - Powered by Google Gemini

A comprehensive, multilingual travel planning assistant that creates personalized travel itineraries using Google Gemini AI. Plan your perfect trip with AI-powered recommendations for destinations, hotels, restaurants, activities, flight searches, weather forecasts, and real-time currency conversion.

โœจ Features

๐Ÿค– AI-Powered Planning

  • Smart Itinerary Generation: Create detailed day-by-day travel plans with specific times and activities
  • Personalized Recommendations: Get suggestions based on your budget, interests, and travel style
  • Hotel & Restaurant Suggestions: Receive curated recommendations with direct booking links

๐ŸŒ Multilingual Support

  • Vietnamese & English: Full support for both languages
  • Automatic Translation: Switch languages seamlessly with preserved functionality
  • Localized Currency: Automatic currency conversion (VNฤ/USD)

๐Ÿ’ฌ Interactive Chat

  • Free Chat Mode: Ask any travel-related questions
  • Real-time Responses: Get instant AI-powered answers
  • Context-Aware: Understands follow-up questions and maintains conversation context

โœˆ๏ธ Flight Search Integration

  • Real-time Flight Data: Search for flights using FlightAPI.io
  • Multi-route Support: Search flights between any global destinations
  • Detailed Flight Info: View departure/arrival times, airlines, flight numbers, and status
  • Direct Booking: Links to popular flight booking platforms

๐ŸŒค๏ธ Weather Forecast

  • 5-Day Weather Forecast: Get accurate weather predictions for your destination
  • Visual Weather Cards: Beautiful UI with weather icons and temperature displays
  • Travel Planning: Make informed decisions based on weather conditions
  • Multiple Destinations: Check weather for any city worldwide

๐Ÿ’ฑ Currency Converter

  • Real-time Exchange Rates: Live currency conversion using ExchangeRate-API
  • 160+ Currencies: Support for all major world currencies
  • Accurate Rates: Updated rates from reliable sources
  • Quick Conversion: Instant calculation with user-friendly interface

๐Ÿ“ค Social Sharing

  • Multi-platform Sharing: Share your itinerary on Facebook, Twitter, LinkedIn, and WhatsApp
  • Direct Links: One-click sharing to social media platforms
  • Email Sharing: Share via email with pre-formatted subject and body

๐Ÿ“ฅ Export Options

  • PDF Export: Print-ready travel itineraries with professional formatting
  • HTML Export: Beautifully formatted standalone web pages
  • Markdown Export: Developer-friendly format for documentation
  • Text Export: Simple, readable plain text format

๐Ÿ”— Booking Integration

  • Direct Booking Links: Quick access to Booking.com and Agoda
  • Google Maps Integration: Find locations instantly with embedded maps
  • Restaurant Search: Links to Google Maps and Google Search

๐Ÿ› ๏ธ Technologies

Backend

  • Node.js with Express - Fast, minimalist web framework
  • TypeScript - Type-safe development
  • Google Gemini 2.5 Flash - Latest AI model for travel recommendations
  • FlightAPI.io - Flight schedules and tracking
  • OpenWeatherMap API - Weather forecasts
  • ExchangeRate-API - Real-time currency exchange rates

Frontend

  • Vanilla JavaScript - No framework dependencies, pure performance
  • Responsive CSS - Mobile-first, fully responsive design
  • Modern HTML5 - Semantic markup with accessibility features

๐Ÿ“ฆ Installation

Prerequisites

Setup Steps

  1. Clone the repository:
git clone https://github.com/tridpt/ai-travel-agent-gemini.git
cd ai-travel-agent-gemini/ai-travel-agent
  1. Install dependencies:
npm install
  1. Configure environment variables:
cp .env.example .env
  1. Edit .env file with your API keys:
GEMINI_API_KEY=your_gemini_api_key_here
WEATHER_API_KEY=your_openweathermap_api_key_here
FLIGHT_API_KEY=your_flightapi_key_here
CURRENCY_API_KEY=your_exchangerate_api_key_here
PORT=3000
NODE_ENV=development
  1. Build TypeScript:
npm run build
  1. Run in development mode:
npm run dev
  1. Open your browser:
http://localhost:3000

๐Ÿš€ Usage

1. Planning a Trip

  1. Select "๐Ÿ“‹ Lรชn Kแบฟ Hoแบกch" tab

  2. Fill in your travel details:

    • Destination (optional - AI can suggest)
    • Start and end dates
    • Budget
    • Number of travelers
    • Travel style (Budget/Comfort/Luxury/Adventure/etc.)
    • Interests (Beach, Mountain, Food, Culture, etc.)
    • Transportation preferences
    • Additional requirements
  3. Click "โœจ Tแบกo Lแป‹ch Trรฌnh Du Lแป‹ch"

  4. Review your personalized itinerary

  5. Share or export in your preferred format

2. Free Chat Mode

  1. Select "๐Ÿ’ฌ Chat Tแปฑ Do" tab
  2. Ask questions like:
    • "Recommend 3-star hotels in Hanoi under 1,000,000 VNฤ"
    • "What should I eat in Da Nang?"
    • "Best time to visit Sapa?"
    • "I want a 5-day beach vacation in Vietnam"

3. Flight Search

  1. Select "โœˆ๏ธ Tรฌm Chuyแบฟn Bay" tab
  2. Enter flight details:
    • Departure city/airport code (e.g., HAN, SGN)
    • Destination city/airport code (e.g., DAD, CXR)
    • Departure date (optional)
  3. Click "๐Ÿ” Tรฌm Chuyแบฟn Bay"
  4. View available flights with:
    • Airline names and flight numbers
    • Departure and arrival times
    • Flight duration
    • Aircraft type
    • Direct booking links

4. Weather Forecast

  1. Select "๐ŸŒค๏ธ Thแปi Tiแบฟt" tab
  2. Enter destination city name
  3. Click "๐Ÿ” Xem Thแปi Tiแบฟt"
  4. View 5-day weather forecast with:
    • Temperature (min/max)
    • Weather conditions
    • Humidity percentage
    • Wind speed
    • Weather icons

5. Currency Converter

  1. Select "๐Ÿ’ฑ Chuyแปƒn ฤแป•i Tiแปn Tแป‡" tab
  2. Enter amount and select currencies:
    • From currency (e.g., USD, EUR, JPY)
    • To currency (e.g., VND, THB, SGD)
    • Amount to convert
  3. Click "๐Ÿ’ฑ Chuyแปƒn ฤแป•i"
  4. View real-time conversion with:
    • Current exchange rate
    • Converted amount
    • Last update time

6. Switching Languages

Click the language buttons in the top-right corner:

  • ๐Ÿ‡ป๐Ÿ‡ณ VI - Vietnamese
  • ๐Ÿ‡ฌ๐Ÿ‡ง EN - English

๐Ÿ“ Project Structure

ai-travel-agent/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ app.ts                      # Express server & API routes
โ”‚   โ””โ”€โ”€ services/
โ”‚       โ”œโ”€โ”€ geminiService.ts        # Gemini AI integration
โ”‚       โ”œโ”€โ”€ flightService.ts        # FlightAPI.io integration
โ”‚       โ”œโ”€โ”€ weatherService.ts       # OpenWeatherMap API integration
โ”‚       โ””โ”€โ”€ currencyService.ts      # ExchangeRate-API integration
โ”œโ”€โ”€ public/
โ”‚   โ”œโ”€โ”€ index.html                  # Main UI - Travel planning
โ”‚   โ”œโ”€โ”€ flight.html                 # Flight search page
โ”‚   โ”œโ”€โ”€ currency.html               # Currency converter page
โ”‚   โ”œโ”€โ”€ css/
โ”‚   โ”‚   โ””โ”€โ”€ style.css               # Responsive styling
โ”‚   โ””โ”€โ”€ js/
โ”‚       โ”œโ”€โ”€ main.js                 # Tab switching & markdown rendering
โ”‚       โ”œโ”€โ”€ formHandler.js          # Form validation & API calls
โ”‚       โ”œโ”€โ”€ flightHandler.js        # Flight search logic
โ”‚       โ”œโ”€โ”€ weatherHandler.js       # Weather forecast logic
โ”‚       โ”œโ”€โ”€ currencyHandler.js      # Currency conversion logic
โ”‚       โ”œโ”€โ”€ shareHandler.js         # Social sharing functionality
โ”‚       โ”œโ”€โ”€ translations.js         # i18n support
โ”‚       โ””โ”€โ”€ exportHandler.js        # Export functionality
โ”œโ”€โ”€ .env                            # Environment variables (gitignored)
โ”œโ”€โ”€ .env.example                    # Environment template
โ”œโ”€โ”€ tsconfig.json                   # TypeScript configuration
โ”œโ”€โ”€ package.json                    # Dependencies & scripts
โ””โ”€โ”€ README.md                       # Documentation

๐Ÿ”ง Available Scripts

npm run dev      # Start development server with auto-reload (uses tsx)
npm run build    # Compile TypeScript to JavaScript
npm start        # Run production server (compiled JS)
npm run clean    # Remove build artifacts

๐ŸŒŸ Key Features Explained

Smart Itinerary Generation

The AI creates comprehensive plans including:

  • Daily schedules with specific times and durations
  • Budget breakdowns (transport, accommodation, food, activities)
  • Hotel recommendations with addresses, price ranges, and booking links
  • Restaurant suggestions with specialties and cuisine types
  • Activity suggestions with entrance fees and duration
  • Money-saving tips and local insights
  • Weather information and packing advice
  • Transportation options with estimated costs

Flight Search Integration

Features powered by FlightAPI.io:

  • Real-time flight schedules from airlines worldwide
  • Comprehensive flight data:
    • Flight numbers and airline information
    • Departure/arrival times and airports
    • Flight duration and distance
    • Aircraft type and registration
    • Flight status (scheduled, active, landed, cancelled)
  • Route-based search: Find flights between any two airports
  • Date-specific searches: Filter by departure date
  • Direct booking links to major travel platforms

Weather Forecast System

Powered by OpenWeatherMap API:

  • 5-day forecasts with 3-hour intervals
  • Detailed weather metrics:
    • Temperature (current, min, max)
    • Feels-like temperature
    • Humidity and pressure
    • Wind speed and direction
    • Cloud coverage
  • Weather conditions: clear, cloudy, rain, snow, thunderstorm
  • Visual weather icons for easy understanding
  • Sunrise/sunset times

Currency Conversion

Real-time rates from ExchangeRate-API:

  • 160+ currencies supported worldwide
  • Live exchange rates updated regularly
  • High accuracy from reliable financial sources
  • Base currency flexibility: Convert from any currency
  • Conversion calculator with swap functionality
  • Rate information: Last update timestamp
  • Popular currencies: USD, EUR, GBP, JPY, CNY, VND, THB, SGD, etc.

Social Sharing

Share your itinerary across platforms:

  • Facebook: Post with custom message and preview
  • Twitter: Tweet with hashtags and travel details
  • LinkedIn: Professional sharing with formatted content
  • WhatsApp: Direct messaging to contacts
  • Email: Pre-formatted email templates with itinerary

Export Formats

๐Ÿ“„ PDF

  • Print-ready format with professional styling
  • Includes all booking links and maps
  • Optimized for A4 paper size
  • Perfect for offline reference

๐ŸŒ HTML

  • Standalone web page with embedded CSS
  • Beautiful gradient design
  • Fully responsive for all devices
  • Works offline after download

๐Ÿ“ Markdown

  • GitHub-friendly format
  • Easy to edit and version control
  • Compatible with documentation tools
  • Great for sharing in repositories

๐Ÿ“ƒ Text

  • Plain text format
  • Universal compatibility
  • Easy to share via email/SMS
  • Lightweight and accessible

๐Ÿ“Š API Endpoints

POST /api/chat

Generate travel itinerary or answer questions

Request:

{
  "message": "I want to visit Paris for 5 days with a budget of $2000"
}

Response:

{
  "response": "Here's your personalized Paris itinerary..."
}

GET /api/flights

Search for flights using FlightAPI.io

Query Parameters:

  • departure: Departure airport code (IATA, e.g., HAN, SGN)
  • arrival: Arrival airport code (IATA, e.g., DAD, CXR)
  • date: Departure date (YYYY-MM-DD, optional)

Response:

{
  "flights": [
    {
      "flightNumber": "VN123",
      "airline": "Vietnam Airlines",
      "departure": {
        "airport": "Noi Bai International Airport",
        "code": "HAN",
        "time": "2025-10-15T08:00:00Z"
      },
      "arrival": {
        "airport": "Tan Son Nhat International Airport",
        "code": "SGN",
        "time": "2025-10-15T10:15:00Z"
      },
      "duration": "2h 15m",
      "aircraft": "Airbus A321",
      "status": "scheduled"
    }
  ]
}

GET /api/weather

Get weather forecast using OpenWeatherMap API

Query Parameters:

  • city: City name (e.g., Hanoi, Da Nang, Ho Chi Minh City)

Response:

{
  "city": "Hanoi",
  "country": "VN",
  "forecast": [
    {
      "date": "2025-10-06",
      "temp": 28,
      "tempMin": 24,
      "tempMax": 31,
      "feelsLike": 30,
      "description": "Partly cloudy",
      "icon": "02d",
      "humidity": 70,
      "pressure": 1013,
      "windSpeed": 15,
      "windDirection": 180,
      "clouds": 40
    }
  ]
}

GET /api/currency

Convert currency using ExchangeRate-API

Query Parameters:

  • from: Source currency code (ISO 4217, e.g., USD, EUR, VND)
  • to: Target currency code (ISO 4217, e.g., VND, THB, JPY)
  • amount: Amount to convert (number)

Response:

{
  "from": "USD",
  "to": "VND",
  "amount": 100,
  "rate": 24500.50,
  "result": 2450050,
  "lastUpdate": "2025-10-06T10:30:00Z"
}

๐Ÿ› Troubleshooting

Server won't start

# Check if port 3000 is in use
netstat -ano | findstr :3000  # Windows
lsof -i :3000                 # macOS/Linux

# Kill the process if needed
taskkill /PID <PID> /F        # Windows
kill -9 <PID>                 # macOS/Linux

# Install dependencies
npm install

# Check Node version (18+ required)
node --version

API Key Issues

# Verify all API keys are set
type .env  # Windows
cat .env   # macOS/Linux

# Test API keys:
# - Gemini: https://aistudio.google.com/app/apikey
# - OpenWeatherMap: https://openweathermap.org/api
# - FlightAPI.io: https://www.flightapi.io/
# - ExchangeRate-API: https://app.exchangerate-api.com/

Build Errors

# Clean and rebuild
npm run clean
npm run build

# Check TypeScript version
npx tsc --version

# Reinstall dependencies
rm -rf node_modules package-lock.json
npm install

API Rate Limits

CORS Errors

  • Make sure backend is running on port 3000
  • Check frontend is loading from same origin
  • Verify cors middleware is enabled in app.ts
  • Clear browser cache and cookies

Flight Search Issues

  • Verify airport codes are valid IATA codes (3 letters)
  • Check date format is YYYY-MM-DD
  • Ensure FlightAPI.io API key is active
  • Some routes may not have data available

Currency Conversion Issues

  • Use valid ISO 4217 currency codes
  • Check internet connection
  • Verify ExchangeRate-API key is active
  • Some exotic currencies may not be supported

๐Ÿ”’ Security Notes

  • โœ… Never commit .env file to Git
  • โœ… Keep all API keys private and secure
  • โœ… Use environment variables for all secrets
  • โœ… Enable rate limiting for production use
  • โœ… Validate all user inputs on backend
  • โœ… Sanitize data before displaying
  • โœ… Use HTTPS in production
  • โœ… Implement authentication for user accounts
  • โœ… Set up CORS properly
  • โœ… Keep dependencies updated

๐ŸŽจ Customization

Changing Colors

Edit public/css/style.css:

/* Primary gradient */
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

/* Change to your colors */
background: linear-gradient(135deg, #YOUR_COLOR_1 0%, #YOUR_COLOR_2 100%);

Adding New Languages

Edit public/js/translations.js:

const translations = {
    vi: { /* Vietnamese */ },
    en: { /* English */ },
    fr: { /* Add French */ },
    es: { /* Add Spanish */ },
    ja: { /* Add Japanese */ }
};

Customizing AI Prompts

Edit public/js/formHandler.js in the buildPrompt() method:

buildPrompt() {
    return `You are a professional travel agent. Create a detailed itinerary for...`;
}

Adding New API Integrations

  1. Create new service in src/services/ (e.g., hotelService.ts)
  2. Add API endpoint in src/app.ts
  3. Create handler in public/js/ (e.g., hotelHandler.js)
  4. Update UI in HTML files
  5. Add translations in translations.js

๐Ÿค Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Contribution Guidelines

  • Follow existing code style and conventions
  • Add comments for complex logic
  • Update documentation (README, JSDoc)
  • Test thoroughly before submitting
  • Write meaningful commit messages
  • Include screenshots for UI changes
  • Add unit tests if applicable

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ‘ค Author

Tran Duc Tri

๐Ÿ™ Acknowledgments

๐Ÿ”ฎ Roadmap & Future Enhancements

Completed โœ…

  • Flight search integration with FlightAPI.io
  • Weather API integration with OpenWeatherMap
  • Currency conversion with ExchangeRate-API
  • Social sharing features (Facebook, Twitter, LinkedIn, WhatsApp)
  • Multiple export formats (PDF, HTML, Markdown, Text)
  • Multilingual support (Vietnamese, English)
  • Responsive design for all devices

In Progress ๐Ÿšง

  • User authentication system (JWT)
  • Save and manage multiple trips
  • Trip collaboration features
  • Email notifications for price changes

Planned ๐Ÿ“‹

  • Hotel price comparison across multiple booking sites
  • Mobile app (React Native)
  • Interactive map view of itinerary (Google Maps API)
  • Calendar export (iCal format)
  • Hotel price alerts and notifications
  • Travel blog integration
  • Photo upload and gallery
  • Expense tracking and budget management
  • Travel insurance recommendations
  • Visa requirements checker
  • Local transportation guide (buses, trains, taxis)
  • Restaurant reservations integration
  • Activity booking system
  • Travel companion matching
  • Offline mode support

๐Ÿ“ž Support

If you encounter any issues or have questions:

  1. Check the Troubleshooting section
  2. Search existing GitHub Issues
  3. Create a new issue with:
    • Clear title describing the problem
    • Detailed description of what happened
    • Steps to reproduce the issue
    • Expected behavior vs actual behavior
    • Screenshots or error messages (if applicable)
    • Environment details:
      • OS (Windows/macOS/Linux)
      • Node.js version
      • Browser and version
      • Package versions

Getting Help

๐Ÿ“ˆ Performance

  • Initial Load: < 2 seconds
  • API Response: < 1 second average
  • Build Size: ~500KB (minified)
  • Lighthouse Score: 95+ on all metrics
  • Mobile Performance: Optimized for 3G networks

๐ŸŒ Browser Support

Browser Version Status
Chrome 90+ โœ… Fully Supported
Firefox 88+ โœ… Fully Supported
Safari 14+ โœ… Fully Supported
Edge 90+ โœ… Fully Supported
Opera 76+ โœ… Fully Supported
IE 11 - โš ๏ธ Limited Support

๐Ÿ“ฑ Mobile Support

  • โœ… iOS Safari 14+
  • โœ… Chrome Mobile 90+
  • โœ… Samsung Internet 13+
  • โœ… Firefox Mobile 88+

โญ If you found this project helpful, please give it a star!

๐Ÿ› Found a bug? Report it here

๐Ÿ’ก Have a feature idea? Suggest it here

๐Ÿ”” Stay updated: Watch this repo

Made with โค๏ธ and โ˜• by Tran Duc Tri

About

A smart AI Travel Agent built with the Google Gemini API. It leverages advanced AI to help users plan trips, find flights and hotels, and generate detailed daily itineraries through natural conversation.

Resources

Stars

12 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages