Use with your agent

Search messages and chats by words or meaning

Search Telegram and MAX messages saved on your computer by words, word forms, typos or meaning, and find the person, chat or file you need.

Find messages, agreements, people, chats and documents across your chats. Learn what you can search, how to choose a search method and how to check the source messages, even when you remember only part of a phrase or its subject.

What you can search:

  • Messages and discussions — by text, sender, date, subject and nearby messages.
  • Contacts and people — by name, username or ID, then recall what you discussed.
  • Chats, groups and channels — by title among your account's chats.
  • Files — by filename, extension and contents, once the document's text has been extracted and saved.
  • Links and attachments — for example, messages with a link, PDF or voice note; voice transcripts become searchable once their text is saved.

Content search supports text files, Word and PDFs with text layers. Scans and photos need text recognition first; ask your agent to do that. Details: Telegram files and MAX. See People for finding a person.

For word forms, typo handling and meaning-based search, see How search works.

Which kinds of content are indexed, and what each one needs (a command, a model or a setting): What gets indexed.

On this page:

  1. Fetch the relevant chat history first
  2. Search everything at once
  3. Search CRM deals and keep work apart
  4. Find a word or phrase
  5. When you don't remember the exact wording
  6. Narrow the conversation
  7. Choose the command
  8. Narrow first, then search
  9. The operators
  10. Words, forms and meaning
  11. Page through the results
  12. Keep the output small
  13. Read the evidence, then widen
  14. Recipes
  15. Common mistakes
  16. If a result is missing
  17. Try it with sample messages
  18. Build a Lucene query
  19. Check the result
  20. More precise queries and technical details
  21. Search pages

Fetch the relevant chat history first

Before searching older messages, download the conversations for the period you need. Logging in does not download all history. Word search can also query the messenger’s server by default: tg asks Telegram for word candidates, and so does max with MAX: within the chat you name, or across all chats with one best match from each. --backend archive keeps word searches local. Topic search and counts use saved messages. File filters are evaluated against the local archive, even when a word search also retrieves server candidates. If that conversation is missing, an empty result does not mean the message was never sent.

Ask your agent to fetch the selected chats or run your messenger's command. Replace Project with the chat title; this example downloads the past month, up to 1,000 messages per run:

tg personal messages sync "Project" --since-time 30d --limit 1000
max personal messages sync "Project" --since-time 30d --limit 1000

If the limit is reached, that month's history may still be incomplete. Instructions for fetching, resuming and checking history: Telegram and MAX.

Search everything at once

When you do not know where something was written — a chat or your own notes — search both together:

tg personal search all invoice
max personal search all invoice

Each result says whether it is a message or a note. tg and max do not search mail: memo search mail does, and memo search all invoice searches messages, mail and notes at once. The next sections, from search CRM deals on, search one kind.

Search CRM deals and keep work apart

memo search all also finds the deals and leads a CRM tool such as b24 stored, by the words of their title. --only crm searches them alone:

memo search all 'renewal' --only crm

People and companies are not in search all. Find them with memo search people and memo organizations list. A deal outside the CRM account's sync scope is not found either.

An agent that uses memo's MCP server sees in search all only what its permissions let it list. When the server denies deals.list or leads.list, those hits are left out, and the answer says so in an issue for crm. crm.list leaves the whole CRM part out, and business.list leaves out invoices, payments, orders, contracts, subscriptions, products and wallets. --only crm and --only business search one part alone, and are refused when that part is denied. These permissions do not limit a search you run yourself in a terminal.

memo search all 'renewal' --only business

A question about who someone is, or how a person, a company and a deal relate, is better answered from their context than from search. Ask your agent to work in this order:

  1. Find the one record: memo search people, memo organizations list or memo deals list.
  2. Read its context: memo context person:<id>, memo organizations context <ref> or memo deals context <ref> --brief.
  3. Follow only the relationships the question needs, for example memo relationships list kind:reports-to 'to:"person:12"'.
  4. Search for the evidence after that, with memo search all.
  5. Cite the references, and name every gap the answer lists under "Not read". A reported relationship is only the CRM's word.

Clients, colleagues and deals shows these answers with examples.

Groups of accounts

A group keeps your work accounts apart from your personal ones. With no group named, a run reads every account: that is the group all, which always exists and never leaves anything out. personal, work and any other group are groups you save yourself. Put the CRM account and your work mailbox in work, then name the group first, and the run reads only its accounts:

memo groups add work bitrix24:example.bitrix24.com
memo groups add work email:owner@northstar.example
memo groups add personal telegram:100
memo groups add personal email:owner@northstar.example
memo groups list
memo work search all 'renewal'

An account can be in two groups. memo groups list shows each saved group, then all, and marks every account that another group holds too. Duplicates are allowed, and the list ends with them. It also shows each account's profile names in every tool, such as the profile work in tg and in b24, once those tools have run. A profile named like a group is only a suggestion and never puts an account in that group.

$ memo groups list
work
  bitrix24:example.bitrix24.com
  email:owner@northstar.example  also in personal
personal
  telegram:100
  email:owner@northstar.example  also in work
all
  bitrix24:example.bitrix24.com  all  also in work
  email:owner@northstar.example  all  also in work, personal
  google-calendar:owner@northstar.example  all
  telegram:100  all  also in personal
duplicate: email:owner@northstar.example is in work, personal

memo groups remove personal email:owner@northstar.example takes the mailbox out of personal, so it is no longer a duplicate, and all still reads it. memo groups move telegram:100 personal work moves an account in one write: first the account, then the group it leaves, then the group it joins. A group you never saved does not exist: a run that names it is refused, and the answer lists your groups and the profiles named like it. After the first sync of a CRM account that no saved group lists, the sync's answer suggests memo groups add work with that account. MEMO_GROUP=work works like the first word for every command. --source personal means your own messenger accounts and not the group personal.

A group narrows the messages, mail, calendar events, CRM records and people a run reads. What you make yourself in memo belongs to no account, so it is in every group: your notes, projects, tasks, invoices, memories and facts. memo work search all 'renewal' finds the deal and the mail, and memo personal search all 'renewal' finds only the mail.

A run that names no group still reads every account. To keep an agent inside one group, start its memo with MEMO_GROUP_LOCK, for example MEMO_GROUP_LOCK=work memo mcp serve. Under the lock, memo refuses the messages, mail, calendar events, CRM records and people of accounts outside the group. It also refuses another group, --source all, an account outside the group and a change to the groups, and the agent cannot lift the lock. A command that cannot keep to a group is refused as a whole, so the lock fails closed:

$ MEMO_GROUP_LOCK=work memo messages show msg:telegram/100/201/1
{"error":{"code":"permission_error","reason":"access.denied","message":"this process is locked to group work (MEMO_GROUP_LOCK) — msg:telegram/100/201/1 belongs to an account outside it","details":{"reference":"msg:telegram/100/201/1"},"retry":{"safe":false}}}

$ MEMO_GROUP_LOCK=work memo personal search all renewal
{"error":{"code":"permission_error","reason":"access.denied","message":"this process is locked to group work (MEMO_GROUP_LOCK) — group \"personal\" (first word) is refused","retry":{"safe":false}}}

What the group holds still answers. Alice's context under the lock reads only the CRM account and counts the accounts it kept out without naming them. Memories and facts leave out evidence and sources outside the group and say how many they left out. memo relationships list leaves out a row whose end only an outside account saw. Your own tasks stay visible:

$ MEMO_GROUP_LOCK=work memo context person:3
Alice  person:3
...
Business
Organizations
  Acme Ltd  organization:1  member-of contact (Procurement manager) reported by bitrix24:example.bitrix24.com
...
Not read: other accounts — 2 outside group work
Read: bitrix24:example.bitrix24.com

$ MEMO_GROUP_LOCK=work memo tasks list project:ATLA
ATLA-1 · open · chore · ATLA · Follow up on the Acme renewal

Which commands run under the lock: Lock an agent to a group.

Find a word or phrase

Start by asking your agent. For MAX, write “max CLI” instead of “tg CLI”:

Request
Use tg CLI. Find where we agreed the renovation deadline in the group and my chat with the contractor. Show the final agreement, check later replies and cite the messages. If history is missing, tell me what needs fetching. Don't send anything.

You should get the agreed date and the messages behind it. If the date was only proposed or later changed, the answer should make that clear. You do not need to know the search syntax.

Optional: commands for the terminal
tg personal search messages invoice
max personal search messages invoice

For an exact phrase, keep the quotes inside the query:

Optional: commands for the terminal
tg personal search messages 'exact:"final invoice"'
max personal search messages 'exact:"final invoice"'

Results link back to messages. Ask your agent to show nearby messages before interpreting an agreement: one line may miss a correction or a later answer.

When you don't remember the exact wording

Message search offers several approaches:

  • A word or exact phrase: when you remember the wording. Use exact: for literal matching.
  • Part of a word: flat* finds words starting with that part, such as “flat” and “flats”.
  • Word forms and shared stems: “invoice” can find “invoices”. Which forms match depends on the archive's language settings.
  • Typos: the default search does not correct typos. Ask your agent to allow misspellings: it can add --discover, which also tries close spellings of the words in the local archive, or search by the start of the word.
  • Meaning: when you remember the subject, such as “the renovation deadline we agreed”, rather than the words. This needs a prepared discussion index.

Word forms, exact matching, indexes and meaning-based search: How search works. Detailed syntax: Telegram and MAX. The --discover option is listed in the command references for Telegram and MAX. These modes describe message search; chat-title and person-name lookup can behave differently.

Narrow the conversation

Optional: commands for the terminal
tg personal search messages 'invoice chat:"Project"'
max personal search messages 'invoice chat:"Project"'

You can also filter by person, date or attachments. The Telegram and MAX guides give examples you can adapt.

Choose the command

You have a lot stored, and an agent pays for every result it reads. This page shows how to get the right records in the fewest steps: pick the command, narrow before you search, page through results and trim the output. After it, you can turn a vague question into one precise search and check what the search covered. It assumes the history you need is already downloaded: Searching.

Put the tool name and your profile name in front of each command, as in tg personal search messages.

You wantRunNotes
Words in your Telegram or MAX messagessearch messages in tg or maxReads the local archive and, by default, the messenger's server
A phone, email, link or person's name written in messagessearch messages with phone:, email:, domain: or mentions:, or mentions listFound by rules, in any spelling
Everything about one person, in every messengercontacts eventsNeeds the identities linked with contacts link
A discussion, when you remember the subject and not the wordssearch conversationsNeeds conversations rebuild and conversations embed once for the chat
A picture by what it showssearch messages "dog on a beach"English only, and the picture setting must be on: What gets indexed
Mail, notes, or you do not know where it was writtenmemo search all, memo search mail, memo search notesThe answer lists the sources it skipped and why
Messages of every messenger at oncememo search messagesMessages only
A decision or a promisememo facts listEach fact links to its evidence
A Drive document, by words or meaningdrive search--exact for words only
A Drive file, by name, type, folder, person or tagdrive catalog list or drive catalog searchMetadata only, works offline

A search that names a chat, a sender and a period reads fewer records and returns fewer wrong ones. Add filters in this order: chat, sender, date, kind, attachment, then the words.

FilterFindsExample
chat:One chat, by name or idchat:"Book club"
from:One senderfrom:"Kai Sample"
date:A period, or everything after a daydate:[2026-01-01 TO 2026-02-01}, date>=2026-10-01
kind:Private chats, groups, channels, botskind:group
has:Messages with a file, photo, voice note, link or texthas:file
filename:A file by its namefilename:*.pdf
mime:A file by its type (Telegram only)mime:"application/pdf"
size:Files by sizesize>10MB
content:Words inside a filecontent:invoice
transcript:Words said in a voice notetranscript:invoice
tag:Your own labelstag:work
phone:, email:, url:, domain:, mentions:A value found in the textphone:"+1 555 010 0100", mentions:"person:7"

Field names are case sensitive, and an unknown field is an error, not an empty answer. The full list of fields is in the query language of Telegram and MAX. The last row is in the latest releases of tg and max.

tg personal search messages 'chat:"Book club" from:"Kai Sample" date>=2026-10-01 delivery' --limit 10

When the messenger's own server is asked too, only the words, one chat, one sender and the dates go to it. has:, tag:, negations and wildcards are applied locally. Details: How search works.

The operators

WriteMeaning
invoice paidBoth words, in any order (AND is the default)
alpha OR betaEither word
alpha NOT beta, alpha -betaThe first word without the second
+alphaThe word must be there
(alpha OR beta) gammaA group
from:(alice OR bob)One field for several values
date:[2026-01-01 TO 2026-02-01}A range: [ ] includes the end, { } excludes it
invo*Any ending
text:/pass(port)?/A regular expression, matched against whole words

Three rules prevent most surprises:

  • A query that is only a negation selects nothing. Pair it with a positive condition: has:photo NOT has:text.
  • An explicit AND binds tighter than OR. alpha OR beta gamma means (alpha OR beta) AND gamma.
  • and, or and not in lower case are ordinary words. Typos such as invoice~1 and boosts such as invoice^2 are errors.

Words, forms and meaning

A plain word finds its other forms: "invoice" finds "invoices". For the exact form only, use exact:invoice. Search does not correct typos: use the part you are sure of (invoi*), or add --discover to also try close spellings in the local archive. Words inside files and transcripts match the exact form only.

Use search conversations when you remember what a discussion was about and not which words were used. Ask in your own words, in any language the model reads. It always returns the nearest conversations, even when none of them answers, so open the messages before you rely on one. For an exact name, number or id, use a field search instead. More: Topic search.

Page through the results

The answer says whether more results exist (has_more). That describes the page, not whether the messenger holds more. Repeat the same command with the same filters and ask for the next page. Which flag does it depends on the command:

CommandNext page
search messages in tg and max--page <n>, counting from 1
contacts events--cursor <cursor>, with the cursor from the answer's page.next
mentions list, drive catalog list, drive catalog search--page <n>
memo search notes, drive search--offset <n>
memo search all, memo search mail, memo search messages--limit only, up to 100: narrow the query instead

Keep the output small

  • --limit <n> caps the hits.
  • --json=<fields> keeps only the fields you name, for example --json=ref,date,text. It is the one option that shrinks every answer: 31% to 64% smaller than full --json in our measurement.
  • --jsonl prints one result per line. It is no smaller than --json. --full returns whole texts.
  • --max-output-bytes caps machine output at 4 MiB by default. A result over the cap fails visibly instead of being cut.
  • --context <n> adds n neighbouring messages on each side of a hit. It is 0 when the output is not a terminal.

Read the evidence, then widen

Open one hit with its neighbours, or follow its reply chain:

tg personal messages context "msg:telegram/1/77/42" --before-n 3 --after-n 3
tg personal messages context "msg:telegram/1/77/42" --thread

If an answer looks thin, read its missing entry. It names what was not searched and the step that fixes it, such as downloading a chat. Each hit says where it matched (matched_in: text, transcript, filename or file). To compare the count with what you expect, stats messages show (in the latest releases) counts matches by chat, sender, day or hour.

Recipes

Replace the names with yours.

GoalCommand
An agreement and its sourcetg personal search messages 'chat:"Book club" agreed date>=2026-10-01' --limit 5
Everything about one person this monthtg personal contacts events "Kai Sample" 'at>=2026-10-01'
Where a phone number appearstg personal search messages 'phone:"+1 555 010 0100"'
Files sent in a chat last weektg personal search messages 'chat:"Book club" has:file date>=2026-10-07'
What a Drive document says about a topicdrive personal search 'budget' --exact --limit 5

For longer ones, see the recipes for Telegram and MAX.

Common mistakes

MistakeWhat happensInstead
Searching before the history is downloadedFew or no resultsDownload the chat first; read missing in the answer
Reading an empty answer as "never sent"The archive may be incompleteCheck what the answer says it covered
Quoting a phrase to get the exact formQuotes match any word formexact:"final invoice"
mime:application/pdf without quotesThe / starts a regular expressionmime:"application/pdf", or filename:*.pdf
mime: in MAXMAX does not report file typesfilename:*.pdf
has:photo to find what a picture showsIt only says a photo is attachedPicture search, in English
A message field in a Drive searchDrive has its own filterstag: and --exact, or catalog list
From: instead of from:An errorField names are lower case
Asking a picture search in another languageThe model knows English onlyHave your agent translate first

If a result is missing

By default, word search can also ask Telegram’s or MAX’s server. Topic search, counts and filters such as files or links need saved history: fetch the missing period, then search again. A word search is different from a search by meaning; try both when you remember only roughly how something was said. Check dates, chat scope and whether history is complete.

Try it with sample messages

Practise combining filters and checking sources before connecting an account. This playground contains 50 fictional messages in 6 chats, runs on your device and never connects to a messenger. The sample messages are in English: try invoice, budget or coffee.

  1. Start with a word or choose a filter.
  2. Narrow the results by person, chat, date or attachment type.
  3. Open a match to read its context, then change a filter and compare the results.

Sample dates run from two days before today to two days after it and use UTC. Type a field such as has: or in: to see its values. Press Space after a word or completed filter to see fields and operators; use ↑ / ↓ and Enter to insert a suggestion, or Esc to close it. Clear the query or choose All to browse every message.

Flexible search conditions

Find a message across your chats. See what came before, what changed, and where the answer comes from.

Build a Lucene query

Lucene syntax combines words with fields and logical operators. Start with invoice, then add conditions to narrow the result. Use uppercase AND, OR and NOT, and parentheses to make the grouping clear.

QueryWhat it finds
invoice AND budgetMessages containing both words.
Atlas AND (invoice OR budget)Atlas messages containing either invoice or budget.
invoice NOT has:fileInvoice messages without a file attachment.
"final invoice"The words together, in that order.
text:cof*Words starting with cof, including coffee.
text:*off*Words containing off, such as coffee or office. ? replaces one character.
chat:"Client studio" AND from:MiaMessages from Mia in Client studio. Quote names containing spaces.
in:max AND has:voiceVoice notes from a selected messenger. Choose a messenger from the in: suggestions.

text:coffee finds the word coffee. text:cof searches for the whole word cof, so it does not match coffee; add * when you only remember part of a word.

has: also offers attachment, link, file, photo, image, video, audio, sticker, contact, location and poll. has:attachment includes attached media; has:link finds links in the message text. You can combine them: (has:file OR has:link) AND text:budget.

Choose Date for today's date, the current month or the five-day sample window. The inserted query uses date:YYYY-MM-DD for a day or date:[START TO END] for an inclusive range. An asterisk leaves one end open; braces exclude the boundary. For example, the Before tomorrow suggestion uses date:{* TO YYYY-MM-DD} with tomorrow's date.

This playground implements the supported WireCat Lucene fields, rather than every Apache Lucene feature. Fuzzy matching (~), boosting (^) and fields such as filename: are unavailable here. An unfinished or unsupported query keeps the previous valid results visible and marks the problem; it does not silently broaden the search.

Check the result

Open the source of the best hit and compare it with what you remembered. If a kind of content never turns up, check the one step it needs: What gets indexed. If a link between records is missing, see How things are linked.

Next: the query language of Telegram or MAX lists every field, preset and date form.

More precise queries and technical details

Learn filters and operators in the Telegram query guide or MAX query guide. How search works explains indexing, conversations and ranking after the practical guides.

For the general grammar, read the official Apache Lucene query parser syntax. WireCat's references define which features work in the tools. The search architecture guide explains how message search, conversation graphs and embeddings fit together.

Search pages