Skip to content

whatsapp

diapason.connectors.whatsapp

WhatsApp chat export connector.

Reads WhatsApp chat history from exported .txt files. WhatsApp allows exporting individual chats via Chat → More → Export Chat on iOS/Android, producing plain-text files in a well-known format.

Export line format::

1/15/24, 10:30 AM - Alice: Hey, how are you?
1/15/24, 10:31 AM - Bob: Good thanks! Working on the project.

Each .txt file in the configured directory is parsed and yielded as a single :class:~diapason.connectors._stubs.Document with doc_type "message" and the message lines joined as content.

WhatsAppConnector

Bases: BaseConnector

Read WhatsApp message history from exported .txt files.

WhatsApp allows exporting individual chats as plain-text files via Chat → More → Export Chat. Point this connector at the directory containing those files (one file per chat) and it will parse each file into a :class:~diapason.connectors._stubs.Document.

Parameters

export_path: Path to the directory containing WhatsApp export .txt files. If empty, no documents are yielded.

disconnect()

No-op: filesystem connector has nothing to disconnect.

is_connected()

Return True if the export directory exists and contains .txt files.

mcp_tools()

Expose two MCP tool specs for real-time WhatsApp queries.

sync(*, since=None, cursor=None)

Parse WhatsApp export files and yield one Document per chat file.

Parameters

since: If provided, skip files (chats) whose most recent message is before this datetime. A file is included if any of its messages are on or after since. cursor: Not used (included for API compatibility).

Yields

Document One document per .txt export file. The document content is the full parsed text of the chat with timestamp and sender prefixes. Participants are extracted from the set of senders found.

sync_status()

Return sync progress from the most recent :meth:sync call.