Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to Connect Telegram to a Local AI Assistant Safely

Практическая инструкция для тех, кто хочет подключить Telegram к локальному AI-ассистенту, Codex, Claude Code или другому coding agent, но не хочет отдавать агенту право писать, редактировать или удалять сообщения от своего имени.

This repository is a docs-only guide. It describes a safe local architecture for using selected Telegram chats as context for an AI assistant.

It puts extra emphasis on the most confusing setup blocker: getting api_id and api_hash from my.telegram.org when the Telegram application form only returns the vague ERROR message, especially for users in Russia or similar network environments.

Preview of my.telegram.org showing the vague ERROR alert while creating a Telegram application

If You Are Stuck At my.telegram.org says ERROR

This is often the hardest part before any AI assistant integration starts. The guide includes a dedicated troubleshooting flow for:

  • my.telegram.org says ERROR;
  • ERROR when creating a Telegram App;
  • getting Telegram API api_id and api_hash;
  • VPN / proxy problems;
  • phone number country vs IP country mismatch;
  • temporary hosts workaround for my.telegram.org;
  • what not to do, including repeated automated /apps/create requests.

Read The Guide

Short Version

Use Telegram as a source of work context, not as an unrestricted agent tool.

Recommended flow:

Telegram work account
  -> read-only Telethon / MTProto sync
  -> explicit allowlist of selected work chats
  -> local SQLite index
  -> compact Markdown / Obsidian context
  -> local AI assistant
  -> optional draft queue
  -> manual approval before any send

Safety Defaults

  • Read-only first.
  • Allowlist first.
  • Local storage first.
  • No secrets in Git.
  • No full Telegram history in prompts.
  • No auto-send.
  • No broad Telegram MCP tools exposed directly to the assistant.

What This Is Not

This is not a Telegram bot tutorial, a cloud service, or a full Telegram client. It is a pattern for building a narrow, local, safety-first context layer.

What You Will Learn

  • How to use Telegram as context for a local AI assistant.
  • How to connect Telegram to Codex, Claude Code, Cursor, Cline, Roo Code, Aider, Continue, Gemini CLI, OpenCode, or Obsidian without exposing broad write tools.
  • How to get Telegram API api_id and api_hash from my.telegram.org.
  • How to troubleshoot the vague my.telegram.org ERROR / my.telegram.org says ERROR message when creating a Telegram App.
  • How to build a read-only Telegram integration with Telethon or another MTProto client.
  • How to choose a safer alternative to broad Telegram MCP tools.

Works With

This pattern is tool-agnostic. It can be used with local or agentic coding assistants such as OpenAI Codex, Claude Code, Cursor, Cline, Roo Code, Aider, Continue, Gemini CLI, OpenCode, GitHub Copilot-style agents, and Obsidian-based Markdown workflows.

Publication Checklist

Before publishing your own fork or implementation:

  • Remove real chat IDs, names, phone numbers, and screenshots.
  • Remove API ID, API hash, bot tokens, and session files.
  • Keep .env, *.session, SQLite databases, raw exports, attachments, and logs out of Git.
  • Use fake paths in examples.
  • Do not expose unrestricted send, edit, delete, admin, contact, or group-management tools to an AI assistant.

About

Guide for connecting Telegram to a local AI assistant.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors