In the previous article we saw a demo video of the 2-way integration between Salesforce and Telegram and a simple use case. In this article I will quickly show the configurations and Apex code to send messages from Salesforce to Telegram. In the next article we will discuss 2 different ways of achieving the other way round i.e processing messages from Telegram to Salesforce. So lets start!

Bot Creation in Telegram

  1. Open the Telegram App and Search for BotFather
  2. Enter command /start and /newbot
  3. After a series of straightforward question and answers you should be able a create a Bot and generate an access token. One such conversation is shown below:

Telegram Bot creation with BotFather for Salesforce Integration

Send Message to Telegram

Once the access token is generated, sending message from Salesforce is a simple Apex callout as shown below:

HttpRequest req = new HttpRequest();
            payload = 'text=' + message +'&chat_id='+receiver_chatid;
  • message is the text you want to send to the Telegram Contact
  • receiver_chatid is numeric id (usually 7 digits) of the contact. In the use case we saw in the previous article we get this id when a Telegram user sends message to the Bot

Make sure you create a Remote Site Setting for the URL

You've successfully subscribed to inteygrate
Welcome back! You've successfully signed in.
Great! You've successfully signed up.
Success! Your account is fully activated, you now have access to all content.