Strands Telegram: Complete Bot API Integration 📱

Comprehensive Telegram Bot API integration with 60+ methods for messages, media, keyboards, polls, groups, and more.
Installation
pip install strands-telegram
Setup
- Create a bot with @BotFather
- Get your token
- Set environment variable:
export TELEGRAM_BOT_TOKEN="your_bot_token_here"
Quick Start
from strands import Agent
from strands_telegram import telegram
agent = Agent(tools=[telegram])
# Send a message
agent.tool.telegram(
action="send_message",
chat_id="@username",
text="Hello from Strands! 🚀"
)
Features
📨 Message Operations
# Send text message
agent.tool.telegram(
action="send_message",
chat_id="123456789",
text="Hello!",
parse_mode="HTML" # or "Markdown"
)
# Send photo
agent.tool.telegram(
action="send_photo",
chat_id="123456789",
file_path="/path/to/photo.jpg",
text="Check this out! 📸"
)
# Send from URL
agent.tool.telegram(
action="send_photo",
chat_id="123456789",
file_url="https://example.com/photo.jpg"
)
🎮 Interactive Keyboards
# Inline keyboard
agent.tool.telegram(
action="send_message",
chat_id="123456789",
text="Choose an option:",
inline_keyboard=[
[{"text": "Option 1", "callback_data": "opt1"}],
[{"text": "Option 2", "callback_data": "opt2"}],
[{"text": "Visit Site", "url": "https://example.com"}]
]
)
📊 Polls
agent.tool.telegram(
action="send_poll",
chat_id="123456789",
question="What's your favorite?",
options=["Python", "JavaScript", "Rust", "Go"]
)
👥 Group Management
# Get chat info
agent.tool.telegram(action="get_chat", chat_id="-100123456")
# Ban user
agent.tool.telegram(
action="ban_chat_member",
chat_id="-100123456",
user_id="789"
)
# Set permissions
agent.tool.telegram(
action="set_chat_permissions",
chat_id="-100123456",
permissions={"can_send_messages": True, "can_send_polls": False}
)
Available Actions
Messages
| Action |
Description |
send_message |
Send text message |
edit_message |
Edit existing message |
delete_message |
Delete message |
forward_message |
Forward message |
copy_message |
Copy message |
pin_message |
Pin message |
unpin_message |
Unpin message |
| Action |
Description |
send_photo |
Send photo |
send_video |
Send video |
send_audio |
Send audio |
send_document |
Send document |
send_voice |
Send voice message |
send_sticker |
Send sticker |
send_animation |
Send GIF |
Interactive
| Action |
Description |
send_poll |
Create poll |
send_dice |
Send dice/slot |
send_location |
Send location |
send_contact |
Send contact |
Management
| Action |
Description |
get_chat |
Get chat info |
get_chat_member |
Get member info |
ban_chat_member |
Ban user |
unban_chat_member |
Unban user |
set_chat_permissions |
Set permissions |
Bot
| Action |
Description |
get_me |
Get bot info |
get_updates |
Get updates |
set_webhook |
Set webhook |
delete_webhook |
Delete webhook |
Full Telegram control for your AI agent. 📱