Home node.js How to find Chat ID To send a message to Telegram chat?

How to find Chat ID To send a message to Telegram chat?

Author

Date

Category

When working with Telegraf.js How can I find out the chat ID to send a message when adding a bot into a group?

const Telegraf = Require ('Telegraf')
Const Config = Require ('./config.json')
Const Bot = New Telegraf (Config.Token)
Bot.start (((CTX) = & gt; ctx.reply ('Welcome'))
Bot.help ((CTX) = & gt; ctx.reply ('Send Me a Sticker'))
Bot.ON ('new_chat_members', (CTX) = & gt; console.log (CTX.Message.New_Chat_members))
Bot.Hears ('Hi', (CTX) = & gt; ctx.reply ('Hey There'))
Bot.Hears (/ Buy / I, (CTX) = & gt; ctx.reply ('buy-buy'))
Bot.telegram.sendMessage (Chat.ID, 'SD')
Bot.startPolling ()

Answer 1, Authority 100%

Easy, you just need to pull out from the CTX object. It turns out like this:

ctx.message.chat.id

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions