Telegram is not just a messenger, it’s one of the features-overstaffed applications. One exciting feature are the bots and the API which gives a real easy-to-do integration.
This 4-part series tutorial tasks you through each step to create, integrate PowerShell with Telegram bot. and by the end of this tutorial, you will learn how to create a Telegram bot and take control of it to control the Infrastructure using Powershell. for instance, send and receive notifications, status updates, or executing troubleshooting commands.
Table of Contents
What is Telegram bot
Telegram Chatbot is accounts-operated software, there is no person on the other side of the line, they are meant to perform a specific function. Telegram did a nice job of making things easy to integrate.
Creating a Telegram bot
The process of creating a Telegram chatbot is easy, all that you need is to install Telegram on your mobile and send messages to The BotFather bot.
Answer a few questions such as the name of the chatbot, and you will be presented with an HTTP KEY. Let’s try to do it together.
I will create a new chatbot and name it PowershellCenterbot
Before starting it’s a good idea to take a look at the Telegram API.
Once you install Telegram, search for BotFather as shown in the picture below, or simply use the desktop app and send a click on this link https://t.me/botfather
Click on the bot and then press on Start, the bot will respond with a message asking what do you want to do, click on /newbot, or simply type it /newbot.
I will name it Powershellcenterbot, Make sure that your chatbot name finishes with the word bot.
BotFather will send you the HTTP API Token key, this is an important part of all the communication.
Sending Messages using Telegram Client.
Now we have created the bot, we can try to send a message to it using the Telegram messenger, your bot will be reachable via search or via sending /mybots to The BotFahter. once you find your bot, click Start to send a text message and see what will happen.
Even though I sent a message to the bot, but there is no message back, not a confirmation or anything. So where did these messages go?
Incoming Messages Page /getUpdates
Remember the HTTP API Token?!, we will need that key to see the messages that the client sent to the bot, let call it the incoming messages page. Let’s navigate to this page https://api.telegram.org/bot{Token}/getUpdates. But just you need to replace the {Token} with your API Key, my API Key was 1418701162:AAEIklEHZowjxorXL6VNfgzV54CmnPoUa3c. The full URL will be
https://api.telegram.org/bot1418701162:AAEIklEHZowjxorXL6VNfgzV54CmnPoUa3c/getUpdates
After opening this page, we will find the messages in JSON format.
This will give us an idea of how to ensure that the messages are arriving, keep your eyes on it while developing the code, as sometimes the delivery got delayed.
Control your Infrastructure using… Telegram Messenger (Part 1 – Create the Bot)
Control your Infrastructure using… Telegram Messenger (Part 2 – Send and Receive.)–>
Control your Infrastructure using… Telegram Messenger (Part 3 – Basic Security) –>
Control your Infrastructure using… Telegram Messenger (Part 4 – Execution) –>