Data Portal Bot is an open-source Telegram bot that provides convenient access to Cambodia's public data through a simple chat interface. Get instant updates on air quality, weather, exchange rates, and stock market information - all from official public sources.
Data Sources:
- Air Quality Index from public monitoring stations
- Weather data from meteorological services
- Exchange rates from official financial sources
- Stock market data from Cambodia Securities Exchange (CSX)
- All data sourced from MEF Cambodia Open Data Portal
- π¬οΈ Air Quality Index (AQI) - Real-time air quality monitoring
- π€οΈ Weather Data - Current weather conditions
- βοΈ UV Index - Sun exposure levels with safety tips
- π± Exchange Rates - USD/KHR and other currencies
- π Stock Market - CSX index and market summary
- π Economic Data - Public economic indicators
- π³ Docker Support - Easy containerized deployment
- π Auto-recovery - Automatic restart on failures
- πΎ Smart Caching - Efficient data caching (5-minute TTL)
/start - Open main menu
/aqi - Air Quality Index
/weather - Current weather
/uv - UV Index
/exchange - Exchange rates
/csx_index - CSX stock index
/csx_summary - CSX market summary
/stats - Bot statistics
/health - Health status
- Node.js 18 or higher
- PostgreSQL database (free options: Neon, Supabase)
- Telegram Bot Token from @BotFather
# 1. Clone repository
git clone https://github.com/im4tta/mefapibot.git
cd mefapibot
# 2. Install dependencies
npm install
# 3. Configure environment
cp .env.example .env
# Edit .env with your credentials
# 4. Initialize database
npm run init-db
# 5. Start bot
npm startCreate a .env file with your credentials:
# Telegram Bot Token (required)
BOT_TOKEN=your_bot_token_from_botfather
# PostgreSQL Database URL (required)
DATABASE_URL=postgresql://user:password@host:5432/database
# Admin User IDs (optional)
ADMIN_USER_IDS=your_telegram_user_id
# API Configuration
MEF_API_URL=https://data.mef.gov.kh/api/v1
# Environment
NODE_ENV=production-
Bot Token: Message @BotFather on Telegram
- Send
/newbotand follow prompts - Copy the token provided
- Send
-
Database: Get free PostgreSQL from:
-
User ID: Message @userinfobot to get your Telegram ID
cd docker
docker-compose up -d
# View logs
docker-compose logs -f
# Stop
docker-compose down# Build
docker build -t data-portal-bot .
# Run
docker run -d \
--name data-portal-bot \
--env-file .env \
-p 3000:3000 \
data-portal-botcd docker
.\run-docker.batmefapibot/
βββ api/ # API endpoints
β βββ daily-broadcast.js # Scheduled broadcasts
β βββ health.js # Health check endpoint
β βββ index.js # Express server
β βββ metrics.js # Metrics endpoint
β βββ webhook.js # Telegram webhook handler
βββ docker/ # Docker configuration
β βββ docker-compose.yml
β βββ run-docker.bat
β βββ stop-docker.bat
βββ scenes/ # Command handlers
β βββ aqi.js # Air quality commands
β βββ economic.js # Economic data commands
β βββ exchange.js # Exchange rate commands
β βββ weather.js # Weather commands
βββ scripts/ # Utility scripts
β βββ init-db.js # Database initialization
β βββ setup-webhook.js # Webhook setup
βββ admin.js # Admin panel features
βββ bot.js # Main bot entry point
βββ bot-class.js # Bot class implementation
βββ database.js # Database utilities
βββ keyboards.js # Telegram keyboard layouts
βββ package.json # Dependencies
βββ Dockerfile # Docker configuration
βββ .env.example # Environment template
βββ README.md # This file
npm start # Start the bot
npm run dev # Development mode
npm run init-db # Initialize database
npm run setup-webhook # Configure webhook
npm run docker:build # Build Docker image
npm run docker:run # Run Docker container
npm run docker:stop # Stop Docker containerThe bot uses PostgreSQL to store operational data. Initialize with:
npm run init-dbPrivacy Note: This bot does not collect or store personal user data.
- β No personal data collection
- β Public data sources only
- β No user tracking or analytics
- β Open source and transparent
- Environment variables for sensitive config
- No hardcoded credentials
- Input validation
- Rate limiting on API calls
- Secure database connections (SSL)
- Error handling without exposing internals
- Keep bot token secure
- Use strong database passwords
- Enable SSL for database
- Keep dependencies updated:
npm audit fix
When running, the bot exposes these endpoints:
GET /api/health- Health checkGET /api/metrics- Bot metricsPOST /webhook- Telegram webhook (production)
Contributions are welcome! To contribute:
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License - see LICENSE file.
- Data from MEF Cambodia Open Data Portal
- Built with Telegraf - Telegram Bot Framework
- Inspired by the need for accessible public data
- Issues: GitHub Issues
- Repository: github.com/im4tta/mefapibot
This bot provides information from public data sources for informational purposes only. The accuracy and availability of data depend on the source APIs. This is an independent project and is not officially affiliated with any government agency or data provider.
Made with β€οΈ for Cambodia