README.md (9175B)
1 # WhatsApp Logger (Self-Hosted) 2 3 A privacy-focused, self-hosted WhatsApp archiving tool. It captures messages (including deleted ones) via a linked device connection and stores them in your own Firebase Firestore database. 4 5 > [!IMPORTANT] 6 > **Update Notice** 7 > 8 > I'm trying to build a feature to save media like images, videos, and voice messages — but Firebase's free tier caps storage at 1GB, so it's not viable for that. I'm planning to add this as an optional feature using Hugging Face for storage instead. Messages will continue to be stored in Firebase as before. Frontend and Firebase security are also being upgraded as part of this effort. 9 > 10 > Okay, so, I made the [plan](plan.md). 11 > 12 > **Please do not sync your fork with this branch for now, as it may break the logger.** 13 14 > [!IMPORTANT] 15 > Using this logger is completely safe and will not get your WhatsApp account banned. Here is why: 16 > 17 > * **100% Passive (Read-Only):** WhatsApp bans accounts for *sending* spam, bulk messages, or unauthorized automated replies. This logger does not send messages; it acts strictly as a passive listener, which does not trigger WhatsApp's anti-spam algorithms. 18 > * **Standard Linked Device:** The tool connects to WhatsApp using the official Multi-Device WebSocket protocol. To WhatsApp's servers, this connection looks exactly like you logging into standard WhatsApp Web on a secondary browser. 19 > * **No User Reports:** The number one cause of bans is other users reporting an account. Since this logger works silently in the background and does not interact with anyone, there is zero risk of being reported. 20 21 ### Check <a href="https://amit.is-a.dev/logger">guide</a> for detailed installation process. 22 <a href="https://www.producthunt.com/products/whatsapp-logger-self-hosted?embed=true&utm_source=badge-featured&utm_medium=badge&utm_campaign=badge-whatsapp-logger-self-hosted" target="_blank" rel="noopener noreferrer"><img alt="WhatsApp Logger (Self-Hosted) - Privacy-focused WhatsApp archiving with Anti-Delete. | Product Hunt" width="250" height="54" src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=1122776&theme=light&t=1776172043162"></a> 23 24 ### Important notes: 25 * It is recommended to download the **web app (PWA)** after the publication of the webpage for better security and native experience. 26 * It is recommended to use **PIN** or **Biometric authentication** inside the web app. Find the authentication options in Settings. 27 28 ## Features 29 30 * **Anti-Delete**: Logs messages instantly, preserving them even if the sender deletes them. 31 * **Privacy First**: You host the backend and database. No third-party servers access your data. 32 * **Secure Access**: Frontend is protected by a password validated against your backend. 33 * **Media Support**: Captures text messages (Images/Media support depends on Baileys implementation, primarily text-focused). 34 * **Search & Filter**: Search by content or filter by date. 35 * **Export**: Export chat logs to `.txt` files. 36 * **Offline Ready**: Uses IndexedDB caching so you can read your logs even without an internet connection. 37 38 --- 39 40 ## Prerequisites 41 42 1. A **GitHub** Account. 43 2. A **Render** Account (Free tier works). 44 3. A **Firebase** Account (Free Spark plan works). 45 4. A **WhatsApp** account on your phone. 46 5. An **UptimeRobot** Account (Free). 47 48 --- 49 50 ## Step 1: Firebase Setup (The Database) 51 52 1. Go to the [Firebase Console](https://console.firebase.google.com/) and create a new project. 53 2. **Create Database**: 54 * Navigate to **Firestore Database** in the sidebar. 55 * Click **Create Database**. 56 * Select a location (e.g., `nam5` or `eur3`). 57 * Start in **Production Mode**. 58 3. **Set Security Rules**: 59 * Go to the **Rules** tab in Firestore. 60 * Replace the rules with the following (allows anyone to read, but only backend with Admin SDK can write): 61 ```javascript 62 rules_version = '2'; 63 service cloud.firestore { 64 match /databases/{database}/documents { 65 match /{document=**} { 66 // 1. Allow Read: Essential for your HTML page to fetch chats. 67 allow read: if true; 68 69 // 2. Allow Update: Enables the "Rename Chat" feature from the frontend. 70 // This allows updating existing documents (like changing the name) 71 // but prevents creating NEW documents or Deleting them. 72 allow update: if true; 73 74 // 3. Block Create/Delete: Only the Backend (Render) can create new messages 75 // or delete them. This prevents random people from injecting fake chats. 76 allow create, delete: if false; 77 } 78 } 79 } 80 ``` 81 4. **Get Backend Credentials (Service Account)**: 82 * Go to **Project Settings** (Gear icon) -> **Service accounts**. 83 * Click **Generate new private key**. 84 * This will download a `.json` file. **Keep this safe.** You will need its content for Render. 85 5. **Get Frontend Configuration**: 86 * Go to **Project Settings** -> **General**. 87 * Scroll down to "Your apps" and click the **Web (</>)** icon. 88 * Register app (nickname: "Logger Frontend"). 89 * Copy the `firebaseConfig` object (API Key, Project ID, etc.). You will need this for `index.html`. 90 91 --- 92 93 ## Step 2: Deploy Backend (The Listener) 94 95 1. **Fork this Repository** to your own GitHub account. 96 2. Log in to [Render](https://render.com/). 97 3. Click **New +** -> **Web Service**. 98 4. Connect your forked repository. 99 5. **Runtime**: Select **Docker**. 100 6. **Environment Variables** (Critical Step): 101 Add the following variables under "Advanced": 102 * `FIREBASE_SERVICE_ACCOUNT`: Paste the **entire content** of the JSON file you downloaded in Step 1. 103 * `AUTH_USER`: Set a username (e.g., `admin`). 104 * `AUTH_PASS`: Set a strong password. This creates the lock for your logger. 105 7. Click **Create Web Service**. 106 8. Wait for the deployment to finish. Render will give you a URL like `https://your-app.onrender.com`. 107 108 --- 109 110 ## Step 3: Connect WhatsApp 111 112 1. Open your Render URL (`https://your-app.onrender.com`) in a browser. 113 2. You will be prompted for a login. Use the `AUTH_USER` and `AUTH_PASS` you set in Render. 114 3. You will see a **QR Code**. 115 4. Open **WhatsApp** on your phone: 116 * iOS: Settings -> Linked Devices 117 * Android: Three dots -> Linked Devices 118 5. Tap **Link a Device** and scan the QR code. 119 6. The page should refresh and say **"System Operational"**. Your backend is now listening! 120 121 --- 122 123 ## Step 4: Setup Frontend (The Viewer) 124 125 1. Download the `index.html` file from this repository. 126 2. Open `index.html` in a text editor (Notepad, VS Code, etc.). 127 3. Locate the Configuration section (around line 675). 128 4. **Fill in the details**: 129 * `RENDER_BACKEND_URL`: Your Render URL (e.g., `https://your-app.onrender.com` - **No trailing slash**). 130 * `firebaseConfig`: The keys you copied in Step 1.5. 131 132 **It should look like this before you edit it:** 133 ```javascript 134 const RENDER_BACKEND_URL = ""; 135 136 // Firebase Config 137 const firebaseConfig = { 138 apiKey: "", 139 authDomain: "", 140 projectId: "", 141 storageBucket: "", 142 messagingSenderId: "", 143 appId: "" 144 }; 145 ``` 146 147 5. **Deploy the Frontend**: 148 * You can host this single file anywhere: 149 * **Firebase Hosting** (Recommended): `firebase init` -> Hosting -> Select `public` directory -> Put `index.html` there -> `firebase deploy`. 150 * **GitHub Pages**: Enable Pages in your repo settings. 151 * **Netlify/Vercel**: Drag and drop the folder containing `index.html`. 152 153 --- 154 155 ## Step 5: Usage 156 157 1. Navigate to your hosted frontend URL. 158 2. You will see a Login Screen. 159 3. Enter the same `AUTH_USER` and `AUTH_PASS` you configured on Render. 160 4. Once unlocked, your chats will load from Firebase. 161 * **Sidebar**: Shows chat list sorted by newest activity. 162 * **Search**: Filter contacts by name or phone number. 163 * **Export**: Download chat history as a `.txt` file. 164 165 --- 166 167 ## Step 6: Keep it Alive (UptimeRobot) 168 169 Render's free tier spins down after inactivity. To keep your logger running 24/7: 170 171 1. Create a free account on [UptimeRobot](https://uptimerobot.com/). 172 2. Click **Add New Monitor**. 173 3. **Monitor Type**: HTTP(s). 174 4. **Friendly Name**: WhatsApp Logger. 175 5. **URL (or IP)**: `https://your-app.onrender.com/ping` (Make sure to add `/ping` at the end). 176 6. **Monitoring Interval**: 5 minutes. 177 7. Click **Create Monitor**. 178 179 --- 180 181 ## Troubleshooting 182 183 * **"No chats found"**: Send a message to the linked WhatsApp account to trigger the first log. 184 * **"Incorrect Credentials"**: Ensure your Render backend is running and you are using the exact Username/Password defined in Render Environment Variables. 185 * **Proof/Phone Numbers**: If a chat shows a long ID (e.g., `1155...@lid`), wait a few minutes. The backend automatically syncs contacts and updates the record with the real phone number. 186 187 ## Disclaimer 188 189 This tool is for personal archiving purposes. Using it to log conversations without consent may violate privacy laws in your jurisdiction. The author is not responsible for misuse.