Load Whatsapp Chats for Analysis
Load an exported WhatsApp chat .txt file into LlamaIndex documents with author metadata.
Why it matters
Ingest and structure your Whatsapp chat history for easier analysis and querying. This asset transforms exported chat logs into a format suitable for AI-powered insights.
Outcomes
What it gets done
Parse exported Whatsapp chat files (.txt).
Extract message timestamps, authors, and content.
Prepare chat data for indexing and retrieval with LlamaIndex.
Enable querying of specific individuals or message content within chats.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/li-reader-readers-whatsapp | bash Overview
Whatsapp chat loader
A LlamaIndex reader that parses an exported WhatsApp .txt chat file into per-message documents with author and timestamp metadata. Use for a chat already exported without media, to search or ask questions scoped by sender or time.
What it does
The WhatsApp Chat Loader loads an exported WhatsApp chat text file into LlamaIndex documents. A WhatsApp chat is exported without media from the app itself - opening the chat, then Menu > More > Export chat, choosing "Without media" - and the resulting .txt file is what the loader reads.
WhatsappChatLoader is initialized with the path to that exported file, and load_data parses it into documents. Messages are saved in the format {timestamp} {author}: {message}, which is useful for asking questions about what specific people said in a group chat. Each document automatically carries source (the file name), author, and timestamp metadata, so queries can be scoped to a particular sender or time.
When to use - and when NOT to
Use it when you have an exported WhatsApp chat and want to build a queryable index over what was said in it - by whom, and when - for a personal or group chat archive. Do not use it on a live, unexported chat; the loader only reads the static .txt export, so it has no access to messages sent after the export was taken, and it excludes media since the export used is the "Without media" option.
Capabilities
load_data parses an exported WhatsApp .txt chat file into Document objects, one per message, each carrying source, author, and timestamp metadata alongside the message text.
How to install
pip install llama-index-readers-whatsapp
Requires a WhatsApp chat already exported to a .txt file without media.
Who it's for
Developers or individuals who want to search or ask questions over the content of an exported WhatsApp conversation, scoped by sender or time.
Source README
Whatsapp chat loader
pip install llama-index-readers-whatsapp
Export a Whatsapp chat
- Open a chat
- Tap on the menu > More > Export chat
- Select Without media
- Save the
.txtfile in your working directory
For more info see Whatsapp's Help Center
Usage
- Messages will get saved in the format:
{timestamp} {author}: {message}. Useful for when you want to ask about specific people in a group chat. - Metadata automatically included:
source(file name),authorandtimestamp.
from pathlib import Path
from llama_index.readers.whatsapp import WhatsappChatLoader
path = "whatsapp.txt"
loader = WhatsappChatLoader(path=path)
documents = loader.load_data()
### see what's created
documents[0]
### >>> Document(text='2023-02-20 00:00:00 ur mom: Hi 😊', doc_id='e0a7c508-4ba0-48e1-a2ba-9af133225636', embedding=None, extra_info={'source': 'WhatsApp Chat with ur mom', 'author': 'ur mom', 'date': '2023-02-20 00:00:00'})
This loader is designed to be used as a way to load data into LlamaIndex.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.