Skip to main content

Telegram Source/Output for Waken — long-polling in, sendMessage out.

Project description

waken-telegram

CI License: MIT

Telegram Source/Output for Waken — long-polling in, sendMessage out.

Unlike waken-claude/waken-openai/... (Target adapters wrapping an AI-agent backend), this package plugs into the other end of the runtime: Telegram is a channel, so it ships a Source (turns incoming messages into Events) and an Output (delivers a Response back to the chat it came from), not a Target.

Install

pip install waken-telegram

Set TELEGRAM_BOT_TOKEN in your environment — get one from @BotFather.

Usage

from waken import Runtime, target_fn, Event, Response
from waken_telegram import TelegramSource, TelegramOutput

@target_fn
async def echo(event: Event) -> Response:
    return Response(text=event.payload["prompt"])

runtime = Runtime()
runtime.target("echo", echo)
runtime.source("telegram", TelegramSource(target="echo"))
runtime.output("telegram", TelegramOutput())
runtime.run()

Message a bot registered under TELEGRAM_BOT_TOKEN and it replies through the same chat — TelegramSource stashes the chat's id on Event.metadata["chat_id"], and TelegramOutput reads it back off to know where to send the response.

Design notes

  • Long polling, not webhooks. TelegramSource calls Bot.get_updates in a background loop rather than standing up a webhook receiver — no public HTTP endpoint, no signature-verification story. It also sidesteps a real limitation in core waken's webhook route today: it only passes handlers the parsed JSON body, with no request headers, which blocks any signature-verified webhook flow. That's a gap in waken core, not something worked around here.
  • Sessions are keyed by the Telegram chat_id via runtime.session("telegram", str(chat_id)), so a Target sees the same session_id across a chat's messages.
  • Text messages only, by design. Photos, stickers, voice notes, and every other Telegram message type are ignored in v1 — a deliberate scope boundary, not an oversight. Extending TelegramSource._poll_once to branch on more Message fields is the natural next step if you need it.

Development

git clone https://github.com/WakenHQ/waken-telegram
cd waken-telegram
pip install -e ".[dev]"
pytest

Tests mock telegram.Bot entirely — no network access or real bot token needed to run the suite.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

waken_telegram-0.1.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

waken_telegram-0.1.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file waken_telegram-0.1.0.tar.gz.

File metadata

  • Download URL: waken_telegram-0.1.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for waken_telegram-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dfea5d4cb806fb197872da8d26a5907fd756e45917074c4b92a813fb57388b70
MD5 28b90046638851bce7922bd3dd751f64
BLAKE2b-256 401206db9ebb5cb74d85895d5e1728f275de553b8065ea839f90b7bb4670c59d

See more details on using hashes here.

Provenance

The following attestation bundles were made for waken_telegram-0.1.0.tar.gz:

Publisher: publish.yml on WakenHQ/waken-telegram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file waken_telegram-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: waken_telegram-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for waken_telegram-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 993abd020972d4edfd41f0f46802710f72107ee042500a4e55a396523512bacd
MD5 8d2261542d461f4d11568fed8dca443c
BLAKE2b-256 0c9e6b130eac6f0acacac7635b4ebfa416a30d59a66bfc948059b14afab01d68

See more details on using hashes here.

Provenance

The following attestation bundles were made for waken_telegram-0.1.0-py3-none-any.whl:

Publisher: publish.yml on WakenHQ/waken-telegram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page