How to contact Telegram
I am using node.js module for Telegram bot. I am trying to reach a user by telegram using the telegram API. Telegram API has 2 types: Bot API and Telegram API .
I think the Bot API can't get user contacts. The Telegram API has a method contact.getContacts
. But I don't know how to use it.
How can I get contacts in Telegram?
source to share
The Bot API can also get contact information; I think it's easier in this case.
You can try the keyboard response request_contact . If the user clicks on it, you will receive a message with the Contact message .
source to share
-
this code will give you contact, user shares their contact with your bot, custom commands command '/ special' will be prompted by a button to allow bot to contact and reconcile your node server you can register contact information to declare markup ---->
//declare Markup const {Extra,Markup}= Telegraf; bot.command('special', (ctx) => { return ctx.reply('Special buttons keyboard', Extra.markup((markup) => { return markup.resize() .keyboard([ markup.contactRequestButton('contact') ]) })) }) //listens for the click on contact button bot.on('contact', (ctx) => { console.log(ctx.update.message.contact); //logs { phone_number: '254*******', //first_name: 'nelsonBlack', //user_id: 73***** } })
source to share