Skip to main content

llama-index readers telegram integration

Project description

Telegram Loader

pip install llama-index-readers-telegram

This loader fetches posts/chat messages/comments from Telegram channels or chats into Documents.

Before working with Telegram’s API, you need to get your own API ID and hash:

  1. Login to your Telegram account with the phone number of the developer account to use.
  2. Click under API Development tools.
  3. A Create new application window will appear. Fill in your application details. There is no need to enter any URL, and only the first two fields (App title and Short name) can currently be changed later.
  4. Click on Create application at the end. Remember that your API hash is secret and Telegram won’t let you revoke it. Don’t post it anywhere!

This API ID and hash is the one used by your application, not your phone number. You can use this API ID and hash with any phone number.

Usage

The first parameter you pass to the constructor of the TelegramReader is the session_name, and defaults to be the session name (or full path). That is, if you create a TelegramReader(session_name='anon', ...) instance and run load_data(), an anon.session file will be created in the working directory where you run this loader.

The Auth procedure asks for:

  • Security Code
  • Password
Please enter the code you received: 12345
Please enter your password: *******
(You are now logged in)

If the .session file already existed, it will not login again, so be aware of this if you move or rename the file! See here for more instructions.

To use this loader, you simply need to pass in a entity name.

from llama_index.readers.telegram import TelegramReader

loader = TelegramReader(
    session_name="[YOUR_SESSION_NAME]",
    api_id="[YOUR_API_ID]",
    api_hash="[YOUR_API_HASH]",
    phone_number="[YOUR_PHONE_NUMBER]",
)
documents = loader.load_data(
    entity_name="https://t.me/[ENTITY_NAME]", limit=100
)

Examples

This loader is designed to be used as a way to load data into LlamaIndex.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llama_index_readers_telegram-0.2.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llama_index_readers_telegram-0.2.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_readers_telegram-0.2.0.tar.gz.

File metadata

File hashes

Hashes for llama_index_readers_telegram-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f6f7c34b046aa70beec5613e7b0cc4e38d45b92e81fabb13452d83ee3bf9b39c
MD5 b3772df40297eaf07df08b762a9cac28
BLAKE2b-256 d32aced97877fb18a1336b558440cbc91d2dee9233cd002dd0dcef07c349fe94

See more details on using hashes here.

File details

Details for the file llama_index_readers_telegram-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_readers_telegram-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 985dc08191bcd85505abf0e0c62c06430d59d4e9300acf351cc0d94ec4e40aa2
MD5 ecea4d450f1403fbdbbe0607f7122b06
BLAKE2b-256 2ca8860975e18b535a20ec5a6885d7157aa17193d7cd132f1b7b8e258d071328

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page