How to send Telegram Messages in C# using Visual Studio 2019

Using the WhatsMate Telegram Gateway REST API



This article shows you how to send a Telegram message in Microsoft’s .net language: C# using Visual Studio 2019.

If you are using Visual Studio 2022, please read this tutorial instead.

Before the recipient can receive your Telegram message, she will need to register with the WhatsMate Telegram Gateway. Instructions are available on the official site. Unregistered users will never receive messages from the Gateway.

To send a Telegram message in C# using Visual Studio 2019, do this:

  1. Copy the following source code to the main class in your Console Application in Visual Studio.
  2. Customize the TODO lines:
    • Specify your gateway instance ID on line 10.
    • Specify your client ID and secret on lines 11 and 12.
    • Specify your target recipient and message on line 19. Remember to include the country code in the recipient’s number.
  3. Add the reference “System.Web.Extensions” by doing this:
    1. Right-click on your project node in the Solution Explorer panel.
    2. Choose “Add” -> “Reference…”
    3. Choose “Framework” on the left pane.
    4. Look for “System.Web.Extensions” in the middle pane. Check the checkbox in front of it.
    5. Click OK.
  4. Build and run the application in Visual Studio.

You will need a trial account to call the above API. Go sign up now.