-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Feat(Tools): Add Telegram Toolkit with Send/Receive capabilities #1196 #1480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Feat(Tools): Add Telegram Toolkit with Send/Receive capabilities #1196 #1480
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a new Telegram Toolkit to enable SuperAGI agents to interact with Telegram bots. However, the implementation has critical issues that prevent the receive functionality from working as described.
Key Changes:
- Added TelegramToolkit class with configuration for TELEGRAM_BOT_TOKEN
- Added TelegramSendMessageTool to send text messages to Telegram chats
- Added TelegramReceiveMessageTool to fetch recent messages (though not integrated into the toolkit)
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 13 comments.
| File | Description |
|---|---|
superagi/tools/telegram/telegram_toolkit.py |
Defines the Telegram toolkit but is missing the receive tool in imports and tool list |
superagi/tools/telegram/telegram_send_message.py |
Implements message sending functionality with incomplete response validation |
superagi/tools/telegram/telegram_receive_message.py |
Implements message retrieval with incorrect API parameter usage and incomplete validation |
superagi/tools/telegram/__init__.py |
Exports toolkit and send tool but missing the receive tool export |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| class TelegramToolkit(BaseToolkit, ABC): | ||
| name: str = "Telegram Toolkit" | ||
| description: str = "Toolkit containing tools for Telegram integration" | ||
|
|
||
| def get_tools(self) -> List[BaseTool]: | ||
| return [ | ||
| TelegramSendMessageTool(), | ||
| ] | ||
|
|
||
| def get_env_keys(self) -> List[ToolConfiguration]: | ||
| return [ | ||
| ToolConfiguration(key="TELEGRAM_BOT_TOKEN", key_type=ToolConfigKeyType.STRING, is_required=True, is_secret=True) | ||
| ] |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are missing for the TelegramToolkit and its tools. The repository has comprehensive test coverage for other toolkits (e.g., in tests/unit_tests/tools/), and the PR description claims tests have been added. Tests should be included to verify the functionality of TelegramSendMessageTool, TelegramReceiveMessageTool, and the TelegramToolkit class.
| message : The message to be sent. | ||
|
|
||
| Returns: | ||
| success message if message is sent successfully or failure message if message sending fails. |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation for the _execute method states it returns "success message if message is sent successfully or failure message if message sending fails" but doesn't specify that it can also return error strings for configuration issues or exceptions. The documentation should accurately reflect all possible return types and scenarios.
| success message if message is sent successfully or failure message if message sending fails. | |
| str: A human-readable message indicating the result of the operation. This may be: | |
| - A success message if the message is sent successfully. | |
| - A failure message if the Telegram API returns a non-200 status code. | |
| - A configuration error message if the TELEGRAM_BOT_TOKEN is not set. | |
| - An error message describing any exception raised while sending the message. |
| limit: Number of messages to retrieve. | ||
|
|
||
| Returns: | ||
| Recent messages or failure message. |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation for the _execute method states it returns "Recent messages or failure message" but doesn't specify the exact format of the returned messages or that it can return error strings for configuration issues or exceptions. The documentation should clearly describe the return format: each message as "[chat_id] username: text" separated by newlines, or specific error messages.
| limit: Number of messages to retrieve. | |
| Returns: | |
| Recent messages or failure message. | |
| limit: Number of messages to retrieve. | |
| Returns: | |
| str: On success, a single string containing recent text messages, one per line, | |
| where each line is formatted as "[chat_id] username: text" and lines are | |
| separated by newline characters. On failure, a human-readable error message | |
| string such as: | |
| - "Error: TELEGRAM_BOT_TOKEN is not set in the configuration." | |
| - "Error from Telegram: <description>" | |
| - "Failed to retrieve messages. Status Code: <code>. Response: <response body>" | |
| - "Error retrieving messages: <exception message>" |
| else: | ||
| return f"Failed to retrieve messages. Status Code: {response.status_code}. Response: {response.text}" | ||
| except Exception as e: | ||
| return f"Error retrieving messages: {e}" |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message "Error retrieving messages: {e}" is too generic and doesn't provide enough context for debugging. It should specify what operation failed, for example: "Failed to retrieve Telegram messages due to network or API error: {e}"
| return f"Error retrieving messages: {e}" | |
| return f"Failed to retrieve Telegram messages due to network or API error: {e}" |
| from abc import ABC | ||
| from typing import List | ||
| from superagi.tools.base_tool import BaseTool, BaseToolkit, ToolConfiguration | ||
| from superagi.tools.telegram.telegram_send_message import TelegramSendMessageTool |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TelegramReceiveMessageTool is missing from imports. According to the PR description, this toolkit should include both send and receive capabilities, but the receive tool is not imported here.
| else: | ||
| return f"Message sending failed. Status Code: {response.status_code}. Response: {response.text}" | ||
| except Exception as e: | ||
| return f"Error sending message: {e}" |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message "Error sending message: {e}" is too generic and doesn't provide enough context for debugging. It should specify what operation failed, for example: "Failed to send Telegram message due to network or API error: {e}"
| return f"Error sending message: {e}" | |
| return f"Failed to send Telegram message to chat_id {chat_id} due to network or API error: {e}" |
| def get_tools(self) -> List[BaseTool]: | ||
| return [ | ||
| TelegramSendMessageTool(), | ||
| ] |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TelegramReceiveMessageTool is not included in the list of tools returned by get_tools(). The PR description states that both send and receive capabilities should be available, but only TelegramSendMessageTool is being returned here. This means agents won't be able to read messages.
| @@ -0,0 +1,2 @@ | |||
| from superagi.tools.telegram.telegram_toolkit import TelegramToolkit | |||
| from superagi.tools.telegram.telegram_send_message import TelegramSendMessageTool | |||
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TelegramReceiveMessageTool is missing from the module exports. For consistency with the toolkit structure and to match what's stated in the PR description, this tool should also be exported here alongside TelegramSendMessageTool.
| from superagi.tools.telegram.telegram_send_message import TelegramSendMessageTool | |
| from superagi.tools.telegram.telegram_send_message import TelegramSendMessageTool | |
| from superagi.tools.telegram.telegram_receive_message import TelegramReceiveMessageTool |
| @@ -0,0 +1,68 @@ | |||
| from typing import Type, Optional, List | |||
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import of 'Optional' is not used.
Import of 'List' is not used.
| from typing import Type, Optional, List | |
| from typing import Type |
Description
Implemented a new Telegram Toolkit to enable SuperAGI agents to interact with Telegram Bots.
Resolves #1196.
Changes
TelegramToolkitclass.TelegramSendMessageTool: Sends text messages to a chat ID.TelegramReceiveMessageTool: Fetches recent messages from the bot's history (usinggetUpdates).[chat_id] username: messageso agents can identify who to reply to.TELEGRAM_BOT_TOKEN).Type of change
Checklist