Application APIο
Document version: 0.2 β Last updated: 2026-10-08 β Status: π΄ UNDER REVIEW
Import concrete applications from kajenn_bot_application. Call management
and sending APIs from trusted application code after startup. Grammar classes
are imported from their corresponding provider modules.
Configuration and input examples are in Getting started, Telegram bots and WhatsApp bots.
Telegramο
- class kajenn_bot_application.TelegramBotApplication(*, persistence_route=None, webhook_url=None, client=None, **kwargs)ο
Own bot instances, sending directly and optionally receiving webhooks.
register_botis a trusted in-process API, not a public HTTP route.clientoptionally supplies an httpx client (owned by the caller). Constructor registry/URL options override the applicationβs grammar values.- Parameters:
persistence_route (str | None)
webhook_url (str | None)
client (httpx.AsyncClient | None)
kwargs (Any)
- async register_bot(*, code, bot_class, token, name='', icon=None, config=None)ο
Validate, durably register, then activate a bot created with BotFather.
Failed persistence leaves the bot inactive. Failed webhook activation leaves its registration available for
activate_botor startup. Duplicate codes and tokens within this application are rejected. A separate send-only application can use the same token without replacing its webhook.- Parameters:
code (str)
bot_class (type[RoutingClass])
token (str)
name (str)
icon (str | None)
config (dict[str, Any] | None)
- Return type:
RoutingClass
- async send_message(bot_code, chat_id, text, *, reply_markup=None)ο
Send a plain-text message to a known Telegram chat.
- Parameters:
bot_code (str)
chat_id (int)
text (str)
reply_markup (dict[str, Any] | None)
- Return type:
Any
- async send_typing(bot_code, chat_id)ο
Emit one typing indication; no background refresh loop is started.
- Parameters:
bot_code (str)
chat_id (int)
- Return type:
Any
- async send_media(bot_code, chat_id, kind, media, *, filename=None, caption='')ο
Send a document, photo, video, audio, voice or animation by reference or upload.
- Parameters:
bot_code (str)
chat_id (int)
kind (str)
media (str | bytes)
filename (str | None)
caption (str)
- Return type:
Any
- async send_poll(bot_code, chat_id, question, options, *, is_anonymous=True, allows_multiple_answers=False, route=None)ο
Send and track a native regular poll; optionally route result events to the bot.
- Parameters:
bot_code (str)
chat_id (int)
question (str)
options (list[str])
is_anonymous (bool)
allows_multiple_answers (bool)
route (str | None)
- Return type:
Any
- async get_poll(bot_code, poll_id)ο
Read persisted poll totals and the latest received answer per voter.
- Parameters:
bot_code (str)
poll_id (str)
- Return type:
dict[str, Any]
- async stop_poll(bot_code, poll_id)ο
Close a tracked native poll and save its final totals.
- Parameters:
bot_code (str)
poll_id (str)
- Return type:
Any
- class kajenn_bot_application.telegram.TelegramBotGrammarο
The Telegram applicationβs registry and optional public webhook location.
- telegram = <genro_builders.builder._decorators._DeclarativeMarker object>ο
- class kajenn_bot_application.telegram.TelegramBotInstanceGrammarο
Shared access options for Telegram bot classes.
WhatsApp Businessο
- class kajenn_bot_application.WhatsAppBotApplication(*, api_version=None, app_secret=None, verify_token=None, **kwargs)ο
Receive authenticated WhatsApp events and send through Cloud API.
- Parameters:
api_version (str | None)
app_secret (str | None)
verify_token (str | None)
kwargs (Any)
- async register_bot(*, code, bot_class, token, phone_number_id, business_account_id, name='', icon=None, config=None)ο
Register an already provisioned business number; never alter its subscriptions.
- Parameters:
code (str)
bot_class (type[RoutingClass])
token (str)
phone_number_id (str)
business_account_id (str)
name (str)
icon (str | None)
config (dict[str, Any] | None)
- Return type:
RoutingClass
- async send_message(bot_code, chat_id, text)ο
Submit one free-form text inside a known open service window.
- Parameters:
bot_code (str)
chat_id (str)
text (str)
- Return type:
Any
- async send_template(bot_code, chat_id, *, name, language, components=None)ο
Submit an explicitly selected approved template; approval is checked by Meta.
- Parameters:
bot_code (str)
chat_id (str)
name (str)
language (str)
components (list[dict[str, Any]] | None)
- Return type:
Any
- async send_buttons(bot_code, chat_id, text, buttons)ο
Submit at most three label-to-payload reply buttons inside the service window.
- Parameters:
bot_code (str)
chat_id (str)
text (str)
buttons (dict[str, str])
- Return type:
Any
- async send_media(bot_code, chat_id, kind, media, *, filename=None, caption='')ο
Submit media by provider ID, HTTPS URL or uploaded bytes.
- Parameters:
bot_code (str)
chat_id (str)
kind (str)
media (str | bytes)
filename (str | None)
caption (str)
- Return type:
Any
- async get_message(bot_code, message_id)ο
Read API acceptance and the most advanced delivery status received.
- Parameters:
bot_code (str)
message_id (str)
- Return type:
dict[str, Any]
- async send_announcement(bot_code, chat_ids, text='', *, template=None)ο
Submit explicit text or a template once per destination and collect outcomes.
- Parameters:
bot_code (str)
chat_ids (list[Any])
text (str)
template (dict[str, Any] | None)
- Return type:
list[dict[str, Any]]
- async queue_announcement(bot_code, chat_ids, text='', *, template=None)ο
Queue an announcement whose sending eligibility is checked at execution time.
- Parameters:
bot_code (str)
chat_ids (list[Any])
text (str)
template (dict[str, Any] | None)
- Return type:
str
- async schedule_reminder(bot_code, chat_id, text='', *, when, conversation_id=None, user_id=None, template=None)ο
Schedule explicit text or a template; record API acceptance separately from delivery.
- Parameters:
bot_code (str)
chat_id (Any)
text (str)
when (datetime)
conversation_id (str | None)
user_id (Any)
template (dict[str, Any] | None)
- Return type:
str