Skip to content

Conversation

@SimplyRohit
Copy link
Contributor

… tools

Summary

This PR extends the Telegram integration by adding new tool modules to handle:

  • Sending animations
  • Sending photos
  • Sending videos
  • Sending audio
  • Deleting messages

Fixes #1562

Type of Change

  • New feature

Testing

Verified each Telegram tool individually
Confirmed successful message send, delete, and media operations on Telegram bot
Ensured build and lint checks passed after import reordering and Biome formatting

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Screenshots/Videos

image

@vercel
Copy link

vercel bot commented Oct 7, 2025

@SimplyRohit is attempting to deploy a commit to the Sim Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Summary

This PR significantly expands the Telegram integration from a single text message tool to a comprehensive multimedia and message management suite. The changes introduce five new tools for sending different media types (animations, photos, videos, audio) and deleting messages, addressing issue #1562.

The implementation follows a consistent architectural pattern across all new tools, using shared authentication parameters (botToken, chatId) and standardized response handling. The original telegram_message tool has been renamed to telegram_send_message to align with the new naming convention (telegram_send_* pattern). All media tools support optional captions with automatic markdown-to-HTML conversion using the existing convertMarkdownToHTML utility.

The changes integrate seamlessly with the existing codebase structure. The telegram/index.ts serves as the central export hub for all tools, the individual tool files follow the established ToolConfig pattern with proper TypeScript typing, and the tools registry is updated to include all new functionality. The Telegram block configuration has been enhanced with a dropdown operation selector and conditional form fields, providing a unified interface for all Telegram operations while maintaining clean separation of concerns.

Important Files Changed

Changed Files
Filename Score Overview
apps/sim/tools/telegram/index.ts 5/5 Entry point restructured to export six Telegram tools with consistent naming
apps/sim/tools/telegram/message.ts 3/5 Refactored existing message tool with new naming and response structure
apps/sim/tools/telegram/delete.ts 3/5 New tool for deleting Telegram messages with debug statement and error handling issues
apps/sim/tools/telegram/types.ts 3/5 Expanded type definitions for all media types with some type inconsistencies
apps/sim/tools/telegram/animation.ts 4/5 New tool for sending animations with proper structure but verbose output schema
apps/sim/tools/telegram/photo.ts 4/5 New tool for sending photos with clean implementation following established patterns
apps/sim/tools/telegram/video.ts 3/5 New tool for sending videos with error handling and type consistency issues
apps/sim/tools/telegram/audio.ts 3/5 New tool for sending audio files with missing error handling and type mismatches
apps/sim/blocks/blocks/telegram.ts 4/5 Enhanced block with operation selector and conditional fields for unified interface
apps/sim/tools/registry.ts 4/5 Updated registry with all new Telegram tools, includes breaking change

Confidence score: 3/5

  • This PR introduces comprehensive functionality with some implementation issues that need attention before merging
  • Score reflects good architectural consistency but concerns about error handling, type safety, and debug statements across multiple files
  • Pay close attention to delete.ts, types.ts, and the error handling patterns in new media tools

Sequence Diagram

sequenceDiagram
    participant User
    participant TelegramBlock
    participant TelegramAPI

    User->>TelegramBlock: "Configure operation (send message/photo/video/audio/animation/delete)"
    User->>TelegramBlock: "Provide bot token"
    User->>TelegramBlock: "Provide chat ID"
    
    alt Send Message
        User->>TelegramBlock: "Provide message text"
        TelegramBlock->>TelegramAPI: "POST /sendMessage with text"
        TelegramAPI-->>TelegramBlock: "Return message data"
    else Send Photo
        User->>TelegramBlock: "Provide photo URL/file_id and caption"
        TelegramBlock->>TelegramAPI: "POST /sendPhoto with photo data"
        TelegramAPI-->>TelegramBlock: "Return photo message data"
    else Send Video
        User->>TelegramBlock: "Provide video URL/file_id and caption"
        TelegramBlock->>TelegramAPI: "POST /sendVideo with video data"
        TelegramAPI-->>TelegramBlock: "Return video message data"
    else Send Audio
        User->>TelegramBlock: "Provide audio URL/file_id and caption"
        TelegramBlock->>TelegramAPI: "POST /sendAudio with audio data"
        TelegramAPI-->>TelegramBlock: "Return audio message data"
    else Send Animation
        User->>TelegramBlock: "Provide animation URL/file_id and caption"
        TelegramBlock->>TelegramAPI: "POST /sendAnimation with animation data"
        TelegramAPI-->>TelegramBlock: "Return animation message data"
    else Delete Message
        User->>TelegramBlock: "Provide message ID to delete"
        TelegramBlock->>TelegramAPI: "POST /deleteMessage with message ID"
        TelegramAPI-->>TelegramBlock: "Return deletion confirmation"
    end
    
    TelegramBlock-->>User: "Return operation result with message data"
Loading

10 files reviewed, 13 comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1
Copy link
Collaborator

@SimplyRohit this is great! Can we just ack the PR comments, I agree with them all asides from the two that I left disagree comments on

@SimplyRohit
Copy link
Contributor Author

SimplyRohit commented Oct 8, 2025

@SimplyRohit this is great! Can we just ack the PR comments, I agree with them all asides from the two that I left disagree comments on
thanks a lot for the review!
Ive gone through all the comments, ack them, and fixed all the issues
ive more updates ready for the telegram tools to expand functionality with chat action operations

@waleedlatif1
Copy link
Collaborator

@SimplyRohit can you also change the base of the PR to staging instead of main?

@SimplyRohit SimplyRohit changed the base branch from main to staging October 8, 2025 16:44
@SimplyRohit
Copy link
Contributor Author

@SimplyRohit can you also change the base of the PR to staging instead of main?

got it, updated to staging

@waleedlatif1
Copy link
Collaborator

merged in #1625

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REQUEST] Extend telegram tool to support send audio, video, animation, and photos

2 participants