Click here to Skip to main content
15,397,981 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
i have an application for creating appointment. i want to send message via telegram from my website to some fixed users(they have telegram installed in their mobile phone. ).
i checked this link:
Other applications using the api :
and created appconfiguration for telegram.but icanot find a suitable simple example which shows how this api can be used in .plz help i have done a loat of search .i found webogram which worked in my machine too but i cant find out how they called api . i m a beginner in i want to know how api call from my pages .plz help . i am asked same question before but no one replayed :(.
sorry for my bad English . PLZ help
Updated 21-Mar-22 11:23am
Goroh 11-Aug-14 6:13am
Have you found any solution? I have the same task, it's neccessary to implement sending messages from .net
flykoh 1-May-15 17:08pm
the API is too complicated there some uncompleted project in GitHub i try for the last three month but i failed

1 solution

I write this code for sending message to my contacts

first you must install TLSharp from nuget -->
Install-Package TLSharp

public static async void GetMyContacts()
           //get available contacts
           var client = new TelegramClient(ApiId, "ApiHash");
           await client.ConnectAsync();

           var hash = await client.SendCodeRequestAsync("+YourPhoneNumber");
           var code = "32000"; // you can change code in debugger //code will send via telegram to you

           TLUser user = null;
               user = await client.MakeAuthAsync("+YourPhoneNumber", hash, code);
           catch (CloudPasswordNeededException ex)
               //if u activate two step verification in telegram
               var password = await client.GetPasswordSetting();
               var password_str = "yourPassword";

               user = await client.MakeAuthWithPasswordAsync(password, password_str);

           if (client.IsUserAuthorized())
               //get available contacts
               var result = await client.GetContactsAsync();

               //find recipient in contacts
               var userr = result.users.lists
                   .Where(x => x.GetType() == typeof(TLUser))
                   .FirstOrDefault(x => x.username == "a username from ur contacts in telegram");

               //send message
               await client.SendMessageAsync(new TLInputPeerUser() { user_id = }, "My Message  :Hi :)");

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900