AI Agent for Campus Navigation: Building Tour, Room Finding, and Event Discovery
Build a campus navigation AI agent that provides building directions, helps find rooms, integrates with event calendars, and delivers facility information to students, staff, and visitors.
Navigating a Complex Campus
University campuses are small cities. With dozens of buildings, multiple floors, renamed halls, construction detours, and hundreds of events, even returning students get lost. A campus navigation agent serves students, faculty, and visitors by providing directions, locating rooms, surfacing upcoming events, and sharing facility details like operating hours and accessibility information.
Campus Data Model
The foundation is a structured representation of buildings, rooms, and events.
from dataclasses import dataclass, field
from enum import Enum
from datetime import datetime, time
from typing import Optional
class BuildingType(Enum):
ACADEMIC = "academic"
ADMINISTRATIVE = "administrative"
RESIDENTIAL = "residential"
ATHLETIC = "athletic"
LIBRARY = "library"
DINING = "dining"
PARKING = "parking"
class AccessibilityFeature(Enum):
ELEVATOR = "elevator"
RAMP = "ramp"
AUTOMATIC_DOORS = "automatic_doors"
BRAILLE_SIGNAGE = "braille_signage"
ACCESSIBLE_RESTROOM = "accessible_restroom"
@dataclass
class GeoPoint:
latitude: float
longitude: float
@dataclass
class Building:
building_id: str
name: str
short_name: str
building_type: BuildingType
location: GeoPoint
floors: int
address: str
accessibility: list[AccessibilityFeature] = field(
default_factory=list
)
departments: list[str] = field(default_factory=list)
open_time: Optional[time] = None
close_time: Optional[time] = None
image_url: str = ""
notes: str = ""
@dataclass
class Room:
room_id: str
building_id: str
floor: int
room_number: str
room_type: str # lecture hall, lab, office, etc.
capacity: int = 0
equipment: list[str] = field(default_factory=list)
@dataclass
class CampusEvent:
event_id: str
title: str
description: str
building_id: str
room_id: Optional[str]
start_time: datetime
end_time: datetime
category: str
organizer: str
is_public: bool = True
Direction Calculator
For campus navigation, we need a function that calculates walking directions between buildings.
See AI Voice Agents Handle Real Calls
Book a free demo or calculate how much you can save with AI voice automation.
import math
BUILDINGS: dict[str, Building] = {}
ROOMS: dict[str, Room] = {}
EVENTS: list[CampusEvent] = []
# Pre-defined walking paths between building pairs
WALKING_PATHS: dict[tuple[str, str], list[str]] = {}
def haversine_distance(p1: GeoPoint, p2: GeoPoint) -> float:
"""Calculate distance in meters between two GPS coordinates."""
R = 6371000 # Earth radius in meters
lat1, lat2 = math.radians(p1.latitude), math.radians(p2.latitude)
dlat = math.radians(p2.latitude - p1.latitude)
dlon = math.radians(p2.longitude - p1.longitude)
a = (math.sin(dlat / 2) ** 2
+ math.cos(lat1) * math.cos(lat2)
* math.sin(dlon / 2) ** 2)
return R * 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
def get_directions(
from_building_id: str, to_building_id: str
) -> dict:
from_bld = BUILDINGS.get(from_building_id)
to_bld = BUILDINGS.get(to_building_id)
if not from_bld or not to_bld:
return {"error": "Building not found"}
distance = haversine_distance(from_bld.location, to_bld.location)
walk_minutes = round(distance / 80) # ~80 m/min walking
path_key = (from_building_id, to_building_id)
steps = WALKING_PATHS.get(
path_key,
[f"Head toward {to_bld.name} from {from_bld.name}"]
)
return {
"from": from_bld.name,
"to": to_bld.name,
"distance_meters": round(distance),
"walking_minutes": max(1, walk_minutes),
"steps": steps,
"destination_address": to_bld.address,
}
Agent Tools
from agents import Agent, function_tool, Runner
import json
@function_tool
def find_building(query: str) -> str:
"""Find a building by name, short name, or department."""
query_lower = query.lower()
matches = []
for bld in BUILDINGS.values():
if (query_lower in bld.name.lower()
or query_lower in bld.short_name.lower()
or any(query_lower in d.lower()
for d in bld.departments)):
matches.append({
"id": bld.building_id,
"name": bld.name,
"type": bld.building_type.value,
"floors": bld.floors,
"departments": bld.departments,
"hours": (
f"{bld.open_time}-{bld.close_time}"
if bld.open_time else "24/7"
),
"accessibility": [
a.value for a in bld.accessibility
],
})
return json.dumps(matches) if matches else "No buildings found."
@function_tool
def find_room(building_name: str, room_number: str) -> str:
"""Find a specific room within a building."""
for room in ROOMS.values():
bld = BUILDINGS.get(room.building_id)
if not bld:
continue
if (building_name.lower() in bld.name.lower()
and room_number in room.room_number):
return json.dumps({
"building": bld.name,
"room": room.room_number,
"floor": room.floor,
"type": room.room_type,
"capacity": room.capacity,
"equipment": room.equipment,
"directions": f"Enter {bld.name}, go to floor "
f"{room.floor}, room {room.room_number}",
})
return "Room not found. Check the building name and room number."
@function_tool
def get_upcoming_events(
category: str = "", building_id: str = ""
) -> str:
"""Get upcoming campus events, optionally filtered."""
now = datetime.now()
upcoming = []
for event in EVENTS:
if event.start_time < now or not event.is_public:
continue
if category and category.lower() not in event.category.lower():
continue
if building_id and event.building_id != building_id:
continue
bld = BUILDINGS.get(event.building_id)
upcoming.append({
"title": event.title,
"when": event.start_time.strftime("%B %d at %I:%M %p"),
"where": bld.name if bld else "TBD",
"category": event.category,
"organizer": event.organizer,
})
upcoming.sort(key=lambda e: e["when"])
return json.dumps(upcoming[:10]) if upcoming else "No upcoming events."
campus_agent = Agent(
name="Campus Navigator",
instructions="""You are a campus navigation assistant. Help
people find buildings, locate rooms, get walking directions,
and discover campus events. Always mention accessibility
features when giving directions. If someone seems lost,
ask where they are starting from to give accurate directions.
Share building hours proactively so visitors do not arrive
to a closed building.""",
tools=[find_building, find_room, get_upcoming_events],
)
FAQ
How does the agent account for construction or temporary closures?
Add a closures list to the Building model with start/end dates and detour instructions. Before giving directions, the agent checks for active closures and automatically reroutes. It can also proactively warn users about upcoming closures that might affect their route.
Can this agent work with real mapping services?
Yes. Replace the haversine calculation with calls to Google Maps, Mapbox, or OpenStreetMap APIs for turn-by-turn walking directions. Indoor navigation can use Bluetooth beacons or WiFi positioning with APIs from Mappedin or Meridian.
How do you handle buildings with multiple entrances?
Model each entrance as a sub-location with its own GPS coordinates and an entrance_type field (main, side, accessible, loading). The directions tool selects the entrance closest to the user starting point, prioritizing accessible entrances when accessibility features are relevant.
#AIAgents #EdTech #CampusNavigation #Python #Geolocation #AgenticAI #LearnAI #AIEngineering
CallSphere Team
Expert insights on AI voice agents and customer communication automation.
Try CallSphere AI Voice Agents
See how AI voice agents work for your industry. Live demo available -- no signup required.