onResponse
This hook is called after receiving a successful response
from the Telegram Bot API.
Parameters
Object with:
- method - API method name
- params - API method parameters
- response - response data
Example
ts
import { Bot } from "gramio";
const bot = new Bot(process.env.BOT_TOKEN as string).onResponse((context) => {
console.log("Response for", context.method, context.response);
});
Add hook only to specified API methods
ts
bot.onResponse("sendMessage", (context) => {
console.log("Response for sendMessage", context.response);
});
// or array
bot.onResponse(["sendMessage", "sendPhoto"], (context) => {
console.log("Response for", context.method, context.response);
});