First of all note that:
There is 9 digit old chat ids and 10 digit new chat ids.
There is two internal links for it:
Android:
tg://openmessage?user_id=1234567890
IOS:
tg://user?id=1234567890
And a web link for telegram web:
https://web.telegram.org/k/#1234567890
When you click on this web link it redirects to username if its available:
https://web.telegram.org/k/#@USERNAME
And there is a username link for windows:
tg://resolve?domain=USERNAME
This one doesn't have an "@"
Combine these and build your solution.