A Telegram Bot is a programe that behaves like a normal chat partner with additional functions. It performs predefined tasks independently and without the user’s involvement. The term bot is derived from the term for robot. We can use the Telegram Bot API to import data from Telegram Bot into Google Sheets. In this tutorial, we’ll show you how to connect the Telegram Bot REST API to Google Sheets in 5 steps:
Apipheny is a free API connector for Google Sheets. You can use Apipheny to connect your Google Sheets to API data sources, easily.
1.) Install Apipheny by opening the following link on desktop and then clicking the Install button in the Google Marketplace: https://apipheny.io/install
2.) After you’ve installed Apipheny, open a Google Sheet and then click on the Extensions dropdown in the menu at the top.
In the dropdown list you should see Apipheny. Click Apipheny then click Import API to open the Apipheny sidebar in your Google Sheet.
Tip: you can open a new Google Sheet by entering this URL in your browser: sheet.new
In your Telegram app, Enter @Botfather in the search tab and choose this bot.
Note: Official Telegram bots have a blue checkmark beside their name.
Click “Start” to activate BotFather bot:
In response, you receive a list of commands to manage bots.
Choose or type the /newbot command and send it.
Choose a name for your bot — your subscribers will see it in the conversation:
And choose a username for your bot — the bot can be found by its username in searches. The username must be unique and end with the word “bot”:
After you choose a suitable name for your bot — the bot is created. The token will be displayed in this last message:
Copy the token to a safe location because you’ll need it later.
In this section, we’ll show you how to browse the Telegram Bot API documentation to find the endpoint URL that retrieves the information you need from your Telegram account.
If you already know your API URL, or you want to use the same example URL as us, just skip to Step 4.
To choose an endpoint, first open the Telegram Bot API documentation page: https://core.telegram.org/bots/api#available-methods
The main section contains all the available methods (endpoints) for the Telegram Bot API with their descriptions. The right menu contains a list of these methods for easy finding:
In this case, we will describe the getUserProfilePhotos method (endpoint), which get a list of profile pictures for a user:
https://api.telegram.org/botTOKEN/getUserProfilePhotos
Don’t forget to replace TOKEN with your own token.
The documentation for this endpoint contains its HTTP, a short description of the endpoint’s purpose and the required/optional parameters if any:
All API calls to the Telegram Bot should be made using the https://api.telegram.org/bot base domain. All endpoints and parameters would be appended to this base domain.
Now go back to your Google Sheet and make sure that the Apipheny add-on is open, on the Import tab.
In the Import Tab, enter these details into the add-on:
Method: At the top of the Apipheny sidebar, select the HTTP method (GET, POST, PUT, PATCH or DELETE) required by your API endpoint. For this example, we are using the GET method.
API URL: In Step 3, we explained how you can find the Telegram Bot API endpoint that you need. Now copy the complete URL into the Apipheny add-on, where it says API URL Path, followed by any GET parameters required for your query.
For this example, we are using the getMyName endpoint, which displays the current bot name for the given user language. The URL for this API endpoint is:
https://api.telegram.org/TOKEN/getMyName
Don’t forget to replace TOKEN with the token you obtained in Step 2.)
Headers: The Headers section of the Apipheny add-on will be left blank.
Here’s what your Telegram Bot API request should look like when entered into Apipheny, if you’re following the same example as us:
The last step is to click the Run button at the bottom of the Apipheny add-on and then your Telegram data will be imported into your Google Sheet:
Schedule requests for automatic updates
Reference cell values in requests
Stack multiple URLs in a single request
Crypto API Tutorials: