A proactive AI chat application that engages users with intelligent rules, spontaneous contributions, and socially aware responses. Unlike traditional chatbots that only respond when prompted, ProactiChat actively participates in conversations with contextual insights and reactions.
- Proactive Engagement: AI spontaneously contributes thoughts and observations based on conversation context
- Smart Reactions: Responds to user emoji reactions with social awareness
- Rule-Based System: Multiple intelligent rules for different types of engagement
- Real-time Communication: WebSocket-based chat with connection status indicators
- Responsive UI: Modern React interface with iMessage-style design
- Frontend: React + TypeScript + Vite
- Backend: Node.js + Express + WebSocket
- AI: OpenAI GPT-4o integration with contextual prompts
- Rules Engine: Modular system for different types of proactive behavior
- Node.js 18+
- npm or yarn
- OpenAI API key
git clone <repository-url>
cd chat-buddyCreate environment files:
# Backend environment
echo "OPENAI_APIKEY=your_openai_api_key_here" > backend/.env
# Frontend environment (if needed)
echo "VITE_API_URL=http://localhost:3001" > frontend/.env# Install backend dependencies
cd backend
npm install
# Install frontend dependencies
cd ../frontend
npm install# Terminal 1: Start backend
cd backend
npm start
# Terminal 2: Start frontend
cd frontend
npm run devThe application will be available at:
- Frontend: http://localhost:5173
- Backend: http://localhost:3001
# Build and run with docker-compose
docker-compose up --build
# Run in background
docker-compose up -d --buildAccess the application:
- Frontend: http://localhost:3000
- Backend: http://localhost:3001
# Build images
docker build -t proactivchat-backend ./backend
docker build -t proactivchat-frontend ./frontend
# Run containers with environment variables
docker run -d -p 3001:3001 \
-e OPENAI_APIKEY=your_key_here \
--name proactivchat-backend \
proactivchat-backend
docker run -d -p 3000:3000 \
--name proactivchat-frontend \
proactivchat-frontendHeroku:
# Set environment variable
heroku config:set OPENAI_APIKEY=your_key_here
# Deploy
git push heroku mainRailway/Render/Others:
- Connect your GitHub repository
- Set
OPENAI_APIKEYin environment variables - Deploy automatically
Backend (.env):
OPENAI_APIKEY=your_openai_api_key_here
NODE_ENV=production
PORT=3001Frontend (.env):
VITE_API_URL=http://localhost:3001You can adjust the AI's proactive behavior in:
backend/src/rules/SpontaneousContributionRule.js- Random contributionsbackend/src/rules/AutoReactionRule.js- Emoji reactionsbackend/src/services/contextualAiService.js- AI prompts and behavior
Key parameters:
// Spontaneous contribution frequency
minIntervalMs: 15 * 1000, // 15 seconds between contributions
shouldContribute: 0.25, // 25% chance per check
// Maximum contributions per hour
maxExecutions: 8, // Limit to prevent spamWebSocket Connection:
ws://localhost:3001- Main chat connection
Message Format:
// Regular message
{ "text": "Hello!" }
// Typing indicator
{ "type": "typing", "isTyping": true }
// AI reaction
{ "type": "ai_reaction", "emoji": "π", "reason": "funny comment" }
// User reaction
"REACT:π:messageIndex"βββ backend/
β βββ src/
β β βββ rules/ # Proactive behavior rules
β β βββ services/ # AI and chat services
β β βββ utils/ # Utility functions
β β βββ index.js # Main server
β βββ Dockerfile
β βββ package.json
βββ frontend/
β βββ src/
β β βββ App.tsx # Main React component
β β βββ App.css # Styling
β β βββ main.tsx # Entry point
β βββ Dockerfile
β βββ package.json
βββ docker-compose.yml
βββ README.md
- Create a new rule class in
backend/src/rules/ - Extend the base
Ruleclass - Define triggers and execution logic
- Add to the rules array in
index.js
Example:
class MyCustomRule extends Rule {
constructor(aiService) {
super("myCustomRule", ["trigger_event"]);
this.aiService = aiService;
}
async execute(event, context) {
// Your logic here
return [{ type: "send_message", payload: { text: "Hello!" } }];
}
}Edit the character prompt in backend/src/services/openAiAdapter.js:
this.characterPrompt = `Your custom AI personality...`;Common Issues:
-
WebSocket Connection Failed
- Check if backend is running on port 3001
- Verify firewall settings
- Check browser console for errors
-
AI Not Responding
- Verify
OPENAI_APIKEYis set correctly - Check backend logs for API errors
- Ensure you have OpenAI API credits
- Verify
-
No Proactive Messages
- Check if rules are hitting execution limits
- Verify conversation has enough context (2+ user messages)
- Check timer interval settings
-
Rate Limiting
- OpenAI API has rate limits
- Reduce proactive behavior frequency
- Check usage in OpenAI dashboard
MIT License - see LICENSE file for details
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
For issues and questions:
- Check the troubleshooting section
- Review backend logs for errors
- Open an issue on GitHub