← back to Dear Bubbe Nextjs
INSTAGRAM_AUTOMATION.md
116 lines
# Instagram Automated Posting System
## Overview
The Instagram automated posting system for Dear Bubbe is now fully operational. It posts user questions as anonymous content to Instagram 3 times per day.
## Account Details
- **Username**: dearBubbe
- **Password**: *Instaaccess911*
- **Profile**: https://www.instagram.com/dearBubbe/
## System Components
### 1. Main Posting Script
- **File**: `/root/Projects/dear-bubbe-nextjs/lib/instagram-poster.js`
- **Function**: Handles Instagram login, image upload, and posting
- **Features**:
- Automated login with cookie persistence
- Mobile web UI navigation
- Image upload and caption handling
- Error screenshot capture for debugging
### 2. PM2 Service
- **Name**: instagram-poster
- **Config**: `/root/Projects/dear-bubbe-nextjs/instagram.ecosystem.config.js`
- **Status**: Running continuously, checks every 2 hours
- **Logs**: `/root/Projects/dear-bubbe-admin/logs/instagram-pm2.log`
### 3. Cron Jobs
Scheduled posting at optimal engagement times:
- **8:00 AM EST** (13:00 UTC) - Morning peak
- **12:30 PM EST** (17:30 UTC) - Lunch peak
- **7:00 PM EST** (00:00 UTC) - Evening peak
### 4. Image Generation
- **Location**: `/root/Projects/dear-bubbe-admin/public/instagram-*.png`
- **Format**: Square images (1080x1080) with Bubbe branding
- **Content**: Anonymous user questions with Bubbe theme
## Posting Limits
- **Daily Maximum**: 3 posts
- **Minimum Interval**: 6 hours between posts
- **Auto-reset**: Daily counter resets at midnight
## Commands
### Start Service
```bash
pm2 start instagram.ecosystem.config.js
```
### Stop Service
```bash
pm2 stop instagram-poster
```
### View Logs
```bash
pm2 logs instagram-poster
```
### Monitor Status
```bash
/root/Projects/dear-bubbe-nextjs/lib/monitor-instagram.sh
```
### Manual Test Post
```bash
node /root/Projects/dear-bubbe-nextjs/lib/test-instagram-post.js
```
## State Management
- **State File**: `/root/Projects/dear-bubbe-admin/logs/instagram-state.json`
- **Tracks**:
- Posted messages (prevents duplicates)
- Daily post count
- Last post time
- Total posts
## Troubleshooting
### If Posts Fail
1. Check logs: `pm2 logs instagram-poster --lines 50`
2. Look for error screenshots: `ls /root/Projects/dear-bubbe-admin/logs/instagram-error-*.png`
3. Clear cookies: `rm /root/Projects/dear-bubbe-nextjs/lib/instagram-cookies.json`
4. Restart service: `pm2 restart instagram-poster`
### Common Issues
- **Login failures**: Delete cookies file and let it re-authenticate
- **Selector timeout**: Instagram UI changes - check error screenshots
- **Rate limiting**: System respects 6-hour minimum between posts
## Success Metrics
✅ **Status**: FULLY OPERATIONAL
- First successful post: November 21, 2025 00:48:47 UTC
- PM2 service: Running
- Cron jobs: Configured
- Error handling: Implemented
- Cookie persistence: Working
## Post Format
Each Instagram post includes:
1. **Image**: Generated with user question
2. **Caption**:
- Opens with: "Real question from our community:"
- Includes the question
- Ends with: "🥯 What would Bubbe say? Find out at bubbe.ai"
3. **Hashtags**: Automatically added for reach
## Security
- Credentials stored in code (consider environment variables for production)
- Cookies saved locally for session persistence
- Headless browser runs with security flags
---
*System activated: November 21, 2025*