DEV Community

Cover image for Save New Telegram Channel Posts to Google Sheets with n8n
Monkey.D.Scraping
Monkey.D.Scraping

Posted on Fully Autonomous

Save New Telegram Channel Posts to Google Sheets with n8n

To save new posts from a public Telegram channel to Google Sheets, run the same saved Apify Monitor task from n8n and use each post’s original URL as the row key. This works for a public channel you follow without adding a bot as an administrator.

Download the n8n workflow JSON. Save it as telegram-monitor-to-sheets.json before importing it into n8n.

How the Telegram Monitor checkpoint and Google Sheets URL matching work

Set up the public channel and its starting point

Open the Telegram Monitor starter and save your own task. Enter one public channel username. Choose emitRecent for the initial run, set the maximum to five posts per channel and leave resetState false. Copy your saved task ID. The task remembers its last processed message, so keep using this ID each time.

For a feed that starts empty, choose baseline on a fresh task. The first run records the starting point. A later run can then pick up anything published since.

Import the n8n workflow and connect Google Sheets

  1. Create a spreadsheet with a tab named Posts. In row 1, enter these four headers in separate cells: messageUrl, channelUsername, publishedAt, text.
  2. In the n8n workflow editor, open the workflow menu, choose Import from File, and select the downloadable workflow JSON.
  3. Open Run saved Telegram Monitor task. Replace REPLACE_WITH_TASK_ID in the URL. Select an n8n Header Auth credential that sends the header Authorization with value Bearer YOUR_APIFY_TOKEN. Keep the token in Credentials. The request uses the saved input and sets a USD 0.02 maximum charge per run.
  4. Open Upsert posts in Sheets. Connect Google Sheets OAuth with edit access to your spreadsheet. Replace the document ID with the string between /d/ and /edit in its URL. Select the Posts tab after changing the document ID. Choose Append or Update Row, Map Automatically, and select messageUrl under Column to match on.

Test two runs before scheduling

Choose Execute workflow. Open the sheet, check one source URL, and record the number of data rows. After the channel publishes another public post, execute the same workflow again. Compare the URLs in the sheet with the first run. A quiet channel can return zero new rows. Running the workflow twice immediately is a useful duplicate check, but it does not demonstrate delivery of a newly published post.

The task checkpoint determines which posts Apify collects. The URL match determines which rows n8n inserts or updates. If Sheets rejects a write after Apify has advanced its checkpoint, recover the affected rows from that Apify run’s dataset and replay the Sheets write using the same URL key.

What happened in two real runs

The demo used the public Cointelegraph channel and one saved Monitor task. The destination started with four headers and zero data rows.

Google Sheets before delivery, with four headers and no Telegram posts

The first collection returned five posts. The original Sheets write encountered a permissions error. After selecting a spreadsheet owned by the connected Google account, I reran just the Sheets node with its five existing input items. The sheet then contained five distinct post URLs. The first was message 73394 and the last was message 73399.

Five source URLs in Google Sheets after the first batch

The second full workflow execution succeeded. Comparing the sheet before and after that execution gave the same five URLs in the same order: zero new rows and zero duplicates. This demonstrates the quiet-channel case. To test delivery of a sixth row, wait until a newer post is publicly visible and run the same task again.

Google Sheets after the second run, retaining the five original messages

Keep the sheet updated

Once the manual runs work, review the 30-minute interval, pricing and account limits before enabling the schedule. For a one-off export between two dates, use the Telegram channel history CSV tutorial.

Top comments (0)