Feature/telegram polling#192
Open
Coder666 wants to merge 2 commits intostephengpope:mainfrom
Open
Conversation
When TELEGRAM_MODE=polling, the bot polls Telegram's getUpdates API instead of requiring a public HTTPS endpoint. Messages are routed through the same TelegramAdapter → processChannelMessage pipeline. - Add lib/channels/telegram-polling.js: getUpdates loop with 25s long-poll timeout, auto-deletes webhook on start - Modify api/index.js: lazy-start polling on first request - Modify lib/channels/telegram.js: skip webhook secret validation in polling mode (updates come from our own getUpdates call) - Modify setup/setup-telegram.mjs: offer webhook vs polling mode, skip APP_URL and webhook steps when polling is selected No new dependencies. Polling runs in the existing Node.js process. Config: TELEGRAM_MODE=polling (default: webhook, no behaviour change)
- Add test/telegram-polling.test.js (9 tests): - Webhook secret rejection in webhook mode - Webhook secret bypass in polling mode - Case-insensitive TELEGRAM_MODE check - Chat ID authorization in polling mode - Fake request construction - stopPolling lifecycle safety - Update CONFIGURATION.md: add TELEGRAM_MODE env var - Update CHAT_INTEGRATIONS.md: document polling vs webhook modes - Add test file to npm test script in package.json All 213 tests pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(telegram): add long-polling mode as alternative to webhooks
The current Telegram integration requires a public HTTPS endpoint (via ngrok, VPS, etc.) for webhook delivery. This PR adds long polling as an alternative — the bot polls Telegram's
getUpdatesAPI, so no public URL is needed.Config
One env var. No new dependencies. No separate service. Runs in the existing Node.js process.
How it works
getUpdateswith 25s long-poll timeoutBoth modes route through the same pipeline:
TelegramAdapter.receive()→ processChannelMessage() → AI → sendResponse(). The AI layer is mode-agnostic.Changes
New file:
getUpdatesloop with 25s long-poll, auto-clears webhook on start, constructs fake Request objects for the existing adapterModified files:
TELEGRAM_MODE=pollinggetUpdatescall, not an external source)TELEGRAM_MODEenv varTests
test/telegram-polling.test.js — 9 new tests:
TELEGRAM_MODEcheckAll 213 tests pass (204 existing + 9 new).