home / skills / rohunvora / cool-claude-skills / tg-ingest

tg-ingest skill

/skills/tg-ingest

This skill helps you export, sync, and manage Telegram data from tg-ingest, improving context sharing and DM/group insights for AI workflows.

npx playbooks add skill rohunvora/cool-claude-skills --skill tg-ingest

Review the files below or copy the command above to add this skill to your agents.

Files (6)
SKILL.md
3.9 KB
---
name: tg-ingest
description: >
  Primary Telegram interface. Full-featured CLI for message export, DM management,
  group sync, contact scoring, and thread state. Use when user mentions "telegram",
  "tg", "@username", or telegram-specific terms. Triggers: "telegram messages",
  "export telegram", "telegram DMs", "telegram groups", "sync telegram",
  "@username messages", "telegram contacts". This is STANDALONE - do not defer
  to unified-messages for telegram operations.
---

# Telegram Export (tg-ingest)

Primary interface for all Telegram operations. **Standalone and full-featured.**

**Location**: `/Users/satoshi/data/tg-ingest`

## Quick Start

```bash
cd /Users/satoshi/data/tg-ingest

# Check status
poetry run tg_export status

# Sync all DMs + whitelisted groups
poetry run tg_export sync-all

# Export specific DM
poetry run tg_export dump-dm --user vibhu --out exports/vibhu.jsonl

# List DMs
poetry run tg_export list-dms
```

## Core Workflows

### Quick Export for AI Context (Recommended)

Get recent messages as markdown, ready to paste into Claude:

```bash
# Syncs first, outputs to stdout (last 24h)
python scripts/quick_export.py klutch

# Custom time range
python scripts/quick_export.py klutch --hours 48

# Copy to clipboard
python scripts/quick_export.py klutch | pbcopy

# Visual copy in browser
python scripts/quick_export.py klutch | quick-view

# Intentional save
python scripts/quick_export.py klutch --save
# → exports/klutch_2026-01-02.md
```

See [references/files.md](references/files.md) for file management philosophy.

### Export via CLI (Alternative)

```bash
# By username (pulls from API, may have caching issues)
poetry run tg_export dump-dm --user vibhu --out vibhu.jsonl

# Last 7 days only
poetry run tg_export dump-dm --user vibhu --last 7d --out vibhu.jsonl
```

**Note:** Prefer quick_export.py for reading synced data. Use dump-dm only for initial exports.

### Sync Operations

```bash
# One-shot sync (DMs + whitelisted groups)
poetry run tg_export sync-all

# Backfill older messages
poetry run tg_export sync-all --backfill

# Live continuous sync
poetry run tg_export live --interval 5m

# Sync DMs only
poetry run tg_export sync-dms --dir data/dms
```

### Manage Thread State

Thread states are stored in `data/decisions.jsonl`.

```bash
# Via CLI (if implemented) or direct file edit
# States: pending, done, archived
# Also supports: draft, snooze, note
```

See [references/state.md](references/state.md) for state management details.

### Manage Groups

```bash
# List registered groups
poetry run tg_export groups list

# Add a group to sync
poetry run tg_export groups add "crypto trenches" --type trading

# Sync groups
poetry run tg_export groups sync

# Backfill group history
poetry run tg_export groups backfill crypto_trenches --limit 1000
```

See [references/groups.md](references/groups.md) for registry management.

### Contact Lookup & Scoring

```bash
# Initialize contacts from DMs
poetry run tg_export contacts-init --dm-dir data/dms

# List contacts by priority
poetry run tg_export contacts-list --tier high

# Score all contacts
poetry run tg_export contacts-score

# Show contact details
poetry run tg_export contacts-show vibhu
```

See [references/contacts.md](references/contacts.md) for scoring algorithm.

## Data Locations

| Path | Purpose |
|------|---------|
| `data/dms/` | DM exports (*.jsonl + *.jsonl.idx) |
| `data/groups/` | Group exports |
| `data/registry.json` | Group registry |
| `data/decisions.jsonl` | Thread states |
| `data/session.session` | Telethon auth |
| `contacts/` | Contact database |

## Authentication

First-time setup:
```bash
# Set env vars (in .env or shell)
export TG_API_ID=your_id
export TG_API_HASH=your_hash

# Login (interactive)
poetry run tg_export login
```

Session persists in `data/session.session`.

## Thread ID Format

Telegram threads use format: `tg:dm:username` or `tg:group:slug`

Examples:
- `tg:dm:vibhu` - DM with @vibhu
- `tg:group:crypto_trenches` - Group chat

Overview

This skill is the primary Telegram interface for exporting messages, managing DMs, syncing groups, scoring contacts, and tracking thread state via a CLI. It provides fast syncs, one-shot exports, live continuous syncing, and utilities to prepare Telegram content for downstream AI workflows. Use it whenever you need reliable, scriptable access to Telegram conversation data or to manage thread lifecycle.

How this skill works

The tool communicates with Telegram via Telethon and stores session/auth data locally. It syncs DMs and whitelisted groups into structured exports (jsonl/markdown), maintains a contacts database with scoring, and records thread state in a decision log. CLI commands cover quick exports, full dumps, sync operations, group registry management, backfills, and live syncing.

When to use it

  • Export recent messages for AI context or manual review
  • Backfill or continuously sync DMs and selected groups
  • Manage thread lifecycle (pending, done, archived, draft, snooze, note)
  • Generate contact lists and priority scores from DM activity
  • Add, list, or backfill group history for curated group archives

Best practices

  • Use the quick export script for reading already-synced data rather than raw API dumps
  • Keep TG_API_ID and TG_API_HASH in environment variables and secure the session file
  • Whitelist only groups you need to reduce sync volume and storage
  • Run periodic contact scoring to keep priorities up to date
  • Backfill selectively with limits to avoid unnecessary API load

Example use cases

  • Produce a markdown summary of the last 24 hours of a DM for an AI assistant prompt
  • Sync all DMs nightly and run contact scoring to surface high-priority contacts
  • Add a new group to the registry, backfill its history, and keep it in continuous sync
  • Export a specific DM to jsonl for archival or downstream processing
  • Run live sync during an event to capture messages in near real-time

FAQ

How do I authenticate once?

Set TG_API_ID and TG_API_HASH as environment variables and run the interactive login command; the session is persisted locally.

Should I use dump-dm or quick export?

Prefer the quick export script for reading already-synced data; use dump-dm for initial raw API exports or when syncing via the API directly.