How can I create a Telegram bot that copies contract addresses with a single tap?

I’m working on a Telegram bot for Solana blockchain notifications using node-telegram-bot-api. I want users to be able to copy contract addresses (CAs) by tapping them once. Right now, users have to long-press to copy, which isn’t ideal.

Here’s what I’ve tried:

  1. Using Markdown formatting with backticks
  2. Creating inline keyboard buttons with callback data

But these methods don’t give the smooth, one-tap copy experience I’m after. I’ve seen other bots do this, where tapping the CA instantly copies it and shows a “copied to clipboard” message.

My current setup uses HTML parsing to format messages. The CA part looks like this:

📜 <b>CA:</b> `Ek4FUaAyinUT5whKyUMFv9qWpggud32P` (long-press to copy)

Is there a way to make this CA tappable for instant copying? Or is this not possible with the current Telegram Bot API? If not, what’s the closest I can get to this user-friendly feature?

I’m using node-telegram-bot-api 0.66.0 and Node.js 20.19.0 on a Raspberry Pi. Any ideas or workarounds would be super helpful!

hey mate, i’ve seen this issue before. try using a custom URL scheme like tg://copy?text=YOUR_CONTRACT_ADDRESS. it’s not perfect, but it’s better than long-pressing. also, consider sending the CA as a separate message - makes it easier to grab. good luck with ur bot!

As someone who’s built several Telegram bots, I can tell you that achieving a one-tap copy for contract addresses isn’t directly supported by the Telegram Bot API. However, I’ve found a workaround that comes pretty close.

Instead of using inline keyboard buttons or markdown formatting, try creating a custom URL scheme. You can format your message like this:

📜 CA: tg://copy?text=Ek4FUaAyinUT5whKyUMFv9qWpggud32P

When users tap this link, it’ll open a dialog asking if they want to copy the text. It’s not quite one-tap, but it’s smoother than long-pressing.

Another trick I’ve used is to send the CA as a separate message, making it easier for users to copy. You could also add a /copy command that sends the CA alone when triggered.

Remember, the ‘copied to clipboard’ notification is client-side, so your bot can’t control that directly. But these methods should improve the user experience significantly.

While the Telegram Bot API doesn’t directly support one-tap copying, there’s a clever workaround I’ve implemented in my projects. Use the tg://msg_url protocol with your contract address. For example:

📜 CA: tg://msg_url?url=Ek4FUaAyinUT5whKyUMFv9qWpggud32P

This creates a tappable link that opens a share dialog, allowing users to easily copy the address. It’s not instant, but it’s more user-friendly than long-pressing.

Another approach is to use inline keyboards with callback queries. When a user taps the button, have your bot respond with the CA in a separate message. This keeps your main message clean while providing easy access to the copyable text.

Remember, the exact user experience may vary slightly depending on the client app and platform.