Skip to content
  • SiteMap
  • Our Services
  • Frequently Asked Questions (FAQ)
  • Support
  • About Us

UpdateGadh

Update Your Skills.

  • Home
  • Projects
    •  Blockchain projects
    • Python Project
    • Data Science
    •  Ai projects
    • Machine Learning
    • PHP Project
    • React Projects
    • Java Project
    • SpringBoot
    • JSP Projects
    • Java Script Projects
    • Code Snippet
    • Free Projects
  • Tutorials
    • Ai
    • Machine Learning
    • Advance Python
    • Advance SQL
    • DBMS Tutorial
    • Data Analyst
    • Deep Learning Tutorial
    • Data Science
    • Nodejs Tutorial
  • Blog
  • Contact us
  • Toggle search form
AI Travel Chatbot in Python

AI Travel Chatbot in Python [Python +Ai]

Posted on March 24, 2025January 14, 2026 By Updategadh No Comments on AI Travel Chatbot in Python [Python +Ai]

AI Travel Chatbot in Python

Introduction

Traveling is exciting, but planning a trip can often feel overwhelming. From finding the best destinations to booking hotels, flights, and activities — the process can take a lot of time. To solve this problem, the AI Travel Chatbot was developed using Python.

This chatbot acts like a personal travel assistant. It helps users get quick answers to travel-related questions, suggests destinations, and guides them with essential information like weather, hotel options, and transportation. For students, it’s an excellent project to understand Natural Language Processing (NLP), Machine Learning, and Python integration with real-world applications.

1. Imports & API Setup

import streamlit as st
import wikipedia
import google.generativeai as genai
import urllib.parse
  • streamlit: For creating the web app.
  • wikipedia: To fetch a short city description.
  • google.generativeai: To use Gemini API for travel suggestions.
  • urllib.parse: Helps create safe URLs for Google Maps links.

API Configuration:

genai.configure(api_key="")  # Add your Gemini API key
  • You need to sign up at Google AI Studio to get your API key.

2. Helper Function – Google Maps Link

def get_maps_link(place, city):
    query = urllib.parse.quote(f"{place} {city}")
    return f"https://www.google.com/maps/search/?api=1&query={query}"
  • Combines place + city → formats into a Google Maps search link.
  • Ensures no spaces/special characters break the link.

3. Get City Description (Wikipedia)

def get_city_description(city):
    try:
        summary = wikipedia.summary(city, sentences=3, auto_suggest=False)
        return summary
    except wikipedia.DisambiguationError as e:
        try:
            summary = wikipedia.summary(e.options[0], sentences=3, auto_suggest=False)
            return summary
        except:
            return "❗ Couldn't find a proper description for this city."
    except:
        return "❗ Couldn't find a proper description for this city."

4. Get Travel Info

def get_travel_info_gemini(city):
    prompt = f"""Provide concise travel details for {city} including:
    1. Three famous places to visit
    2. Three popular local foods
    3. Three best malls
    4. Three recommended restaurants
    Only give names in bullet points, no extra description."""
    
    model = genai.GenerativeModel('models')
    response = model.generate_content(prompt)
    return response.text
  • Sends a prompt to Gemini asking for travel data.
  • Gemini replies with bullet-pointed names of places, foods, malls, and restaurants.

5. Stylish HTML + CSS for UI

st.markdown("""
    <style>
        .title { ... }
        .section-header { ... }
        .item { ... }
        .map-link { ... }
        .description { ... }
    </style>
""", unsafe_allow_html=True)
  • Custom CSS for:
    • Title (.title)
    • Headers like “Famous Places” (.section-header)
    • Each item row (.item)
    • Google Maps link styling (.map-link)
    • Description paragraph (.description)
  • Why use this? → Streamlit’s default look is basic, so this gives your app a clean, modern, and colorful design.
AI Travel Chatbot in Python
AI Travel Chatbot in Python
AI Travel Chatbot in Python
AI Travel Chatbot in Python
AI Travel Chatbot in Python
AI Travel Chatbot in Python

6. Main App UI

city = st.text_input("Enter City Name")
if st.button("Get Travel Info"):
    ...
  • Input field for the city name.
  • Button triggers all the logic (fetch Wikipedia + Gemini info + display results).

7. Parsing Gemini Response

lines = [line.strip('-• ').strip() for line in details.split('\n') if line.strip()]
current_section = None
for line in lines:
    ...
  • Splits the Gemini response line by line.
  • Filters each line into one of the 4 lists:
    • famous_places, foods, malls, restaurants
  • Limits to 3 items per list (skips extras).
  • If fewer than 3 items are found → fills with N/A later.

8. Reusable Display Function

def display_table(title, items, icon):
    st.markdown(f'<div class="section-header">{icon} {title}</div>', unsafe_allow_html=True)
    if items:
        for item in items:
            link = get_maps_link(item, city)
            st.markdown(f'<div class="item">🔹 <b>{item}</b> | <a class="map-link" href="{link}" target="_blank">Open in Google Maps</a></div>', unsafe_allow_html=True)
    else:
        for _ in range(3):
            st.markdown(f'<div class="item">🔹 <i>N/A</i></div>', unsafe_allow_html=True)
  • Displays each section (title + items + Google Maps links).
  • Repeats for all 4 categories.
  • Items always show as 3 lines (with links or “N/A”).

9. Explore City on Google Maps

st.markdown(f'<div class="section-header">🌐 Explore {city.title()} on <a class="map-link" href="{get_maps_link(city, "")}" target="_blank">Google Maps</a></div>', unsafe_allow_html=True)
  • General Google Maps link to explore the whole city.

 

Buy Source Code
Post Views: 1,740
Python Projects Tags:ai travel chatbot in python example, ai travel chatbot in python github, best ai travel chatbot in python, chatbot using llm github, llm chatbot project, llm rag chatbot github, travel agent chatbot, travel chatbot github python, travel chatbot project chatgpt, travel guide chatbot github

Post navigation

Previous Post: Restaurant Management System in Python (Django) with Source Code
Next Post: Python Tkinter Radiobutton

More Related Articles

Best Streamlit Bank Management System in Python Best Streamlit Bank Management System in Python Python Projects
Library Management System Library Management System using Python on Django Framework Python Projects
Learning Management System using Django Best Learning Management System (LMS) using Django — Course, Quiz, Results & Payments Python Projects

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may also like

  1. Food Management System in Python [Django Framework ]
  2. File Sharing Website Using Python in Django
  3. Email Spam Detection Web App with Flask
  4. Real-time Sales Prediction Using Flask and Scikit-Learn
  5. Best Complaint Management System Using Python Django Web Application
  6. Pharmacy Management System Project using Python Django

Most Viewed Posts

  1. Top Large Language Models in 2025
  2. Online Shopping System using PHP, MySQL with Free Source Code
  3. login form in php and mysql , Step-by-Step with Free Source Code
  4. Flipkart Clone using PHP And MYSQL Free Source Code
  5. News Portal Project in PHP and MySql Free Source Code
  6. Blog Site In PHP And MYSQL With Source Code || Best Project
  7. User Login & Registration System Using PHP and MySQL Free Code
  8. Top 10 Final Year Project Ideas in Python
  9. Online Bike Rental Management System Using PHP and MySQL
  10. E learning Website in php with Free source code
  • AI
  • ASP.NET
  • Blockchain
  • ChatCPT
  • code Snippets
  • Collage Projects
  • Data Science Project
  • Data Science Tutorial
  • DBMS Tutorial
  • Deep Learning Tutorial
  • Final Year Projects
  • Free Projects
  • How to
  • html
  • Interview Question
  • Java Notes
  • Java Project
  • Java Script Notes
  • JAVASCRIPT
  • Javascript Project
  • JSP JAVA(J2EE)
  • Machine Learning Project
  • Machine Learning Tutorial
  • MySQL Tutorial
  • Node.js Tutorial
  • PHP Project
  • Portfolio
  • Python
  • Python Interview Question
  • Python Projects
  • PythonFreeProject
  • React Free Project
  • React Projects
  • Spring boot
  • SQL Tutorial
  • TOP 10
  • Uncategorized
  • Blood Bank Management System Project in PHP & MySQL (With Source Code)
  • Railway Management System in PHP and MySQL
  • Agentic RAG AI System Using Python – Complete Final Year Project Guide
  • AI-Powered Online Examination System with Face Detection Using PHP & MySQL
  • Real-Time Medical Queue & Appointment System with Django

Most Viewed Posts

  • Top Large Language Models in 2025 (8,641)
  • Online Shopping System using PHP, MySQL with Free Source Code (5,290)
  • login form in php and mysql , Step-by-Step with Free Source Code (4,943)

Copyright © 2026 UpdateGadh.

Powered by PressBook Green WordPress theme