{"id":3849,"date":"2022-12-22T06:05:52","date_gmt":"2022-12-22T06:05:52","guid":{"rendered":"https:\/\/cocoalopez.com\/blog\/?p=3849"},"modified":"2023-01-17T03:59:12","modified_gmt":"2023-01-17T03:59:12","slug":"telegram-bot-to-notify-your-channel-when-a-google-sheet-cell-has-been-edited","status":"publish","type":"post","link":"https:\/\/cocoalopez.com\/blog\/?p=3849","title":{"rendered":"Telegram Bot to notify your channel when a Google Sheet Cell has been edited"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Did this one over an hour to notify me when certain cells change their value and their adjacent values.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"194\" data-attachment-id=\"3851\" data-permalink=\"https:\/\/cocoalopez.com\/blog\/?attachment_id=3851\" data-orig-file=\"https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2022\/12\/image-4.png?fit=1049%2C318&amp;ssl=1\" data-orig-size=\"1049,318\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-4\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2022\/12\/image-4.png?fit=300%2C91&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2022\/12\/image-4.png?fit=640%2C194&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2022\/12\/image-4-1024x310.png?resize=640%2C194&#038;ssl=1\" alt=\"\" class=\"wp-image-3851\" srcset=\"https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2022\/12\/image-4.png?resize=1024%2C310&amp;ssl=1 1024w, https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2022\/12\/image-4.png?resize=300%2C91&amp;ssl=1 300w, https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2022\/12\/image-4.png?resize=768%2C233&amp;ssl=1 768w, https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2022\/12\/image-4.png?resize=672%2C204&amp;ssl=1 672w, https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2022\/12\/image-4.png?resize=1038%2C315&amp;ssl=1 1038w, https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2022\/12\/image-4.png?resize=400%2C121&amp;ssl=1 400w, https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2022\/12\/image-4.png?resize=696%2C211&amp;ssl=1 696w, https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2022\/12\/image-4.png?w=1049&amp;ssl=1 1049w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Change your telegram bot token and Channel ID to make it work.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On the google sheets you want to edit add the following code and add a trigger for it that starts OnEdit function when the cell is edited and set it to notify immediately<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/TELEGRAM BOT NOTIFIER WHEN A CEL HAS CHANGED ITS VALUE\n\/\/ CREATE A TRIGGER WITH THE onEdit Function (click on the watch at the APPS SCRIPT EDITOR, go to TRIGGERS, select the event for WHEN EDITING and set for notify immediately\n\n\/\/Place this script on the worksheet scripts\nfunction onEdit(e) {\n  \/\/ Get the edited cell and its value\n  var range = e.range;\n  var row = range.getRow();\n  var col = range.getColumn();\n  var value = range.getValue();\n  var previousValue = e.oldValue; \/\/ The previous value of the cell\n\n\n  \/\/ Get the worksheet and the value of the cell next to the edited cell\n  var sheet = range.getSheet();\n  var adjacentCellValue = sheet.getRange(row, col + 1).getValue();\n  var artistaLocal = sheet.getRange(row, col - 1).getValue();\n\n  \/\/ Get the value of the SHOT NUMBER\n  var cellValueAtB = sheet.getRange(row, 2).getValue(); \/\/ 2 is the column index for column B\n\n  \/\/ Get the value of the ARTIST WORKING ON THE SHEET\n  var artist = sheet.getRange(row, 7).getValue(); \n\n  \/\/ Get the value of the STAGE of the modification\n  var stage = sheet.getRange(12, col).getValue(); \/\/ 6 is the row index for row 6\n  \n\n  \/\/ Get the value of the PROJECT\n  var project = sheet.getRange(2, 3).getValue();\n\n  \/\/ Get the value of the EPISODE\n  var episode = sheet.getRange(3, 3).getValue();\n\n  \/\/ Get the Shareable URL and GID to join them within the message body\n  var thisDocumentUrl = SpreadsheetApp.getActiveSpreadsheet().getUrl();\n  var thisDocumentGid = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getSheetId()\n\n  \/\/ Send a message through the Telegram bot\n\n  var message = `&lt;a href='${thisDocumentUrl}#gid=${thisDocumentGid}'>&lt;u>${project} | ${episode}&lt;\/u>&lt;\/a>\\n &lt;b>${cellValueAtB} &lt;\/b>\\n &lt;i>${stage} &lt;\/i>\\n pas\u00f3 de &lt;em>${previousValue}&lt;\/em> a &lt;b>${value}&lt;\/b> \\n por ${artistaLocal}.`;\n\n\n\n  \/\/ Provide the Id of your Telegram group or channel\n  const chatId = '-5954105';\n\n  const BOT_TOKEN = '1986321029:AAF09NbQfA9wdCyLAHsjpoSC43ai0P0VEh4';\n\n  const TELEGRAM_API = `https:\/\/api.telegram.org\/bot${BOT_TOKEN}\/sendMessage`;\n\n  const text = encodeURIComponent(message);\n\n  const url = `${TELEGRAM_API}?chat_id=${chatId}&amp;text=${text}&amp;parse_mode=HTML`;\n\n  const response = UrlFetchApp.fetch(url, { muteHttpExceptions: true });\n\n  const { ok, description } = JSON.parse(response);\n\n    if (ok !== true) {\n      Logger.log(`Error: ${description}`);\n    \n    }\n};<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This code will run when you edit your google sheet and will send the message at the var message to your telegram channel.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Make sure to invite your bot to your channel and make it admin <br>You can follow more detailed instructions here: <a href=\"https:\/\/www.labnol.org\/telegram-bot-notifications-210814\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.labnol.org\/telegram-bot-notifications-210814<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Did this one over an hour to notify me when certain cells change their value and their adjacent values. Change your telegram bot token and Channel ID to make it work. On the google sheets you want to edit add the following code and add a trigger for it that starts OnEdit function when the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3851,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"tdm_status":"","tdm_grid_status":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1002],"tags":[],"class_list":["post-3849","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-featured"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2022\/12\/image-4.png?fit=1049%2C318&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9XJix-105","jetpack-related-posts":[{"id":4595,"url":"https:\/\/cocoalopez.com\/blog\/?p=4595","url_meta":{"origin":3849,"position":0},"title":"Tampermonkey Block BOTS from twitter","author":"cgmodeler","date":"July 3, 2025","format":false,"excerpt":"This tampermonkey script will block any bot from appearing on your timeline. Use tampermonkey for it to work. https:\/\/greasyfork.org\/en\/scripts\/541560-twitter-x-bot-and-flag-post-hider","rel":"","context":"In &quot;Featured&quot;","block_context":{"text":"Featured","link":"https:\/\/cocoalopez.com\/blog\/?cat=1002"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2025\/07\/image.png?fit=947%2C665&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2025\/07\/image.png?fit=947%2C665&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2025\/07\/image.png?fit=947%2C665&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2025\/07\/image.png?fit=947%2C665&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":4305,"url":"https:\/\/cocoalopez.com\/blog\/?p=4305","url_meta":{"origin":3849,"position":1},"title":"Mute unwanted Headlines and Images from websites","author":"cgmodeler","date":"March 27, 2024","format":false,"excerpt":"Well it's been a while, elections are coming and I don't want to be reading bullshit about people I don't care for, so made this quick TAMPERMONKEY script that will filter anything containing the words on the list and clear the website up for you. With a little blur: \/\/\u2026","rel":"","context":"In &quot;Featured&quot;","block_context":{"text":"Featured","link":"https:\/\/cocoalopez.com\/blog\/?cat=1002"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2024\/03\/image-4.png?fit=1036%2C949&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2024\/03\/image-4.png?fit=1036%2C949&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2024\/03\/image-4.png?fit=1036%2C949&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2024\/03\/image-4.png?fit=1036%2C949&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":2774,"url":"https:\/\/cocoalopez.com\/blog\/?p=2774","url_meta":{"origin":3849,"position":2},"title":"Convertir FPS a TIMECODE y TIMECODE a FPS en Excel \/ Google Sheets","author":"cgmodeler","date":"July 3, 2018","format":false,"excerpt":"This Excel formula grabs a timecode value from cell A1 and converts it into frames. The timecode should be in the format \"01:01:01;01\". The formula uses 30 frames per second and does not calculate drop frames. =VALUE(LEFT(A1,2))*60*60*30+VALUE(MID(A1,4,2))*60*30+VALUE(MID(A1,7,2))*30+RIGHT(A1,2) Example: A1: 01:06:46;11 RESULT: 120191 This Excel formula grabs a number value from\u2026","rel":"","context":"In &quot;Featured&quot;","block_context":{"text":"Featured","link":"https:\/\/cocoalopez.com\/blog\/?cat=1002"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2018\/07\/convertir-fps-a-timecode-y-timecode-a-fps-en-excel-google-sheets.jpg?fit=462%2C467&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":3884,"url":"https:\/\/cocoalopez.com\/blog\/?p=3884","url_meta":{"origin":3849,"position":3},"title":"Auto Switch Monitor Resolution BAT and Qres","author":"cgmodeler","date":"January 13, 2023","format":false,"excerpt":"Using qres and a cmd this script will switch from any specified resolution to the other and back just with running the BAT file. @echo off rem Get the current resolution set \"zzTmp=desktopmonitor get ScreenWidth^,ScreenHeight\" for \/f \"tokens=4,5 delims=. \" %%a in ('ver') do set \"version=%%a%%b\" if version GTR 62\u2026","rel":"","context":"In &quot;Featured&quot;","block_context":{"text":"Featured","link":"https:\/\/cocoalopez.com\/blog\/?cat=1002"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2023\/01\/image-3.png?fit=953%2C625&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2023\/01\/image-3.png?fit=953%2C625&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2023\/01\/image-3.png?fit=953%2C625&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2023\/01\/image-3.png?fit=953%2C625&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":3642,"url":"https:\/\/cocoalopez.com\/blog\/?p=3642","url_meta":{"origin":3849,"position":4},"title":"Collection of FFMPEG Drag &#038; Drop CMD\/BAT Tools","author":"cgmodeler","date":"July 2, 2022","format":false,"excerpt":"Here's a small collection of scripts i've made, downloaded, modified, etc to compress, edit, add, remux video files as well as converting mkv files without the need of re-rendering. Copy the code and save as a .bat file, save it on your ffmpeg bin folder or any command line if\u2026","rel":"","context":"In &quot;Featured&quot;","block_context":{"text":"Featured","link":"https:\/\/cocoalopez.com\/blog\/?cat=1002"},"img":{"alt_text":"close up photo of programming of codes","src":"https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2022\/07\/pexels-photo-546819.jpeg?fit=1200%2C797&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2022\/07\/pexels-photo-546819.jpeg?fit=1200%2C797&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2022\/07\/pexels-photo-546819.jpeg?fit=1200%2C797&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2022\/07\/pexels-photo-546819.jpeg?fit=1200%2C797&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2022\/07\/pexels-photo-546819.jpeg?fit=1200%2C797&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":4600,"url":"https:\/\/cocoalopez.com\/blog\/?p=4600","url_meta":{"origin":3849,"position":5},"title":"Helldivers PS4 Save Editing Guide: Key Variables &amp; Apollo Process","author":"cgmodeler","date":"November 1, 2025","format":false,"excerpt":"So I've spend about 5 hours but finally nailed it. Got how to edit the save file and make it work for Helldivers PS4 version. Feel free to buy me a coffe https:\/\/ko-fi.com\/cocoalopez This short guide covers editing common stats in Helldivers 1 PS4 save files using a hex editor\u2026","rel":"","context":"In &quot;Featured&quot;","block_context":{"text":"Featured","link":"https:\/\/cocoalopez.com\/blog\/?cat=1002"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/cocoalopez.com\/blog\/wp-content\/uploads\/2025\/11\/Helldivers_art.jpg?fit=315%2C315&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/cocoalopez.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3849","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cocoalopez.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cocoalopez.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cocoalopez.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cocoalopez.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3849"}],"version-history":[{"count":2,"href":"https:\/\/cocoalopez.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3849\/revisions"}],"predecessor-version":[{"id":3888,"href":"https:\/\/cocoalopez.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3849\/revisions\/3888"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cocoalopez.com\/blog\/index.php?rest_route=\/wp\/v2\/media\/3851"}],"wp:attachment":[{"href":"https:\/\/cocoalopez.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3849"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cocoalopez.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3849"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cocoalopez.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3849"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}