An AI-powered agent built using LangChain, OpenAI, and Gmail API that can dynamically invoke tools based on user requests.
Retrieve weather information for a specified city.
Example
What is the weather in Hyderabad?Fetch post details from JSONPlaceholder using a Post ID.
Example
Get post 20API:
https://jsonplaceholder.typicode.com/posts/{id}
Uses the OpenAI language model to generate a short, inspirational thought that can provide daily motivation and encouragement. .
Example
Generate today's thoughtConnects securely to Gmail using OAuth 2.0 and retrieves the latest email subjects from the user's Primary Inbox.
Example
Show my latest 2 email subjects βββββββββββββββ
β User β
ββββββββ¬βββββββ
β
βΌ
ββββββββββββββββββββ
β LangChain Agent β
ββββββββββ¬ββββββββββ
β
βΌ
βββββββββββββββ
β OpenAI LLM β
ββββββββ¬βββββββ
β
βββββββββββββββββΌβββββββββββββββββ
β β β
βΌ βΌ βΌ
π€οΈ Weather π° Posts π§ Gmail Tool
β β β
βΌ βΌ βΌ
External API JSONPlaceholder Gmail API
β
βΌ
Final AI Response
| Technology | Purpose |
|---|---|
| π Python | Core Programming Language |
| π¦ LangChain | Agent Framework |
| πΈοΈ LangGraph | Agent Execution Engine |
| π€ OpenAI API | LLM Integration |
| π§ Gmail API | Email Retrieval |
| π OAuth 2.0 | Authentication |
| π Requests | HTTP Requests |
| βοΈ Python Dotenv | Environment Variables |
Install required packages:
pip install langchain
pip install langchain-openai
pip install langgraph
pip install python-dotenv
pip install requests
pip install google-api-python-client
pip install google-auth-oauthlib
pip install google-auth-httplib2Create a .env file:
OPENAI_API_KEY=your_openai_api_keyCreate a Google Cloud Project.
Enable Gmail API.
Configure OAuth Consent Screen.
Create OAuth Client ID.
Select:
Desktop Application
Download credentials file.
Rename to:
credentials.json
Project Structure:
project/
β
βββ dynamic_agent_input.py
βββ credentials.json
βββ .env
βββ token.json
βββ README.md
User
β
Google Login
β
OAuth Consent
β
Access Granted
β
token.json Generated
β
Gmail API Access
First run requires login.
Subsequent runs use the stored token.
python dynamic_agent_input.py "Get post 20"python dynamic_agent_input.py "Generate a daily thought"python dynamic_agent_input.py "Show my latest email subjects"User Query
β
LangChain Agent
β
OpenAI Model
β
Tool Selection
β
Tool Execution
β
External API
β
Tool Result
β
LLM Formatting
β
Final Response
Never commit:
credentials.json
token.json
.env
Add to .gitignore:
credentials.json
token.json
.env
__pycache__/
venv/β Tool Calling
β Agent Architecture
β OAuth 2.0 Authentication
β Gmail API Integration
β OpenAI Integration
β External API Consumption
β Dynamic Workflow Execution
β LangChain Agent Development
- π© Email Summarization
- βοΈ Email Draft Generation
- π Calendar Integration
- π¦οΈ Real Weather API Integration
- ποΈ Database Connectivity
- π Multi-Tool Agent Workflows
Sathvik Chekkali
Built for learning Agentic AI, LangChain, Tool Calling, and External API Integration.