This extension provides a set of tools to interact with the Telegram Bot API directly from the Gemini CLI.
- Send messages
- Read messages
- Get bot information
- Get chat information
- Edit messages
- Delete messages
- Send photos
- Send documents
- Get chat administrators
- Answer callback queries
To install the extension, run the following command in your Gemini CLI:
/extension install https://github.com/VSKurkin/gemini-cli-telegram-extension.gitNote: Your Gemini CLI must be configured to allow installing third-party extensions.
This extension requires a Telegram Bot API token. You can provide it in one of two ways:
-
Environment Variable (Recommended): Set the
TELEGRAM_BOT_TOKENenvironment variable in your system. This is the most secure and flexible method.- Linux/macOS:
export TELEGRAM_BOT_TOKEN="your-bot-token"
- Windows:
$env:TELEGRAM_BOT_TOKEN="your-bot-token"
- Linux/macOS:
-
.envFile: Create a file named.envin the directory where you run thegeminicommand. Add the following line to it:TELEGRAM_BOT_TOKEN="your-bot-token"
To use the tools provided by this extension, you need to make a tool call in your prompt. The Gemini CLI will execute the tool call and return the result.
Example 1: Send a message
To send a message, make a tool call to telegram:send_message with the chat_id and text parameters.
telegram:send_message(chat_id="your-chat-id", text="Hello from Gemini!")
Example 2: Read new messages
To read new messages, make a tool call to telegram:read.
telegram:read()
Example 3: Send a photo
To send a photo, make a tool call to telegram:send_photo.
telegram:send_photo(chat_id="your-chat-id", photo_path="/path/to/your/photo.jpg")
This section provides a detailed description of each tool and its parameters.
Sends a text message.
| Parameter | Type | Description |
|---|---|---|
chat_id |
string | Chat ID. |
text |
string | The text of the message. |
Reads new messages.
| Parameter | Type | Description |
|---|---|---|
timeout |
integer | Timeout for waiting for updates. |
chat_id |
string | Chat ID to filter messages from. |
offset |
integer | Offset for get_updates. |
Gets information about the bot. (No parameters)
Gets information about a chat.
| Parameter | Type | Description |
|---|---|---|
chat_id |
string | Chat ID. |
Edits a text message.
| Parameter | Type | Description |
|---|---|---|
chat_id |
string | Chat ID. |
message_id |
integer | Message ID. |
text |
string | The new text of the message. |
Deletes a message.
| Parameter | Type | Description |
|---|---|---|
chat_id |
string | Chat ID. |
message_id |
integer | Message ID. |
Sends a photo.
| Parameter | Type | Description |
|---|---|---|
chat_id |
string | Chat ID. |
photo_path |
string | Path to the photo file. |
caption |
string | Caption for the photo. |
Sends a document.
| Parameter | Type | Description |
|---|---|---|
chat_id |
string | Chat ID. |
document_path |
string | Path to the document file. |
caption |
string | Caption for the document. |
Gets a list of chat administrators.
| Parameter | Type | Description |
|---|---|---|
chat_id |
string | Chat ID. |
Answers a callback query.
| Parameter | Type | Description |
|---|---|---|
callback_query_id |
string | Callback query ID. |
text |
string | Text of the notification. |
To set up the development environment, follow these steps:
-
Clone the repository:
git clone https://github.com/VSKurkin/gemini-cli-telegram-extension.git cd gemini-cli-telegram-extension -
Create a virtual environment:
python -m venv .venv source .venv/bin/activate -
Install dependencies:
pip install -r requirements.txt pip install ruff # Or add it to a requirements-dev.txt
To run the tests, execute the following command from the root of the repository:
python -m unittest discover testsTo lint the code, use ruff:
ruff check .To format the code, use ruff:
ruff format .