Skip to content

Add Telegram support using grammY#1

Open
Copilot wants to merge 365 commits intomainfrom
copilot/add-telegram-support-grammy
Open

Add Telegram support using grammY#1
Copilot wants to merge 365 commits intomainfrom
copilot/add-telegram-support-grammy

Conversation

Copy link

Copilot AI commented Dec 2, 2025

Adds Telegram bot support as a third messaging provider alongside Twilio WhatsApp and WhatsApp Web, using the grammY framework for long-polling message delivery.

Implementation

Provider Structure

  • src/telegram/ - Core bot client, send/receive, media handling, error formatting
  • src/providers/telegram/ - Barrel exports following existing provider pattern
  • Singleton bot instance with token-based cache to prevent duplicate connections

Integration Points

  • Updated Provider type: "twilio" | "web" | "telegram"
  • Added TELEGRAM_BOT_TOKEN environment variable
  • Extended send and relay commands with --provider telegram option
  • Auto-reply adapter converts Telegram messages to Twilio-compatible format

Media Support

  • Auto-detects type from extension: .jpg → photo, .mp4 → video, etc.
  • Supports local paths and URLs (Telegram fetches URLs directly)
  • Handles chat IDs (numeric) and usernames (@username)

Usage

# Send text
warelay send --provider telegram --to 123456789 --message "Hello"

# Send media
warelay send --provider telegram --to @channel --media ./photo.jpg --message "Check this"

# Auto-reply relay
warelay relay --provider telegram --verbose

Testing

  • 9 new unit tests (send, utils, command integration)
  • Mock-based tests for bot API interactions
  • Updated existing provider validation tests
Original prompt

Add telegram support using grammY.
Ultrathink and follow the project folder structure, best practices and style.
First analyse the current whatsapp implementation for feature parity


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add telegram support using grammY with feature parity analysis Add Telegram support using grammY Dec 2, 2025
Copilot AI requested a review from tiagoefreitas December 2, 2025 16:33
@tiagoefreitas
Copy link
Owner

@codex review this pr

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 13 to 16
const requestedToken = token || readEnv(runtime).telegramBotToken;
if (!requestedToken) {
throw new Error(
"TELEGRAM_BOT_TOKEN not found. Set it in .env or pass as argument.",

Choose a reason for hiding this comment

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

P1 Badge Allow Telegram bot creation without Twilio env

Using the Telegram provider currently fails if the environment only supplies TELEGRAM_BOT_TOKEN. createTelegramBot always calls readEnv to fetch the token (src/telegram/client.ts lines 13-16), but readEnv enforces required Twilio credentials via its schema and exits when they’re missing (src/env.ts lines 18-51). As a result, warelay send --provider telegram or relay --provider telegram terminates before starting the bot unless all Twilio variables are set, which blocks Telegram-only usage; load the Telegram token without validating Twilio config.

Useful? React with 👍 / 👎.

Copy link
Owner

Choose a reason for hiding this comment

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

@codex fix that

Choose a reason for hiding this comment

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

Copy link
Owner

Choose a reason for hiding this comment

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

@codex env is created, fix that issue

Choose a reason for hiding this comment

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

Summary

Testing

  • ⚠️ pnpm test (failed to download pnpm due to restricted network in the environment)

View task →

@tiagoefreitas tiagoefreitas marked this pull request as ready for review December 2, 2025 21:32
@tiagoefreitas tiagoefreitas force-pushed the copilot/add-telegram-support-grammy branch from c2516d3 to 49f435c Compare December 7, 2025 17:33
- Add Telegram bot integration using grammY library
- Support sending and receiving messages via Telegram Bot API
- Add --provider option to send and relay commands
- Update login to handle Telegram bot token
- Store Telegram credentials at ~/.clawdis/telegram/

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@tiagoefreitas tiagoefreitas force-pushed the copilot/add-telegram-support-grammy branch from 49f435c to 9a66b54 Compare December 7, 2025 17:37
Pi-agent-core's Agent.prompt() expects a plain string, not a structured
message object. The RPC handler passes input.message directly to
agent.prompt(), so sending { role: "user", content: [...] } caused
"(command produced no output)" errors.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

3 participants