LaunchKit · 2026
Back to Skills

telegram-history

Fetch Telegram chat message history via MTProto user API (Telethon)

1
1.2k downloads
by @rhlsthrm

Setup & Installation

openclaw skills install @rhlsthrm/telegram-history

Or with the ClawHub CLI, for registry-managed skill folders outside a full OpenClaw workspace:

npx clawhub install telegram-history

Version History

v1.1.0Feb 17, 2026 - Version note by skill developer:

Fix: use relative paths instead of hardcoded home dir. Fix: SKILL.md now matches actual CLI arguments. Phone number is a required argument, not hardcoded.

What This Skill Does

Fetches message history from Telegram chats, groups, and forum topics using the MTProto user API via Telethon. The Telegram Bot API cannot read chat history, so this skill authenticates as a user account instead. Supports filtering by topic, pagination by message ID, and JSON output.

Unlike the Bot API, MTProto user authentication gives read access to any chat the account belongs to, including history the bot endpoint blocks entirely.

When to use it

  • Archiving old messages from a private Telegram group
  • Exporting a forum topic thread before it gets deleted
  • Paginating through thousands of messages in a large channel
  • Pulling chat logs into a local database for search
  • Reviewing message history in a group the bot API cannot access

Example Workflow

Here's how your AI assistant might use this skill in practice.

INPUT

User asks: Fetch the last 50 messages from group -1001234567890 as JSON

AGENT
  1. 1Load api_id and api_hash from api_credentials.json in the skill directory
  2. 2Resume the saved Telethon session for the authenticated user account
  3. 3Call tg_history.py with the chat ID, --limit 50, and --json flags
  4. 4Resolve sender display names for each message
  5. 5Return the formatted JSON array
OUTPUT

A JSON array of 50 messages with sender names, timestamps, and message text

Requirements

Accounts, API keys, or tools you or your AI assistant may need to set up while using this skill.

Telegram API credentials (api_id and api_hash) from https://my.telegram.org/appsTelegram account phone number for one-time login