const chat_id = req.body.message.chat.id
const dharmaraj = 2xx4xxx5x //My Telegram UID
So I have these 2 const declared at top and chat_id
is ID of group/user who used my bot command. If I use the bot from my personal chat, it does reply. But when someone else use the bot in private or in group, the bot won't alert me about it in Telegram.
Here is the code:
console.log(`Post command used by ${user_id}`)
res.status(200).send({
method: 'sendMessage',
dharmaraj,
text: `Message posted successfully!!`,
parse_mode: 'Markdown'
})
The console.log()
statement does work.
But I don't receive the message from the bot.
I have started
the bot and have a long chat history as well. So that shouldn't be an issue.
I read this but I don't want to use any other package.
EDIT:
(1) If I replace it with the chat_id
itself (ID where the bot was triggered) it will send message in that chat. Problem is to get some text in my personal chat so I know the bot has been used.
(2) I tried embedding the snippet in a try-catch
but no error there.
(3) Tried replacing UID with the @username
but no luck.