An AI-powered, multilingual advisory chatbot for farmers. It provides instant information on crop management, pests, and soil health via both text and voice, aiming to be fast, accessible, and easy to use.
- 🗣️ Multilingual Support: Text and voice chat in 8+ languages (English, Spanish, French, German, Portuguese, Hindi, Chinese, Arabic)
- 🎤 Voice Input/Output: Speak your questions and hear responses back
- 🌾 Agricultural Expertise: Knowledge base covering:
- Crop diseases and treatment
- Pest identification and control
- Fertilizer recommendations
- Weather-related farming advice
- Soil health management
- 📱 Mobile Responsive: Works perfectly on phones, tablets, and desktops
- ⚡ Fast Response: < 3 seconds response time for 95% of queries
- 🔄 Real-time Chat: Instant messaging interface
- 📊 Admin Dashboard: Manage knowledge base and view chat analytics
- Backend: Django 4.2+ (Python 3.8+)
- Frontend: HTML5, CSS3, JavaScript (ES6+)
- Database: SQLite (development) / PostgreSQL (production)
- AI Services:
- Google Cloud Speech-to-Text
- Google Cloud Text-to-Speech
- Google Cloud Dialogflow (optional)
- Deployment: Docker-ready
- Python 3.8 or higher
- pip (Python package manager)
- Google Cloud account (for speech services)
-
Clone the repository
git clone <repository-url> cd crop-crystalline-chatbot
-
Create virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Configure environment variables
cp .env.example .env # Edit .env with your Google Cloud credentials and settings -
Set up Google Cloud credentials
- Create a service account in Google Cloud Console
- Download the JSON key file
- Set
GOOGLE_APPLICATION_CREDENTIALSin.envto the path of your key file
-
Run setup script
python setup.py
-
Start the development server
python manage.py runserver
-
Open your browser
- Visit: http://127.0.0.1:8000
- Admin panel: http://127.0.0.1:8000/admin
Create a .env file with the following variables:
# Django settings
SECRET_KEY=your-secret-key-here
DEBUG=True
# Google Cloud credentials
GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/service-account-key.json
GOOGLE_CLOUD_PROJECT_ID=your-project-id
# Dialogflow settings (optional)
DIALOGFLOW_PROJECT_ID=your-dialogflow-project-id
DIALOGFLOW_LANGUAGE_CODE=en-US-
Enable APIs:
- Cloud Speech-to-Text API
- Cloud Text-to-Speech API
- Dialogflow API (optional)
-
Create Service Account:
- Go to Google Cloud Console → IAM & Admin → Service Accounts
- Create a new service account
- Grant necessary permissions
- Download JSON key file
-
Set up Dialogflow (optional):
- Create a new Dialogflow project
- Configure intents and entities for agricultural queries
- Link to your Google Cloud project
POST /api/chat/- Send text messagePOST /api/voice-chat/- Send voice messageGET /api/history/<session_id>/- Get chat historyGET /api/languages/- Get supported languagesGET /api/health/- Health check
Text Chat:
{
"message": "How do I treat tomato blight?",
"session_id": "optional-session-id",
"language_code": "en-US"
}Voice Chat:
{
"audio_data": "base64-encoded-audio",
"session_id": "optional-session-id",
"language_code": "en-US"
}Stores agricultural knowledge and advice:
category: Type of advice (crop_diseases, pest_identification, etc.)topic: Specific topic or problemquestion_patterns: Common question patternsanswer: Response textlanguage_code: Language of the entry
Tracks user chat sessions:
session_id: Unique session identifierlanguage_code: User's preferred languagecreated_at: Session start time
Stores chat history:
session: Link to chat sessionmessage_type: 'user' or 'bot'content: Message textaudio_file: Optional audio fileresponse_time: Bot response time
-
Add language support:
# In chatbot/views.py, update supported_languages view {'code': 'new-lang', 'name': 'Language Name', 'native_name': 'Native Name'}
-
Populate knowledge base:
python manage.py populate_knowledge_base --language=new-lang
-
Update frontend:
- Add translations in
static/js/chatbot.js - Update language selector in template
- Add translations in
FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
RUN python setup.py
EXPOSE 8000
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]Run tests with:
python manage.py test- Response times are tracked in the database
- Use Django admin to view chat analytics
- Health check endpoint:
/api/health/
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
For support and questions:
- Create an issue on GitHub
- Check the documentation
- Review the admin panel for chat logs
- Integration with weather APIs
- Image-based pest identification
- Crop planning calendar
- Push notifications
- Offline mode improvements
- Advanced analytics dashboard
- Integration with agricultural databases
Made with ❤️ for farmers worldwide 🌾