- ✅ LinkedIn OAuth Authentication (OpenID Connect)
- ✅ AI Post Generation with Gemini 2.0 Flash
- ✅ Image Upload & Analysis
- ✅ Post Confirmation & Refinement Dialog
- ✅ Direct LinkedIn Posting
- ✅ NEW: Conversation System with Context
- ✅ NEW: Multiple Chat Windows
- ✅ NEW: Chat History & Persistence
- Create multiple conversations - Organize posts by project/campaign
- Switch between chats - Like ChatGPT, maintain separate contexts
- Edit previous posts - AI remembers conversation history
- Context-aware AI - References past messages automatically
- Persistent storage - All conversations saved in MongoDB
- Chat history view - See all messages in a conversation
User: "Create a post about my AI project"
AI: [Generates post]
User: "Make it shorter"
AI: [Generates shorter version - remembers original]
User: "Add more technical details"
AI: [Updates with details - maintains context]
[Later, in same conversation]
User: "Edit the AI project post to mention React"
AI: [Finds and updates the post from history]
models/Conversation.js- Conversation database schemaroutes/conversations.js- Conversation API endpoints
context/ConversationContext.jsx- Global conversation statecomponents/ConversationSidebar.jsx- Sidebar UI component- Updated
components/AiInterface.jsx- Context-aware chat - Updated
App.jsx- Integrated sidebar
CONVERSATION_FEATURE.md- Complete feature documentationSETUP_INSTRUCTIONS.md- This file
cd D:\15OCT\Sever
npm startExpected output:
🚀 Server running on http://localhost:3001
📱 Frontend URL: http://localhost:5173
🔐 LinkedIn OAuth configured
✅ MongoDB Connected
cd D:\15OCT\RTL
npm run devExpected output:
VITE ready in xxx ms
➜ Local: http://localhost:5173/
http://localhost:5173
┌─────────────────────────────────────────────────┐
│ [Sidebar] │ [Main Content Area] │
│ │ │
│ New Chat │ [Header: Menu | Profile] │
│ ───────── │ │
│ Conv 1 │ [Chat History] │
│ Conv 2 │ - User message │
│ Conv 3 │ - AI response │
│ │ - User message │
│ │ - AI response │
│ │ │
│ │ [Input Area] │
│ │ - Text input │
│ │ - Image upload │
│ │ - Send button │
│ │ │
│ │ [Generated Post Display] │
│ │ - Post content │
│ │ - "Ready to Post?" button │
└─────────────────────────────────────────────────┘
- New Chat Button - Create new conversation
- Conversation List - All your chats
- Edit Title - Rename conversations (hover to see icon)
- Delete - Remove conversations (hover to see icon)
- Active Highlight - Current conversation highlighted
- Mobile Responsive - Hamburger menu on mobile
- User Messages - Right-aligned, blue background
- AI Messages - Left-aligned, gray background
- Images - Displayed inline
- Timestamps - Time of each message
- Auto-scroll - Scrolls to latest message
- Open app → Click "Login with LinkedIn"
- Authorize app on LinkedIn
- Redirected back → Profile appears
- Type message → AI generates post
- Click "Ready to Post?" → Review
- Click "Post to LinkedIn" → Success!
- Click "New Chat" → Type about Project A
- Generate and refine posts for Project A
- Click "New Chat" → Type about Project B
- Generate posts for Project B
- Switch back to Project A conversation
- Continue working on Project A posts
- Select old conversation from sidebar
- Type: "Edit the previous post to add..."
- AI finds post in history and updates it
- Refine further if needed
- Post to LinkedIn
GET /auth/linkedin- Start OAuthGET /auth/linkedin/callback- OAuth callbackGET /auth/me- Get current userPOST /auth/logout- Logout
POST /api/posts/create- Create LinkedIn postGET /api/posts/my-posts- Get post history
GET /api/conversations- Get all conversationsGET /api/conversations/:id- Get specific conversationPOST /api/conversations- Create new conversationPOST /api/conversations/:id/messages- Add messagePATCH /api/conversations/:id- Update titleDELETE /api/conversations/:id- Delete conversationGET /api/conversations/:id/context- Get context for AI
{
linkedinId: String,
email: String,
firstName: String,
lastName: String,
profilePicture: String,
accessToken: String,
linkedinProfile: Object
}{
userId: ObjectId,
content: String,
imageUrl: String,
linkedinPostId: String,
status: String,
publishedAt: Date
}{
userId: ObjectId,
title: String,
messages: [
{
role: 'user' | 'assistant',
content: String,
imageUrl: String,
timestamp: Date
}
],
lastMessageAt: Date,
isActive: Boolean,
metadata: {
totalMessages: Number,
postsGenerated: Number
}
}- Last 5-10 messages sent to AI as context
- Helps AI understand conversation flow
- Enables editing of previous posts
- Maintains consistency across messages
- Each conversation is independent
- Switch between conversations seamlessly
- Context is per-conversation
- Conversations persist across sessions
- User types message
- Message saved to database
- Context fetched (last N messages)
- Context + new message sent to AI
- AI generates response
- Response saved to database
- UI updates with new message
Solution: Make sure you're logged in. Sidebar only appears for authenticated users.
Solution:
- Check backend is running
- Check MongoDB connection
- Check browser console for errors
- Verify JWT token in localStorage
Solution:
- Ensure conversation has messages
- Check
getConversationContext()is being called - Verify messages are saved to database
- Check backend logs for errors
Solution:
- Click directly on conversation in sidebar
- Check if conversation is loading (spinner)
- Verify conversation exists in database
- Login with LinkedIn works
- Profile displays correctly
- Generate post works
- Image upload works
- Post to LinkedIn works
- Logout works
- Create new conversation
- Messages save to database
- Switch between conversations
- Edit conversation title
- Delete conversation
- Chat history displays
- Context works (AI remembers previous messages)
- Sidebar shows on desktop
- Sidebar toggles on mobile
- Edit previous post using context
- Multiple conversations maintain separate contexts
- Conversations persist after logout/login
- Auto-scroll to latest message
- Image attachments show in history
- Timestamps display correctly
You'll know everything is working when:
- ✅ You can login with LinkedIn
- ✅ Sidebar shows with "New Chat" button
- ✅ You can create multiple conversations
- ✅ Chat history displays messages
- ✅ AI remembers context (try: "make it shorter")
- ✅ You can switch between conversations
- ✅ You can edit conversation titles
- ✅ You can delete conversations
- ✅ You can post to LinkedIn
- ✅ Everything persists after refresh
Scenario 1: Multiple Projects
1. Create "Marketing Campaign" conversation
2. Generate 3-4 posts about marketing
3. Create "Product Updates" conversation
4. Generate posts about product
5. Switch back to "Marketing Campaign"
6. Ask AI to edit one of the marketing posts
Scenario 2: Iterative Refinement
1. Create new conversation
2. "Create a post about my startup"
3. "Make it more professional"
4. "Add statistics"
5. "Make it shorter"
6. "Add a call-to-action"
7. Post to LinkedIn
Scenario 3: Context Awareness
1. Create conversation
2. "Create a post about AI"
3. "Now create another post building on that theme"
4. "Combine both posts into one"
5. "Make it suitable for LinkedIn"
FINAL_SETUP_COMPLETE.md- Original setup guideCONVERSATION_FEATURE.md- Detailed conversation feature docsLINKEDIN_SCOPES_FIX.md- LinkedIn OAuth troubleshootingSETUP_INSTRUCTIONS.md- This file
You now have a fully-featured AI-powered social media manager with:
- ✅ LinkedIn authentication
- ✅ AI post generation
- ✅ Image support
- ✅ Post refinement
- ✅ Direct LinkedIn posting
- ✅ Conversation system with context
- ✅ Multiple chat windows
- ✅ Persistent chat history
Start creating amazing content! 🚀
Built with 💜 using:
- React 19
- Node.js + Express
- MongoDB Atlas
- Google Gemini AI 2.0 Flash
- LinkedIn API v2
- Tailwind CSS
- Passport.js