AI-powered Twitter bot that generates social discourse through nuanced breaking news content in English and Chinese.
- Bilingual Support: Content generation in English and Chinese with cultural adaptation
- AI-Powered Content: Uses OpenAI GPT-4 and Anthropic Claude for intelligent tweet generation
- Breaking News Monitoring: Real-time monitoring of multiple news sources
- Nuanced Questioning: Generates subtle factual variations to encourage discussion
- Ethics Filtering: Multi-layer content filtering for responsible AI deployment
- Real-time Dashboard: React-based dashboard for bot control and analytics
- Automated Responses: Intelligent response system for user interactions
- Comprehensive Analytics: Detailed engagement and performance metrics
- Frontend: Next.js with React and Ant Design
- Backend: Firebase Cloud Functions with TypeScript
- Database: Cloud Firestore
- Authentication: Firebase Auth
- AI Services: OpenAI API and Anthropic Claude
- News Sources: RSS feeds from Reuters, BBC, CNN, Xinhua, CCTV, etc.
- Node.js 18 or later
- Firebase CLI
- Twitter Developer Account
- OpenAI API key
- Anthropic API key (optional)
- News API keys
-
Clone the repository
git clone <repository-url> cd nuancebot
-
Install dependencies
npm install cd functions && npm install
-
Set up environment variables
cp .env.local.example .env.local
Fill in your API keys and configuration:
# Firebase Configuration NEXT_PUBLIC_FIREBASE_API_KEY=your_api_key_here NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your_project.firebaseapp.com NEXT_PUBLIC_FIREBASE_PROJECT_ID=your_project_id # Twitter API Credentials TWITTER_API_KEY=your_twitter_api_key TWITTER_API_SECRET=your_twitter_api_secret TWITTER_ACCESS_TOKEN=your_access_token TWITTER_ACCESS_TOKEN_SECRET=your_access_token_secret # OpenAI API OPENAI_API_KEY=your_openai_api_key # Anthropic Claude API (optional) ANTHROPIC_API_KEY=your_anthropic_api_key # News APIs NEWS_API_KEY=your_news_api_key GUARDIAN_API_KEY=your_guardian_api_key
-
Initialize Firebase
firebase init
Select:
- Firestore
- Functions
- Hosting
-
Deploy Firestore rules and indexes
firebase deploy --only firestore
-
Deploy Cloud Functions
cd functions npm run build firebase deploy --only functions
-
Start the development server
npm run dev
-
Start Firebase emulators (in a separate terminal)
firebase emulators:start
-
Build and serve functions locally
cd functions npm run serve
The application will be available at http://localhost:3000
- Access the dashboard at your deployed URL
- Authenticate using Firebase Auth
- Configure bot settings:
- Tweet interval (10-240 minutes)
- Language preferences (English/Chinese)
- News categories
- Ethics level
- AI model selection
- Start/Stop the bot using the control panel
- Monitor real-time statistics and performance
- View tweet history and engagement metrics
- Emergency stop functionality for immediate shutdown
The bot automatically:
- Monitors breaking news from configured sources
- Analyzes articles for factual nuances
- Generates culturally appropriate questions
- Applies ethics filtering
- Publishes tweets at scheduled intervals
- Responds to user interactions
npm testnpm run test:e2enpm run test:performance-
Build the application
npm run build
-
Deploy to Firebase Hosting
firebase deploy
-
Set production environment variables
firebase functions:config:set twitter.api_key="your_key" firebase functions:config:set openai.api_key="your_key"
- Development: Uses Firebase emulators
- Staging: Uses Firebase staging project
- Production: Uses Firebase production project
| Setting | Description | Default | Range |
|---|---|---|---|
tweetInterval |
Minutes between tweets | 60 | 10-240 |
primaryLanguage |
Main content language | en | en, cn |
ethicsLevel |
Content filtering level | moderate | strict, moderate, permissive |
maxDailyTweets |
Maximum tweets per day | 12 | 1-50 |
creativityLevel |
AI creativity (temperature) | 0.7 | 0.0-1.0 |
- Reuters Breaking News
- BBC World News
- CNN Breaking News
- Associated Press
- TechCrunch
- ๆฐๅ็ฝ (Xinhua)
- ไบบๆฐ็ฝ (People's Daily)
- ๅคฎ่งๆฐ้ป (CCTV News)
- ๆพๆนๆฐ้ป (The Paper)
- ๆฐๆตช่ดข็ป (Sina Finance)
The dashboard provides:
- Real-time metrics: Tweet count, engagement rate, interactions
- Language distribution: EN/CN content performance
- Category analysis: Top performing news categories
- Engagement trends: Historical performance data
- Response analytics: User interaction patterns
- Multi-layer filtering: Prohibited content detection
- Cultural sensitivity: Language-appropriate content
- Fact verification: Source credibility checks
- Human oversight: Optional manual review
- GDPR compliance: User data protection
- Firestore security rules: Database access control
- API rate limiting: Abuse prevention
- Audit logging: Complete activity tracking
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Check the documentation
- Open an issue
- Join our Discord
- OpenAI: GPT-4 API for content generation
- Anthropic: Claude API for content analysis
- Firebase: Backend infrastructure
- Twitter: API access for social media integration
- News Sources: Reuters, BBC, Xinhua, and others
- Initial release
- Bilingual support (EN/CN)
- Real-time dashboard
- AI-powered content generation
- Breaking news monitoring
- Ethics filtering system
Built with โค๏ธ for responsible AI-driven social discourse