Sending Messages (simplified way)
Sending Messages and Media with Bot¶
These Bot methods send messages or media to the current chat.
- All messages go to the current chat by default
- Using
awaitis optional - If awaited, the Telegram API response is returned
- Only some methods support chained actions
Sending Text Messages¶
Simple Text¶
Object Format¶
With Formatting¶
Sending Keyboards¶
String Format¶
Object Format¶
Sending Media¶
All media methods support string and object formats.
Photo¶
Document¶
Bot.sendDocument("file.pdf", "Here is your pdf")
Bot.sendDocument({
document: "file.pdf",
caption: "Here is your file"
})
Audio¶
Video¶
Voice¶
Using Chained Methods (Limited Support)¶
Only specific Bot methods return a response that supports chained methods
(when used with await).
Example:
Note
Not all Bot methods support chaining. Chaining works only when the method returns a Telegram message object.
Debugging with Bot.inspect()¶
Bot.inspect() sends inspect data to the current chat.
It is mainly used for debugging and checking values quickly.
Inspect Any Data¶
Inspect Multiple Values¶
The inspected data is formatted and sent as a message in the chat.
Tip
Use Bot.inspect() only during development. Avoid using it in production bots for users.
Available Bot Methods¶
Only the following Bot methods are available for sending output:
Bot.sendMessageBot.sendKeyboardBot.sendDocumentBot.sendPhotoBot.sendAudioBot.sendVideoBot.sendVoiceBot.inspect
These methods are intentionally limited and focused on output and flow control.
Not Available in Bot¶
Methods that read or query Telegram data, such as:
getChatgetMegetUserProfilePhotos- or similar Telegram API read methods
are not available in the Bot instance.
Info
The Bot instance is designed for sending responses and controlling bot behavior, not for querying Telegram data.
Important Notes¶
- All Bot send methods use the current chat
awaitis optional- Only limited methods support chained actions
Bot.inspect()sends output to chat- Method names are case-sensitive
- Errors can be handled using the
!command