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.3.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.3.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for llama_index_readers_telegram-0.3.0.tar.gz
Algorithm Hash digest
SHA256 8b3f7e4608ebc0fd2cef2a88a15a17ea483047f040128488d7ae180025a0b59b
MD5 69fe5e25d03085935e37f71c1e0d134e
BLAKE2b-256 85b62ae869e89e5ab6969be11e61f3abb08229afe05a7228c01422f6d7f96d14

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llama_index_readers_telegram-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 541cd91f1dcc23f20a1403d14eae027347ac49595725d2338376160746c020c2
MD5 42132f0ddfa5748fe91efbf13a87a9d2
BLAKE2b-256 0f1effee69191a4c345e5043887307e22229353cd96a60fc2cd4c57865f99539

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