A Node.js backend chatbot powered by Groq LLM with a unique personality system, memory, and randomness.
- 🎭 Strong personality (emoji + pauses + smart/dumb behavior)
- 🧠 Short-term + long-term memory (MongoDB)
- 👽 Random alien / elvish / conflict events
- ⚡ Fast responses using Groq (free LLM API)
- 🔒 Secure environment variable handling
- Node.js
- Express.js
- MongoDB (Mongoose)
- Groq API (Free LLM)
git clone https://github.com/aditig80/chatbot-server
cd chatbot-servernpm installCopy from .env.example:
PORT=5000
GROQ_API_KEY=your_api_key_here
MONGO_URI=your_mongodb_connection_stringnode server.jsExpected output:
Server running on port 5000
MongoDB connected
POST http://localhost:5000/chat
{
"userId": "user1",
"message": "How do I prepare for interviews?"
}{
"reply": "💡 You should focus on DSA fundamentals ||| practice mock interviews ||| build projects"
}The chatbot personality is controlled using a structured system prompt with strict rules:
-
Emoji Rule
- Every response starts with exactly one emoji.
-
Pause Rule
- Uses
|||as natural pauses.
- Uses
-
Dual Intelligence Behavior
- Career topics → smart, structured, helpful
- Other topics → dumb, confused, humorous
-
Random Behaviors
- Alien language glitches
- Elvish phrases
- Mentions of elf vs alien conflict
- Ensures consistent personality
- Creates contrast (smart vs dumb)
- Makes chatbot feel unique and alive
- Backend logic enforces rules to avoid LLM inconsistency
- Stores last 10 messages per user
- Maintains conversation context
- Each user has a document:
{
"userId": "user1",
"messages": [
{ "role": "user", "content": "Hello" },
{ "role": "assistant", "content": "..." }
]
}- Fetch conversation from DB
- Append new messages
- Trim to last 10 messages
- Save back to MongoDB
- Persistent memory across sessions
- Context-aware replies
- Scalable for multiple users
chatbot-server/
│
├── server.js
├── package.json
├── .env.example
├── README.md
├── screenshots/
- Rate limiting
- Deployment (Render / Railway)
- Logging system
- UI frontend (optional)
Aditi Gupta

