Skip to main content

How to send a message to a Telegram channel using a bot

In this article, we'll explain how to create a Telegram bot and use it to post notifications in channels

How to create a Telegram bot

  1. Search for the “@Botfather” in Telegram

  2. Start a conversation and type “/newbot”

  3. Enter the new bot’s name (this will be a display name)

  4. Enter bot’s username (must end with “_bot”)

  5. Get the bot’s API Token

💡 Bots can’t message people first, but message channels can.

How to get the chat ID for the Telegram channel

  1. Create a new channel in Telegram (you can do so by starting a new message)

  2. Invite your bot to the Channel (search by bot’s username) and add it as an Admin

  3. Go to https://api.telegram.org/bot{{TOKEN}}/getUpdates
    Replace {{TOKEN}} with your bot’s Token in the URL (you can always get your token under chat with @Botfather). You should get the following message:

    {"ok":true,"result":[]}
  4. Post something to the channel with the bot (so the bot “sees” that it’s added to the channel)

  5. Refresh the link above, and it should have a list of all channels and conversations the bot participates in. You should get a similar message:

"channel_post":{"message_id":2,"sender_chat":{"id":-1001631771642,"title":"ThisIsThechannel","type":"channel"},"chat":{"id":-1001631771642,"title":"ThisIsThechannel","type":"channel"},"date":1660333732,"text":"hey","has_protected_content":true}}]}

6. This is a chat ID that you need to make an API call (it starts with "-"):

How to make an API call to the Telegram channel

Create a Workflow with Make an API call

If you’re a CEO or sales manager, getting notified about lost deals in real time can help you react faster and improve your sales strategy. With NetHunt CRM, your workflow can automatically send Telegram alerts whenever a deal is marked as “Lost,” including all key deal details for quick analysis and decision-making. Here is how you can do this:

  • Choose a trigger you need. In our case, it will be "Field value changes" to the Lost" status in the "Stage" field in the Deals folder:

  • In the second step, choose the "Make an API call" action with the Post" type. In the URL field, paste the following:
    https://api.telegram.org/bothere should be your bot's token/sendMessage

    In the JSON field, enter the data you want to push via the Bot.


    Syntax:
    {
    "chat_id": here should be your channel ID,
    "text": "deal was lost. Reason:",
    "parse_mode": "HTML"
    }

  • Activate the workflow to receive instant updates about lost deals:

NOTES:

  • "parse_mode": "HTML" is optional. Only need to include this line if the text in the “text” contains HTML tags like <b> to show this formatting.

  • Line breaks can be added by typing “\n”


Haven’t found the answers you’re looking for? Contact our Support Team directly from the CRM.

Did this answer your question?