Telegram and Google Sheets integration: the bot saves messages to a sheet

A Telegram and Google Sheets integration in nana800 takes two blocks: the trigger catches messages to your bot, and the Google Sheets block adds a row for each of them. A row can hold the text, the sender name and username, the chat ID, the date and a link to the file sent. You need a bot token from @BotFather and access to the sheet, with no code and no server.

Build it in the builder

What you can automate

  • Collect leads through a bot: a client writes, and the name, username, text and date land in a new row
  • Take reports, receipts and photos from staff: a link to the file sent, up to 20 MB, goes into a sheet column
  • Archive posts of a channel where the bot is an admin in a sheet with the date and text
  • Count answers to buttons under a bot message: a press starts the scheme too, and the button data goes into the row
  • Find a client by username and update their row instead of adding a new one

How to set it up

  1. 1

    Create a bot and prepare the sheet

    Send /newbot to @BotFather and copy the bot token. Write column names into the first row of the sheet, for example date, name, username, message. The block puts data under these names and writes them itself into an empty sheet.

  2. 2

    Add the incoming message trigger

    Create a scheme in the builder and add the Telegram message from user to bot trigger. Paste the token and choose what starts the scheme: messages only, messages and button presses, or channel posts.

  3. 3

    Give the block access to the sheet

    Add the google sheet record block. OAUTH: click the connect button and sign in with a Google account that can open the sheet. SERVICE_ACCOUNT: paste the email and private key of a Google service account and share the sheet with that email as an editor.

  4. 4

    Map columns to message fields

    Paste the whole sheet address into the sheet ID field and keep sheet number 0 for the first tab. Choose append_row, and in the row data write a column name on the left and a trigger field on the right: date, name and username from from, text from message, chat_id.

  5. 5

    Turn the scheme on and message the bot

    The trigger receives messages only while the scheme is on. Turn it on, message the bot and open the sheet: a new row appears at the bottom. If it does not, open the block result, the hint from Google is in error_message. An enabled scheme costs $0.0042 per hour.

  6. 6

    Reply to the person

    After the row is saved, add the Telegram message send block with the same token and chat_id from the trigger, and write something like "Request received". This way the client sees the message got through.

Pricing

A run of a Telegram block costs $0.001, a run of a Google Sheets block costs $0.001. Every month the balance is topped up to $3.50 for free, an enabled scheme costs $0.0042 per hour.

Services in this connection

  • Telegram

    Build a Telegram bot without code: reply to messages, add buttons, send leads and alerts to a chat, group or channel. Free balance every month, no card needed.

  • Google Sheets

    Send leads and orders to Google Sheets without code: append rows, find, read and update them by row number. Free balance every month, no card needed.

Frequently asked questions

Each message means two basic block runs: the trigger and the row write, $1 per 1,000 runs each. An enabled scheme costs $0.0042 per hour. Your balance is topped up to $3.50 every month: that is 3,500 basic block runs if you leave scheme hours aside. A scheme kept on around the clock spends most of it on hours.

Check that the scheme is on and the trigger listens to the right events. If the same bot is connected to another service that also reads its messages, the trigger gets nothing: create a separate bot for nana800. If messages arrive but rows do not, look at error_message of the sheet block: common causes are a sheet not shared with the service account or the Google Sheets API not enabled in Google Cloud.

Yes. Photos, videos, voice messages and documents up to 20 MB are copied to nana800 storage, and their links are in image_urls, video_urls, audio_urls and document_urls. Put a link into a sheet column. Files over 20 MB get no link because Telegram does not give such files to bots.

First look for the row with find_rows, for example by username. Then add the condition block: if a row was found, update it with update_row using row_number, if not, add a new one with append_row. The condition block is free.

Yes. The trigger catches messages to the bot in private chats and in groups it was added to, plus posts in channels where the bot is an admin. Pick the option in the events field. Mind the Telegram rule: in a group a bot gets only commands and replies to its own messages by default. To let it see the whole chat, turn off privacy mode with /setprivacy in @BotFather or make the bot a group admin.

No. Both blocks are set up with fields in the browser: the bot token, the sheet address, column names and message fields. You do not need a server either: nana800 fetches the messages of the bot with its token.

Build your first scheme for free

Sign-up is free and needs no card. Every month the balance is topped up to $3.50 for free, enough for about 3,500 runs of basic blocks.

Build it in the builder