Sharing a contact with telegram bot #113508
Replies: 2 comments
-
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
-
Hi @ibnum1, Unfortunately, the Telegram Bot API doesn't support directly choosing a contact from the user's contact list via a button. However, you can ask users to manually share a contact. Here's a simplified example using Telegraf.js: const { Telegraf } = require('telegraf');
const bot = new Telegraf('YOUR_BOT_TOKEN');
bot.start((ctx) => {
ctx.reply('Welcome! Please share a contact by selecting it from your contact list and sending it here.');
});
bot.on('contact', (ctx) => {
const contact = ctx.message.contact;
// Log contact details
console.log(`Contact received: ${contact.first_name} ${contact.last_name}, Phone: ${contact.phone_number}`);
ctx.reply(`Thank you for sharing ${contact.first_name}'s contact!`);
});
bot.launch(); In this script:
For more details, you can refer to the official Telegram Bot API documentation |
Beta Was this translation helpful? Give feedback.
-
Select Topic Area
Question
Body
hi all,
i'm a telegram bot developer using telegraf js
i was making a gifting system so i wanted to make it as the user can choose any contact from his contact list and sends it to the bot after that the bot but i wanted to implement this as a button says share contact and then the contact list screen is viewed by the user to pick a contact.....
how to do that please
Beta Was this translation helpful? Give feedback.
All reactions