{
  "id": 5179233,
  "title": "Making three years of a Telegram group chat queryable",
  "url": "https://urgent.news/2026/09/02/making-three-years-of-a-telegram-group-chat-queryable",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-02T21:51:04.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/mikhkonkov/making-three-years-of-a-telegram-group-chat-queryable-54j2"
  },
  "original_language": "en",
  "account": "Telegram groups are like knowledge bases that are difficult to access. Within these chats, there may be important details such as the time it took for the tax office to process requests, which forms replaced older versions, and which accountants are no longer recommended. However, Telegram's search function is limited to finding known words and cannot answer questions. To overcome this limitation, a pipeline is required to extract the chat history, convert it into documents, and hand it over to a reading system like NotebookLM. The parsing process has its challenges, and I will detail them below, but the core design problem lies elsewhere: packing the data and ensuring the process is idempotent, meaning it can be repeated without errors.\n\nTelegram Desktop has offered the ability to export chat history since 2018, providing JSON or HTML formats. The native macOS application, added in version 12.10, writes HTML only, while the Mac App Store build was still on version 12.9 without the menu item. Telegram Web and mobile apps do not have this export option. Therefore, it is necessary to read both JSON and HTML formats.\n\nJSON exports contain a list of messages, where a plain message has text: \"hello\", while a message with a link, bold text, or a code span has an array of runs. The string representation of the text becomes \"[object Object]\" in the document, which is undesirable. To address this, a function is created to convert the content value to a string. This function handles various cases, including arrays, objects, and undefined/null values.\n\nThe HTML export presents three traps that can cause issues when processing the data. Firstly, the sender's name is only displayed for the first message in a sequence by the same person. Subsequent messages have no author, so the last name is carried forward. Forwarded messages introduce a second author. Desktop displays the original sender's name inside a div with the class \"forwarded body\". To handle this, the author must be extracted from the chunk before the forwarded message.\n\nSecondly, the format of dates differs between macOS and Desktop. macOS writes dates as \"9 September 2020, 18:44:51\", while Desktop writes \"09.09.2020 18:44:51 UTC+01:00\". Both formats need to be normalized to ISO format to ensure proper ordering when comparing dates.\n\nThirdly, the packing process poses a challenge. NotebookLM caps a source at 500,000 words, with the more restrictive cap being the number of sources per notebook. The expensive mistake is under-filling the source, leading to wasted budget. To pack the pages efficiently, a greedy bin-pack algorithm is used, filling each file to a specific word budget without splitting messages across files. However, this approach requires careful consideration of the file's frontmatter, which is written after packing and counts toward the word limit. Additionally, the separators between messages and the file's frontmatter also contribute to the word count. To ensure the final render does not exceed the word limit, the rendered Markdown should be measured instead of the raw text. The indices and ranges of each file are used as memoized values to avoid re-rendering the entire batch for each message, making the process more efficient with a time complexity of O(1) per message addition.",
  "summary": "A three-year group chat is a knowledge base nobody can read. Somewhere in it is how long the tax office actually took, which form replaced the old one, which accountant people quietly stopped recommending. Telegram's search finds a word you already know. It cannot answer a question. The fix is boring in outline: get the history out, turn it into documents, hand them to something that reads —…",
  "key_points": [
    "Telegram groups contain valuable information not easily accessible through search function",
    "Export feature available in Telegram Desktop since 2018, providing JSON or HTML formats"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}