Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make phone number a link in Telegram Bot?

Our team tries to create the Telegram Bot and it is essential for us to make phone number in the long messages clickable. Sometimes we have to send our users messages with a lot of information and few phone numbers, so it is hard to get the phone, because telegram allows to copy only the whole message. If we send the short message without any markdown the telegram mobile app will highlight it:

await bot.send_message(chat_id, "Example text with a phone +79991234567")

Telegram shows the phone number as a link

If we use Markdown Telegram also make a number be clickable:

await bot.send_message(
    chat_id,
    "Example text with a phone [+79991234567](tel:+79991234567)", 
    parse_mode='Markdown'
)

Telegram shows the phone number as a link

Although if the message is a quite long Telegram just ignore the numbers and don't parse:

await bot.send_message(
    chat_id, 
    "Example text with a phone [+79991234567](tel:+79991234567)\nwithin a long-long message\nwithin a long-long message\nwithin a long-long message\nwithin a long-long message\nwithin a long-long message\nwithin a long-long message\nwithin a long-long message\nwithin a long-long message\nwithin a long-long message\nwithin a long-long message", 
    parse_mode='Markdown'
)

Telegram doesn't shows the phone number as a link

Is there a way to make Telegram to show phone numbers as a link? Thank you

like image 483
Sergey Cherepanov Avatar asked Nov 14 '16 14:11

Sergey Cherepanov


People also ask

How do I turn a phone number into a link?

Href=tel: creates the call link. This tells the browser how to use the number. “Tel: 123-456-7890 “creates the HTML phone number. The number within the quotes is the number it will call.

How can I get Telegram number link?

To create an invite link, go to Group Info > Add Member > Invite to Group via Link. Anyone who has Telegram installed will be able to join your group by following this link. If you choose to revoke the link, it will stop working immediately.


2 Answers

I found that when string length is 200 or more, highlighting won't work. Seems like unofficial limitation.

like image 53
Roman Pushkin Avatar answered Oct 25 '22 07:10

Roman Pushkin


According to Telegram API there's no such thing for showing numbers clickable. Your Telegram application is doing the job and for long messages it doesn't work (maybe open an issue in GitHub and tell them). You can just use HTML or Markdown to change style of phone numbers but they can't be clickable for saving to contacts.

like image 38
Vahid Msm Avatar answered Oct 25 '22 07:10

Vahid Msm