How to send message from Website To Telegram APP
Asked Answered
F

3

5

I have a share button in my website and I want to send a specific message to Telegram APP contacts (when I open website in Mobile)

The Problem is I didnt find the complete code and it just open the APP in the mobile

my code is :

<a href="tg://" id="telegram_share" class="mobileShare" title="inviteFriends" alt="telegram_share"></a>

as you see I didnt find proper command for sending message in href property

for example I found something simillar for adding sticker like :

<a class="tgme_action_button" href="tg://addstickers?set=Saber2">Add Stickers</a>
Franci answered 27/6, 2015 at 19:23 Comment(1)
To allow website visitors to chat directly with you through a Telegram widget (whitout leaving your website), you could use Intergram: github.com/idoco/intergramSpectrometer
F
13

iT's called URI Scheme Hope this one save someone else's time :)

<a href="tg://msg?text=your MsG!" id="telegram_share" class="mobileShare" title="inviteFriends" alt="telegram_share"></a>

right Now it only works on IOS

Franci answered 27/6, 2015 at 22:0 Comment(3)
There's anything for Android?Martinemartineau
A link like this <a href="tg://msg?text=your MsG!">link</a> does work in Android tooAggravation
Do you know any place other than telegram.wiki/tips:urischeme to understand all the possible parameters of the URI scheme?Godbeare
S
3

USE THE API

Once you've set up a username, you can give people a t.me/username link. Opening that link on their phone will automatically fire up their Telegram app and open a chat with you. You can share username links with friends, write them on business cards or put them up on your website.

This way people can contact you on Telegram without knowing your phone number.

That is currently the best way to link to someone's Telegram, and is stated officially in here: https://telegram.org/faq/?setln=en#q-how-does-t-me-work

This method redirects to:

tg://resolve?domain=username

If you want to send a message, there's no official information about it, so you would need to do it using URI scheme as mentioned in the question, using this structure (which doesn't seem to allow specifying to whom the message will be sent):

tg://msg?text=yourMsG

It seems we can't mix both.

Spectrometer answered 29/6, 2018 at 4:28 Comment(1)
At least it would be interesting to be able to send a message to an already started chatID ...Superinduce
I
3
 <a target="_blank" href="https://t.me/share/url?url=Hi,How Are You ?">
  Share Hi,How Are You ? To Telegram
 </a>

enter image description here

Incus answered 22/11, 2020 at 11:48 Comment(1)
While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value.Nez

© 2022 - 2024 — McMap. All rights reserved.