A conversational AI chatbot built with Python and Flask that can answer general questions, fetch real-time cryptocurrency data (prices, market cap, trading volume, OHLC, top gainers/losers), and even predict future prices using simple machine learning. The agent uses NLTK for natural language processing, CoinGecko API for crypto data, and scikit-learn for basic regression.
- Conversational Chatbot: Handles greetings, small talk, and fallback responses using NLTK's pattern-matching.
- Crypto Price Lookup: Get the latest USD price for any supported cryptocurrency.
- Market Cap & Volume: Query the current market capitalization and trading volume.
- Top Gainers & Losers: See the top performing and worst performing coins (requires CoinGecko Pro API).
- OHLC Data: Retrieve Open, High, Low, Close data for a coin.
- Coin Recommendation: Suggests a coin with the highest market cap and volume.
- Price Prediction: Uses linear regression on the last 30 days to predict the next day's price.
- Web Interface: Simple chat UI built with Flask, HTML, and CSS.
.
├── app.py # Main Flask backend and AI logic
├── requirements.txt # Python dependencies
├── .env # Environment variables (API keys)
├── templates/
│ └── index.html # Chatbot web interface
├── static/
│ └── css/
│ └── style.css # UI styling
├── reqs.py # (Optional) Dependency helper
└── myenv/ # Python virtual environment (not needed for deployment)
- Python 3.8+
- CoinGecko API Key (for some endpoints, especially top gainers/losers)
- Basic command-line knowledge
-
Clone the repository
git clone <your-repo-url> cd ai_agent
-
Create and activate a virtual environment
python -m venv myenv # On Windows: myenv\Scripts\activate # On macOS/Linux: source myenv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Download NLTK data
In a Python shell:import nltk nltk.download('punkt')
-
Set up your
.envfile
Create a.envfile in the project root:COINGECKO_API_KEY=your_api_key_here
python app.py- Visit http://127.0.0.1:5000/ in your browser.
- Type queries like:
price of bitcoinmarket cap of ethereumtrading volume of solanatop gainers and losersohlc of dogecoinpredict price of cardano- Or just say
hello!
-
General:
hello
what is your name? -
Crypto Data:
price of bitcoin
market cap of ethereum
trading volume of solana
ohlc of dogecoin
top gainers and losers
recommend a coin
predict price of cardano
- Some endpoints (like top gainers/losers) require a CoinGecko Pro API key.
- The price prediction is a simple linear regression and not financial advice.
- All environment variables are loaded securely using python-dotenv.
This project is for educational purposes. See LICENSE if provided.
