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!

System Requirements

System Requirement Document
Page 1 of 5

chat_bot System Requirements Document (SRD)

1. Introduction

The purpose of this document is to outline the system requirements for the "chat_bot" project, which aims to develop a Personal AI WhatsApp Assistant. This assistant is designed to be lightweight, modular, and capable of generating human-like responses while being easy to integrate with the WhatsApp Cloud API.

2. System Overview

The chat_bot project is a production-ready Personal AI WhatsApp Assistant that processes incoming messages via a webhook, generates natural replies, and maintains a lightweight conversation history. The system is designed to be modular, allowing for easy future enhancements, and is optimized for low token usage and API costs.

2a. Source Content Inventory

  • Profile Information: Stored in profile.json to maintain a small memory footprint.
  • Database: SQLite with tables for Users, Conversations, Messages, and Settings.
  • System Prompt: Ensures the assistant behaves like the user, avoiding AI-specific language.
  • API Endpoints: Includes /chat, /webhook, /history/{phone}, and /health.
Page 2 of 5

3. Functional Requirements as Story Points

  • As a User, I should be able to send messages to the assistant via WhatsApp and receive human-like replies.
  • As a Developer, I should be able to configure the AI model and other settings via a .env file.
  • As a User, I should be able to view the conversation history with the assistant.
  • As a Developer, I should be able to easily integrate the assistant with the WhatsApp Cloud API.
  • As a User, I should receive replies that match my texting style, including tone and formality.
  • As a Developer, I should be able to maintain and update the assistant's modular components easily.

4. User Personas

  • User: An individual interacting with the AI assistant via WhatsApp.
  • Developer: A technical user responsible for configuring and maintaining the assistant.

5. Core User Flows

  1. Message Processing:

    • User sends a message via WhatsApp.
    • Webhook receives the message.
    • Load user profile and recent conversation.
    • Build a prompt based on the profile and recent messages.
    • Generate a reply using the AI model.
    • Save the conversation and return the response to the user.
  2. Configuration and Setup:

    • Developer configures settings in the .env file.
    • Developer sets up the SQLite database.
    • Developer deploys the application and connects it to the WhatsApp Cloud API.
Page 3 of 5

6. Visuals Colors and Theme

[Default — not specified by user]

  • primary: #007bff (blue)
  • primary_light: #66b2ff (light blue)
  • secondary: #6c757d (gray)
  • accent: #28a745 (green)
  • highlight: #ffc107 (yellow)
  • bg: #f8f9fa (light gray)
  • surface: #ffffff (white)
  • text: #212529 (dark gray)
  • text_muted: #6c757d (muted gray)
  • border: #dee2e6 (light gray)

7. Signature Design Concept

Interactive Chat Interface

The homepage will feature an interactive chat interface that mimics a real WhatsApp conversation. Users can click on messages to see how the AI generates responses in real-time. The interface will include subtle animations, such as message bubbles expanding and contracting, and a typing indicator that mimics human typing speed.

  • Animations: Message bubbles will animate into view with a slight bounce effect using motion/react.
  • Interaction: Users can hover over messages to see timestamps and additional options.
  • Responsive Design: The interface will adjust to different screen sizes, maintaining usability on both desktop and mobile devices.
Page 4 of 5

LANDING HERO MOTION BRIEF

The landing page will feature a dynamic illustration of a smartphone screen displaying a conversation. As users scroll, the conversation bubbles will animate into view, showcasing the AI's ability to generate human-like responses. The animation will loop every 10 seconds, highlighting different texting styles and tones.

8. Interaction Model & Motion Direction

  • Intended Interaction Model: Animated
  • Internal Pages: Static for configuration and settings pages.
  • Distinctive Core Mechanic: The landing page will feature a kinetic typography effect, where key phrases animate into view as users scroll.

9. Non-Functional Requirements

  • The system must be lightweight and optimized for low token usage.
  • The assistant must generate responses within 2 seconds.
  • The system must be modular to allow easy integration of new features.
Page 5 of 5

10. Tech Stack

  • Frontend: Not applicable (backend-focused project)
  • Backend: Python, FastAPI
  • Database: SQLite with SQLAlchemy ORM
  • AI: OpenAI Compatible API
  • Configuration: python-dotenv
  • Logging: Built-in logging
  • HTTP: httpx
  • Validation: Pydantic

11. Assumptions and Constraints

  • The assistant will not handle complex memory or RAG.
  • The system will not use vector databases or embeddings.
  • The assistant will not perform semantic searches.

12. Glossary

  • AI: Artificial Intelligence
  • API: Application Programming Interface
  • LLM: Large Language Model
  • RAG: Retrieval-Augmented Generation
  • Webhook: A method of augmenting or altering the behavior of a web page or web application with custom callbacks.
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