messages_read_history
Read messages from a conversation thread. Use text_contains to find specific messages by content; media_type (photo, document, video, voice, link), date_from/date_to (YYYY-MM-DD, inclusive) and direction (incoming, outgoing) narrow the search and work without text: a photo with no caption sent by the other side in a given month is media_type='photo', direction='incoming' and the dates. A search runs over the loaded part of the conversation and, when that is not all of it, asks the channel's own server (Telegram) to search the rest and stores the hits (a search with text_contains also stores the neighbouring messages of its first 20 hits; one without words stores the hits alone). search_coverage says which: complete = true with a source, or complete = false with the reason, in which case an empty list is not proof the text is absent. sync.loaded_from is the date since which EVERY message is stored (null when unknown); sync.oldest_stored_at is the oldest message stored at all, gaps or not. Returns the most recent messages, including sender info and timestamps.
Voice calls: each row carries a meta object with allowlisted keys (event_type ∈ 'call_started'|'call_ended'|null, source ∈ 'voice_transcript'|null, call_id, speaker_display_name, duration_seconds, outcome, direction) plus per-message channel. To find calls without scanning every row, use calls.list_history instead.
Usage:
Get thread_id from threads.list first, OR
Use contact_name to auto-resolve thread_id
Examples:
User: 'show me messages from chat with [contact]' → read_history(contact_name='[contact]', limit=10)
User: 'last 5 messages from thread 571' → read_history(thread_id=571, limit=5)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of messages to return (default: 10, max: 100) | |
| before | No | Cursor for the page of OLDER messages of a chat read live (`source: "live"`, a Discord channel that is not synced): pass the previous answer's `next_before`. Pages hold at most 100 messages (limit). A stored chat pages with offset instead (the answer's `next_offset`). OMIT for the newest page. | |
| offset | No | Number of messages to skip (for pagination, default: 0) | |
| date_to | No | Filter: only messages sent on or before this day (YYYY-MM-DD, UTC). | |
| date_from | No | Filter: only messages sent on or after this day (YYYY-MM-DD, UTC). | |
| direction | No | Filter: 'incoming' = written by the other side, 'outgoing' = written by the owner of the connected account. OMIT for both. | |
| thread_id | No | Thread ID from threads.list (e.g. '571'), or a channel_ref (e.g. 'telegram:1306644770'). Optional if contact_name provided. | |
| load_until | No | Load this conversation's history down to this day (YYYY-MM-DD, UTC) in the background, a page at a time. For a channel whose server cannot search (WhatsApp), or to read everything around a date. The answer's `history_load` says how far back the history reaches now and, once the run is over, why it stopped; call again to follow it. OMIT for a normal read. | |
| media_type | No | Filter: only messages carrying this kind of attachment. Works without text_contains, which is how a photo or document sent without a caption is found. OMIT for every kind. | |
| contact_name | No | Contact/thread name to search for (optional if thread_id provided). Example: 'Jane Smith', 'John Doe' | |
| in_workspace | No | Run this one call in this workspace id instead of the session's. Nothing is stored; other sessions are not affected. | |
| text_contains | No | Filter: only return messages containing this text (case-insensitive substring match) | |
| include_outgoing | No | Include messages sent by you (default: true) | |
| channel_account_id | No | Connected account the conversation must belong to, when you know it (from channels.list). Scopes the lookup to that account, so the same person reached on two connected accounts cannot be confused for one, and a chat that does not exist on this account is 'not found' instead of someone else's thread with a matching id. |