Architecture
Overview
The current SDK is divided into clear layers:
src/request: handle HTTP transport and map API errorssrc/models: parse payload intoUser,Chat,Message,Update,WebhookInfosrc/core:Bot,Application,ApplicationBuilder,CallbackContextsrc/handlers: handle commands and messagessrc/filters: filters can be combinedsrc/i18n: runtime message system forvi/en
Basic run flow

Mapping from Python to TypeScript
This project is referenced from python_zalo_bot, but not mechanically copied.Some parts have been simplified:
- remove Python-only patterns like
__slots__, sentinel defaults, freeze object - keep lifecycle clear via
initialize()andshutdown() - Prioritize objects and more compact TypeScript parsers
- fallback parse for message sending response if the API returns a thin payload
Role of each main block
src/request
This is the bottom layer of the SDK.It is responsible for:
- HTTP call to Zalo Bot API
- handle timeouts
- map HTTP status to custom error
src/models
Models receive the raw payload and convert it into an object that is easier to use in code, for example:
UpdateMessageUserChat
src/core
Here is the main dispatcher:
Bot: client calls APIApplication: polling round and dispatch updateApplicationBuilder: clearer way to initialize the app
src/handlers and src/filters
These two parts create event-driven programming:
CommandHandleris used for commands like/startMessageHandleris used for text, photos or other filtersfiltersallows combining conditions in an easy-to-read fashion
src/i18n
This section reads ZALO_BOT_LANG and decides whether log/runtime messages should be displayed in Vietnamese or English.
Current limit
- There is no full media upload abstraction yet
- There is no worker queue layer yet
- webhook framework adapters have not been separated into separate packages
Thread runs when polling
- App is created from
ApplicationBuilder Application.runPolling()callsBot.initialize()Bot.initialize()checks the token viagetMe()ApplicationrepeatsgetUpdate()Updateis parsed into a model- The first Handler to match will handle the update
- Your callback can call
replyText()or other message sending methods