How to send Telegram Messages in Java

Using the WhatsMate Telegram Gateway REST API



This article shows you how to send a Telegram message in Java.

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 Java, do this:

  1. Copy the following source code to a Java file named TelegramSender.java.
  2. Customize the TODO lines:
    • Specify your gateway instance ID on line 9.
    • Specify your client ID and secret on lines 10 and 11.
    • Specify your target recipient on line 18. Remember to include the country code.
    • Specify your message on line 19.
  3. Compile the Java file: javac TelegramSender.java
  4. Execute the class to send your message: java TelegramSender

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