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.4.0.tar.gz (5.2 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.4.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for llama_index_readers_telegram-0.4.0.tar.gz
Algorithm Hash digest
SHA256 d0245cdb1a69acdb86accb3b764289efdb1eea8991fadbecb713609222d3aa00
MD5 8475698aa619b126517539582566e6c7
BLAKE2b-256 88ef07297e178a8d366fb81483bfa8e28c839b1d10d0ef78f52a93e46400f1f7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llama_index_readers_telegram-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2b742c27f6904478283b892e0e46a869b9afe4215a160ef7037d1cf1c423d616
MD5 6c38a19f6202098b302d313c05193fe1
BLAKE2b-256 38305a83887fecbcf7ba51c90e0da8cd954e0507ca577143ed4e4c1863d32a30

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