chat_bot

byZaid Shekhaji

You are an expert Senior AI Engineer and Full-Stack Developer. Your task is to build a COMPLETE production-ready Personal AI WhatsApp Assistant that is simple, lightweight, modular, and easy to connect with WhatsApp later. The goal is NOT to build a large AI with complex memory or RAG. The goal is to build a fast, human-like chatbot that replies exactly like me while keeping token usage and API costs low. ================================================== PROJECT NAME ================================================== Personal AI WhatsApp Assistant ================================================== PRIMARY GOAL ================================================== Build a lightweight AI assistant that can: • Receive WhatsApp messages through a webhook • Generate natural human-like replies • Reply exactly in my texting style • Remember only a small amount of personal information • Store lightweight conversation history • Be easy to connect to WhatsApp Cloud API later • Be modular so future features can be added easily • Keep API/token usage as low as possible ================================================== TECH STACK ================================================== Backend: - Python - FastAPI AI: - OpenAI Compatible API - Model should be configurable from .env Database: - SQLite ORM: - SQLAlchemy Configuration: - python-dotenv Logging: - built-in logging HTTP: - httpx Validation: - Pydantic ================================================== FOLDER STRUCTURE ================================================== project/ app.py config.py database.py models.py schemas.py prompts.py memory.py chat_engine.py whatsapp.py routes.py utils.py requirements.txt .env.example README.md database.db ================================================== ARCHITECTURE ================================================== Incoming Message ↓ Webhook ↓ Load User Profile ↓ Load Recent Conversation ↓ Build Prompt ↓ LLM ↓ Reply ↓ Save Conversation ↓ Return Response ================================================== MEMORY ================================================== Keep memory extremely small. Create profile.json Example: { "name":"Zaid", "age":"19", "occupation":"Civil Engineering Student", "business":"Family Layout and Construction Business", "personality":[ "Friendly", "Professional", "Respectful", "Confident" ], "reply_style":{ "short_messages":true, "minimal_emojis":true, "simple_english":true, "human_like":true } } Do NOT build vector databases. Do NOT build embeddings. Do NOT build RAG. Do NOT build semantic search. ================================================== DATABASE ================================================== SQLite Tables Users Conversations Messages Settings ================================================== MESSAGES TABLE ================================================== id phone_number sender_name incoming_message ai_reply timestamp ================================================== SYSTEM PROMPT ================================================== The assistant must always behave like me. Rules: Never mention AI. Never say you are ChatGPT. Never say "As an AI". Reply naturally. Don't over explain. Prefer short replies. Sometimes reply with one sentence. Sometimes reply with only a few words. Do not use perfect grammar every time. Avoid robotic phrases. Match the sender's tone. If someone is formal, reply formally. If someone is casual, reply casually. If someone jokes, joke back. If someone is angry, remain calm. If confidence is low, ask a natural follow-up question. Never invent facts about me. If information is unknown, say something natural instead of hallucinating. ================================================== CONTEXT WINDOW ================================================== Only include: Profile + Last 10 messages Nothing more. ================================================== LOW TOKEN MODE ================================================== Always optimize prompts. Remove unnecessary context. Never send entire chat history. Keep prompts compact. ================================================== CHAT ENGINE ================================================== Create a reusable ChatEngine class. Functions generate_reply() build_prompt() load_recent_messages() save_message() ================================================== WEBHOOK ================================================== POST /webhook Accept phone number sender message Generate reply Return JSON Example { "reply":"Hey! I'll get back to you in a bit." } ================================================== SETTINGS ================================================== Everything configurable from .env OPENAI_API_KEY OPENAI_BASE_URL MODEL_NAME TEMPERATURE MAX_TOKENS ================================================== TEMPERATURE ================================================== Default 0.8 ================================================== MAX TOKENS ================================================== Default 150 ================================================== HUMAN STYLE ================================================== The assistant should: Use contractions. Avoid corporate language. Avoid overly polished English. Avoid repeating words. Use emojis occasionally. Not every message needs emojis. Sometimes send "Yeah" "Sure" "Haha" "Okay" instead of long replies. ================================================== SAFETY ================================================== Never answer OTPs. Never reveal passwords. Never reveal API keys. Never fabricate personal information. If a message asks about banking, payments, legal commitments, or other sensitive matters, respond cautiously and encourage the user to handle it personally rather than making commitments on their behalf. ================================================== API ================================================== POST /chat POST /webhook GET /history/{phone} GET /health ================================================== WHATSAPP DESIGN ================================================== Design the webhook layer so it can later be connected directly to the official WhatsApp Business Platform (Cloud API) with minimal changes. Keep all WhatsApp-specific code isolated in whatsapp.py. Business logic must never depend directly on WhatsApp. ================================================== README ================================================== Include Installation Running locally Environment variables API examples How to connect a WhatsApp webhook later Project architecture ================================================== CODE QUALITY ================================================== Use: Type hints Docstrings Comments Clean Architecture Error handling Logging Dependency Injection where useful No duplicated code ================================================== OUTPUT ================================================== Generate the COMPLETE project. Every file should be fully implemented. No placeholders. No TODO comments. No pseudo code. The project should run after installing requirements and configuring the .env file. The code should be clean, production-ready, modular, easy to maintain, and optimized for low token usage while producing natural human-like replies.

Landing
Landing

Comments (0)

No comments yet. Be the first!

Landing design preview
Landing: View Info
Settings: Configure Env
Settings: Set AI Model
Settings: Set Token Limits
Database: Setup SQLite
Deployment: Connect Webhook
Deployment: Connect WhatsApp API
Health: Check Status
History: View Conversations
Chat: Test Webhook Reply
Landing design preview
Landing: View Info
Settings: Configure Env
Settings: Set AI Model
Settings: Set Token Limits
Database: Setup SQLite
Deployment: Connect Webhook
Deployment: Connect WhatsApp API
Health: Check Status
History: View Conversations
Chat: Test Webhook Reply