A complete implementation of an intelligent AI agent that can interact with real-world services, make contextual decisions, and provide proactive assistance. Built from the ground up with both basic and advanced context-aware capabilities, featuring AI-powered X (Twitter) integration for trending topics and news analysis.
- 🌤️ Weather Integration - Real-time weather data with fallback simulation
- 📧 Email System - Send actual emails via Gmail SMTP
- 📅 Calendar Management - Create and manage events
- 💬 Natural Language - Conversational interface with AI responses
- 🔒 Security Features - Input validation and sanitization
- ⚡ Error Handling - Graceful failure management
- 🤝 Specialist Sub-Agents - Weather, Calendar, Email, and Decision agents
- 🔗 Cross-Domain Reasoning - Connects weather impacts to calendar conflicts
- 🎯 Proactive Intelligence - Automatically suggests schedule changes
- 🧩 Contextual Decisions - Makes intelligent recommendations across domains
- 💾 Memory System - Maintains context across interactions
- 📊 Impact Analysis - Assesses weather effects on planned activities
- 📅 Google Calendar Integration - Real Google Calendar API with OAuth2 authentication
- 🔄 Automated Event Management - Create, list, and manage calendar events
- 🤖 Smart Scheduling - AI-powered conflict detection and resolution
- 📱 X Integration - Get trending topics, news, and AI-powered summaries
- 🤖 AI-Powered Analysis - OpenAI integration for intelligent content summaries
- 🔥 Trending Topics - Real-time trending topics from X with smart analysis
- 📰 News Summaries - AI-generated summaries of breaking news and updates
- 📖 Daily Spiritual Content - Automated Bible verse posting to X
- 🧠 Advanced Context Awareness - Calendar and social media impact on daily routine
- ⚡ Proactive Recommendations - Schedule optimization and social engagement
git clone https://github.com/zechariahks/personal-ai-agent-buddy.git
cd personal-ai-agent-buddy
python3 run.py setup
# Export API keys as environment variables for full functionality
# You can add these to your ~/.bashrc or ~/.zshrc for persistence
# OpenAI API Key (for AI responses and summaries)
export OPENAI_API_KEY="your-openai-key-here"
# Weather API Key (for real weather data)
export WEATHER_API_KEY="your-weather-key-here"
# Gmail Configuration (for email features)
export GMAIL_EMAIL="your-email@gmail.com"
export GMAIL_APP_PASSWORD="your-app-password-here"
# X Configuration (for trending topics, news, and posting)
export X_BEARER_TOKEN="your-x-bearer-token"
export X_API_KEY="your-x-api-key"
export X_API_SECRET="your-x-api-secret"
export X_ACCESS_TOKEN="your-x-access-token"
export X_ACCESS_TOKEN_SECRET="your-x-access-token-secret"
# Default Settings
export DEFAULT_CITY="New York"
# Security Configuration (optional)
export AGENT_JWT_SECRET="your-jwt-secret-key"
export AGENT_ENCRYPTION_KEY="your-encryption-key"
# External Services (optional)
export SENDGRID_API_KEY="your-sendgrid-api-key"
python3 test_env_vars.py
# Run the Google Calendar setup script
python3 setup_google_calendar.py
This will guide you through:
- Google Cloud Console Setup - Creating OAuth2 credentials
- API Enablement - Enabling Google Calendar API
- Authentication Flow - Browser-based OAuth2 authentication
- Token Generation - Automatic creation of
token.pickle
file
What you'll need:
- Google account
- Google Cloud Console access (free)
- Web browser for authentication
Files created:
credentials.json
- Your OAuth2 credentials (download from Google Cloud Console)token.pickle
- Authentication tokens (created automatically during setup)
python3 google_calendar_integration.py
# Interactive demo with all features
python3 run.py demo
# Basic agent
python3 run.py basic
# Advanced context-aware agent
python3 run.py context
# Enhanced agent with X integration and AI summaries
python3 run.py enhanced
You: What's the weather in London?
Agent: 🌤️ Weather in London:
• Temperature: 22°C
• Condition: Sunny
• Humidity: 45%
You: Remind me to call mom tomorrow
Agent: 📝 Reminder created: 'call mom tomorrow' for yourself
You: What's the weather in New York?
Agent: 🌤️ Weather Analysis for New York:
• Temperature: 15°C (Heavy Rain)
• Outdoor suitability: Poor (25%)
📅 Schedule Impact Analysis:
Found 1 potential conflict:
• Team Picnic (Tomorrow at 2:00 PM)
💡 Consider moving indoors due to rain
You: List my calendar events
Agent: 📅 Your Upcoming Events:
1. Team Meeting - Today at 2:00 PM
Location: Conference Room A
2. Doctor Appointment - Tomorrow at 10:00 AM
Location: Medical Center
3. Project Review - Friday at 3:00 PM
Location: Virtual (Zoom)
You: Schedule a meeting with John tomorrow at 3 PM
Agent: 📅 Event created successfully!
Event: Meeting with John
Date: Tomorrow (August 12, 2025)
Time: 3:00 PM
✅ Added to your Google Calendar
📊 Schedule Analysis:
• No conflicts detected
• 1 hour buffer after doctor appointment
• Optimal scheduling achieved
You: X trends
Agent: 🔥 X Trending Topics - AI Summary
Based on current X data, here are the key trends:
1. **AI & Technology** - Major developments in artificial intelligence
are driving significant discussion, with focus on new model releases
and industry applications.
2. **Breaking News** - Current events and real-time updates are
generating high engagement across the platform.
3. **World Events** - Global developments continue to shape
conversations with diverse perspectives and reactions.
You: Post daily Bible verse
Agent: 📱 Posting Bible verse to X...
✅ Post shared on X successfully! Post ID: 1234567890
📖 Daily Bible verse posted:
"Trust in the Lord with all your heart..."
— Proverbs 3:5-6
personal-ai-agent-buddy/
├── basic_agent.py # Core agent implementation
├── context_aware_agent.py # Advanced context-aware agent
├── enhanced_context_aware_agent.py # Enhanced agent with X integration
├── x_agent.py # X API integration with AI summaries
├── google_calendar_integration.py # Google Calendar API integration
├── setup_google_calendar.py # Google Calendar setup guide
├── test_agent.py # Comprehensive test suite
├── test_env_vars.py # Environment variable configuration test
├── demo_agent.py # Interactive demonstrations
├── run.py # Quick start script
├── requirements.txt # Python dependencies
├── credentials.json # Google OAuth2 credentials (you create this)
├── token.pickle # Google authentication tokens (auto-generated)
└── README.md # This file
- Get your key from platform.openai.com
- Export as environment variable:
export OPENAI_API_KEY="sk-your-key-here"
- Get your key from openweathermap.org
- Export as environment variable:
export WEATHER_API_KEY="your-weather-key"
- Enable 2-factor authentication on Gmail
- Generate App Password in Google Account settings (https://myaccount.google.com/apppasswords)
- Export as environment variables:
export GMAIL_EMAIL="your-email@gmail.com" export GMAIL_APP_PASSWORD="your-app-password"
- API Access: Get X API access from X Developer Portal
- Create App: Create an X app and get your API keys
- Export credentials:
export X_BEARER_TOKEN="your-bearer-token" export X_API_KEY="your-api-key" export X_API_SECRET="your-api-secret" export X_ACCESS_TOKEN="your-access-token" export X_ACCESS_TOKEN_SECRET="your-access-token-secret"
To make your environment variables persistent across terminal sessions, add them to your shell profile:
For Bash (~/.bashrc or ~/.bash_profile):
echo 'export OPENAI_API_KEY="your-key-here"' >> ~/.bashrc
source ~/.bashrc
For Zsh (~/.zshrc):
echo 'export OPENAI_API_KEY="your-key-here"' >> ~/.zshrc
source ~/.zshrc
# Set all required environment variables for current session
export OPENAI_API_KEY="your-openai-key-here"
export WEATHER_API_KEY="your-weather-key-here"
export GMAIL_EMAIL="your-email@gmail.com"
export GMAIL_APP_PASSWORD="your-app-password-here"
export X_BEARER_TOKEN="your-x-bearer-token"
export X_API_KEY="your-x-api-key"
export X_API_SECRET="your-x-api-secret"
export X_ACCESS_TOKEN="your-x-access-token"
export X_ACCESS_TOKEN_SECRET="your-x-access-token-secret"
export DEFAULT_CITY="New York"
Choose your shell and add the export commands to the appropriate configuration file:
For Zsh users (~/.zshrc):
# Add to ~/.zshrc
echo 'export OPENAI_API_KEY="your-openai-key-here"' >> ~/.zshrc
echo 'export WEATHER_API_KEY="your-weather-key-here"' >> ~/.zshrc
echo 'export GMAIL_EMAIL="your-email@gmail.com"' >> ~/.zshrc
echo 'export GMAIL_APP_PASSWORD="your-app-password-here"' >> ~/.zshrc
echo 'export X_BEARER_TOKEN="your-x-bearer-token"' >> ~/.zshrc
echo 'export X_API_KEY="your-x-api-key"' >> ~/.zshrc
echo 'export X_API_SECRET="your-x-api-secret"' >> ~/.zshrc
echo 'export X_ACCESS_TOKEN="your-x-access-token"' >> ~/.zshrc
echo 'export X_ACCESS_TOKEN_SECRET="your-x-access-token-secret"' >> ~/.zshrc
echo 'export DEFAULT_CITY="New York"' >> ~/.zshrc
# Reload your shell configuration
source ~/.zshrc
# Check if your environment variables are set correctly
echo "OpenAI API Key: $OPENAI_API_KEY"
echo "Weather API Key: $WEATHER_API_KEY"
echo "Gmail Email: $GMAIL_EMAIL"
echo "X Bearer Token: $X_BEARER_TOKEN"
echo "Default City: $DEFAULT_CITY"
The project includes a comprehensive test suite:
python3 test_agent.py
Test Results:
- ✅ All core functionality working
- ✅ X integration with AI summaries validated
- ✅ Security features validated
- ✅ Error handling verified
# Basic weather
"What's the weather in Tokyo?"
# Context-aware analysis
"Check weather for my outdoor meeting tomorrow"
# Create reminders
"Remind me to buy groceries after work"
# Schedule events
"Schedule a team meeting tomorrow at 2 PM"
# Google Calendar integration
"List my calendar events"
"Create calendar event: Lunch with Sarah on Friday at 12 PM"
"Check my schedule for conflicts"
# List items
"Show my reminders"
"List my events"
# Send emails (requires Gmail setup)
"Send email to colleague about the project update"
# Get AI-powered trending topics
"X trends"
# Get AI-powered news summary
"X news"
# Get comprehensive summary
"X summary"
# Post Bible verse
"Post daily Bible verse"
# Post custom message
"Post to X: Excited about AI developments!"
# Weather impact analysis
"What's the weather like?"
# → Automatically checks calendar for conflicts
# Proactive suggestions
# → "I notice you have an outdoor event during the rain forecast"
User Input → Request Processing → Skill Execution → Response
User Input → Context Analysis → Multi-Agent Consultation → Decision Making → Proactive Response
User Input → X API Data Collection → OpenAI Analysis → Intelligent Summary → Contextual Response
- WeatherAgent: Analyzes weather impact on activities
- CalendarAgent: Detects schedule conflicts
- EmailAgent: Composes contextual notifications
- DecisionAgent: Makes cross-domain recommendations
- XAgent: Handles X integration with AI-powered summaries
- Input Sanitization - Removes dangerous characters
- Request Validation - Blocks harmful patterns
- API Key Protection - Environment variable storage
- Error Message Sanitization - Prevents information leakage
- OpenAI integration for intelligent content analysis
- Real-time trending topics analysis
- News summarization from X data
- Context-aware content generation
- Maintains conversation history
- Tracks decision patterns
- Stores cross-session data
- Social media activity logging
- Anticipates user needs
- Suggests preventive actions
- Learns from interactions
- Cross-platform insights
- Connects weather to calendar
- Links email to scheduling
- Integrates social media trends
- Provides comprehensive daily summaries
def new_skill(self, parameters):
"""Add your custom functionality"""
try:
result = your_implementation(parameters)
return f"✅ Success: {result}"
except Exception as e:
return f"❌ Error: {str(e)}"
class NewSpecialistAgent:
def __init__(self, parent_agent):
self.parent = parent_agent
self.name = "NewBot"
def specialized_function(self, data):
return analysis_result
- Response Time: 50-200ms for most requests
- Memory Usage: 10-25MB depending on agent type
- API Efficiency: Optimized external calls with intelligent caching
- Reliability: 99%+ uptime with proper configuration
- AI Summary Generation: 1-3 seconds for OpenAI analysis
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python3 test_agent.py # Run tests
- Interactive Demo:
python3 demo_agent.py
- Test Cases: Comprehensive examples in
test_agent.py
- Code Documentation: Detailed comments throughout
- Architecture Guide: See specialist agent implementations
Import Errors
source venv/bin/activate
pip install -r requirements.txt
API Key Issues
# Check if environment variables are set
echo $OPENAI_API_KEY
echo $X_BEARER_TOKEN
echo $WEATHER_API_KEY
X API Access Issues
- Ensure you have the correct API access level
- Some endpoints require higher tier access
- Check X Developer Portal for your app's permissions
Permission Errors
chmod +x *.py
import logging
logging.basicConfig(level=logging.DEBUG)
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenAI for the GPT API and intelligent summaries
- X (Twitter) for the social media API
- OpenWeatherMap for weather data
- The open-source community for inspiration
- Web interface (Flask/FastAPI)
- Voice recognition integration
- Database storage for persistence
- Multi-user support
- Mobile app companion
- Docker containerization
- Cloud deployment guides
- Advanced AI model integration
- Real-time notification system
git clone <your-repo-url>
cd personal-ai-agent-buddy
python3 run.py demo
Transform your applications with the power of Agentic AI and intelligent social media analysis! 🚀
Built with ❤️ for developers who want to create intelligent, context-aware applications with AI-powered insights