so i have this telegram bot, created it with telegraf js library and its running with web hooks, my goal is to retreive the data from the bot and pass the data into an object in my node js.
1- this function is responsible for creating multi web hooks for multi bots
async bootstrapBots() {
try {
const bots = await Bot.find();
bots.forEach((bot) => {
const bot_token = get(bot, "token", null);
if (bot_token) {
const account_bot = new AtomBot(bot_token);
account_bot.getBot().launch({
webhook: {
domain: process.env.SERVER_URL || process.env.NGROK_URL,
hookPath: `/bots-webhook?accountId=${bot.accountId}&botToken=${bot_token}`,
},
});
}
});
} catch (error) {
throw error;
}
},
2- i want to pass the data from the telegram bot data to this class on createMsjObject
class MsgConstructor {
constructor(message, accId, botToken, botId) {
this.message = this.createMsjObject(message, accId, botToken);
this.botId = botId;
}
createMsjObject(message, accId, botToken) {
return {
accountId: accId,
botToken: botToken,
query: get(message, "message.text", ""),
chatId: get(message, "message.chat.id", 0),
contactFirstName: get(message, "message.chat.first_name", ""),
contactLastName: get(message, "message.chat.last_name", ""),
contactUserName: get(message, "body.message.chat.user_name", ""),
date: get(message, "message.date", null),
isBot: get(message, "message.from.is_bot", false),
};
}