Skip to main content

Post to Telegram from Google Sheets with Document Studio

Document Studio enables you to automatically post messages to your Telegram Groups and Channels from data in Google Sheets.

Create a Telegram Bot

The first step is to create a new Telegram bot that will be used to send messages to a Telegram group or channel. To create a new bot, go to BotFather (works inside the Telegram app on desktop, Telegram web app or your Telegram mobile app) and click the Start button.

Type /newbot and hit Enter to create a new bot. Give your bot a name and then provide a username for your bot. The username should not contain spaces, only alphanumeric characters and underscores can be used. It should end with the word bot like documentstudio_bot.

Telegram Bot for Google Sheets

Telegram will now provide a secret API token for your bot that we'll need at a later stage.

Warmup the Telegram Bot

Please make sure that the bot has been added to the Telegram group or channels you want to send messages to.

Open the bot's profile link (e.g., t.me/username_bot) click on the top bar where its name is displayed, and then from the 3-dot menu, select Add to group to add the bot any Telegram group of your choice that you are a member of.

This step should be completed on Telegram's mobile app since not all Telegram features are available on the web or desktop.

Telegram Group

Promote the Bot to Admin

Open the Telegram group where you want to send messages from Document Studio. Go to the list of members, long press the bot name and select Promote to admin.

Now type "Hello" (or any text message) in the Telegram group. This is an important step.

Telegram Admin

Connect Telegram to Google Sheets

Install Document Studio and open your Google Sheet to launch the add-on. You may either open an existing sheet or create a new sheet and add data manually to the sheet.

Inside the Document Studio app, provide a descriptive name for your workflow and choose the worksheet in your Google Spreadsheet that contains the merge data. Click on Continue to move to the conditions page.

On the Conditions panel, specify if you want your workflow to run only if the rows in the Google Specific sheet satisfy certain conditions. By default, the workflow will run for all rows in the sheet that contain data.

Next, choose Telegram from the list of available tasks.

Telegram to Google Sheets

Make a Telegram message template

Inside the Telegram task, paste the bot API token and click Verify to get a list of channels and groups where the bot has access to post messages.

TIP: If you do not see any group or channel in the drop-down list, switch to that group inside Telegram and manually post any text message, just say Hello, in the group.

Switch to Document Studio and click on Refresh and you should see the list of channels and groups that the bot has access to post messages.

A message saying Telegram connected indicates that the connection is successful.

info

In some cases, Document Studio may show an error message saying Please add this bot to a Telegram group or channel.

To fix this error, open the Telegram app on your phone, remove the bot from your group and add it back. Then, click on Refresh.

You can use dynamic fields, enclosed in double curly braces, in the message body. For instance, if name, age and city of members are listed in your Google Sheet, you can personalize the Telegram messages with variables.

Telegram Configuration

Telegram Bots also support Scriptlets to add conditional text in the message body.

{% if {{Age}} > 18 or {{Age}} == 18 %}
{{Name}} can vote in the elections
{% endif %}

Preview and Save

Click the Preview button and you should see the message in Telegram. Document Studio will take the data from the second row of the selected Google Sheet and publish the message to your selected Telegram group or channel. Click Done to locally apply your changes.

Telegram Message

If you want the workflow to be automatically triggered every hour, so that any new rows added in that duration are processed automatically, you can choose the option Run workflow every hour and then click on the Save button.

The workflow will now appear in the workflow dashboard where you can edit, delete or manually run the workflow.