{"id":52647,"date":"2025-03-12T14:00:00","date_gmt":"2025-03-12T13:00:00","guid":{"rendered":"https:\/\/blog.sheetgo.com\/?p=52647"},"modified":"2025-08-07T21:29:54","modified_gmt":"2025-08-07T19:29:54","slug":"envoyer-des-notifications-slack-a-partir-dune-feuille-de-calcul-google","status":"publish","type":"post","link":"https:\/\/www.sheetgo.com\/fr\/blog\/google-sheets-features\/send-slack-notifications-from-a-google-sheets\/","title":{"rendered":"Comment envoyer des notifications Slack \u00e0 partir d'une feuille de calcul Google Sheets en utilisant Apps Script ?"},"content":{"rendered":"\n[et_pb_section fb_built=&#8221;1&#8243; _builder_version=&#8221;4.27.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][et_pb_row _builder_version=&#8221;4.27.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.27.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][et_pb_text _builder_version=&#8221;4.27.2&#8243; _module_preset=&#8221;default&#8221; hover_enabled=&#8221;0&#8243; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221; sticky_enabled=&#8221;0&#8243;]<blockquote>\n<p><strong data-start=\"47\" data-end=\"56\">Note:<\/strong> This post was originally published in our community forum.<\/p>\n<\/blockquote>\n<p>In the modern workplace, automating routine tasks is key to efficiency. One common task is sending notifications based on spreadsheet data, such as birthdays or anniversaries. Slack, a popular communication tool for teams, can be integrated with Google Sheets to send automated notifications, making it easier to celebrate special occasions or remind team members of important dates.<\/p>\n<p>In this blog post, we\u2019ll guide you through the process of setting up Slack notifications from a Google Spreadsheet using Google Apps Script, and how to create a Slack app for this purpose.<\/p>\n<h2><strong>Creating a Slack app for notifications<\/strong><\/h2>\n<p>Before diving into the script, you need to set up a Slack app to send notifications to your workspace. Here\u2019s how:<\/p>\n<ol>\n<li><strong>Start by visiting the Slack API website<\/strong><span>\u00a0<\/span>at<span>\u00a0<\/span><a href=\"https:\/\/api.slack.com\/apps\" rel=\"ugc noopener nofollow\" target=\"_blank\">https:\/\/api.slack.com\/apps<\/a>. Log in if prompted.<\/li>\n<li><strong>Create a New App<\/strong>: Click on \u201cCreate New App.\u201d Choose \u201cFrom scratch\u201d and give your app a name. Select the workspace where you want the app installed.<\/li>\n<li><strong>Enable Incoming Webhooks<\/strong>: After creating your app, go to \u201cIncoming Webhooks\u201d in the \u201cFeatures\u201d section and toggle it on. This allows your app to send messages to a Slack channel.<\/li>\n<li><strong>Generate a Webhook URL<\/strong>: Click \u201cAdd New Webhook to Workspace,\u201d choose a channel (like #general) for notifications, and click \u201cAllow.\u201d Copy the webhook URL provided.<\/li>\n<\/ol>\n<p>This URL is what you\u2019ll use in your Google Apps Script to send messages from your spreadsheet to Slack.<\/p>\n<h2><strong>Automating Slack notifications with Google Apps Script<\/strong><\/h2>\n<p>With your Slack app and webhook ready, the next step is to automate notifications from a Google Spreadsheet. Assume you have a spreadsheet with Column A for emails, Column B for names, and Column C for birthdays.<\/p>\n<ol>\n<li><strong>Open Your Spreadsheet<\/strong>: Go to the spreadsheet from which you want to send notifications.<\/li>\n<li><strong>Access the Apps Script Editor<\/strong>: Click on<span>\u00a0<\/span><strong><code>Extensions<\/code><\/strong><span>\u00a0<\/span>&gt;<span>\u00a0<\/span><strong><code>Apps Script<\/code><\/strong><span>\u00a0<\/span>and clear any existing code.<\/li>\n<li><strong>Paste the Script<\/strong>: Use the following Google Apps Script, replacing<span>\u00a0<\/span><strong><code>'YOUR_WEBHOOK_URL_HERE'<\/code><\/strong><span>\u00a0<\/span>with your actual webhook URL from Slack.\n<pre><code data-highlighted=\"yes\" class=\"hljs language-javascript\">   <span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title function_\">sendSlackNotifications<\/span>(<span class=\"hljs-params\"><\/span>) {\n     <span class=\"hljs-keyword\">var<\/span> webhookUrl = <span class=\"hljs-string\">'YOUR_WEBHOOK_URL_HERE'<\/span>;\n     <span class=\"hljs-keyword\">var<\/span> sheet = <span class=\"hljs-title class_\">SpreadsheetApp<\/span>.<span class=\"hljs-title function_\">getActiveSpreadsheet<\/span>().<span class=\"hljs-title function_\">getSheetByName<\/span>(<span class=\"hljs-string\">'Sheet1'<\/span>);\n     <span class=\"hljs-keyword\">var<\/span> data = sheet.<span class=\"hljs-title function_\">getDataRange<\/span>().<span class=\"hljs-title function_\">getValues<\/span>();\n     <span class=\"hljs-keyword\">var<\/span> today = <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-title class_\">Date<\/span>();\n     today.<span class=\"hljs-title function_\">setHours<\/span>(<span class=\"hljs-number\">0<\/span>,<span class=\"hljs-number\">0<\/span>,<span class=\"hljs-number\">0<\/span>,<span class=\"hljs-number\">0<\/span>);\n   \n     data.<span class=\"hljs-title function_\">forEach<\/span>(<span class=\"hljs-keyword\">function<\/span>(<span class=\"hljs-params\">row, index<\/span>) {\n       <span class=\"hljs-comment\">\/\/ Skip header row<\/span>\n       <span class=\"hljs-keyword\">if<\/span> (index === <span class=\"hljs-number\">0<\/span>) <span class=\"hljs-keyword\">return<\/span>; \n       <span class=\"hljs-keyword\">var<\/span> email = row[<span class=\"hljs-number\">0<\/span>], name = row[<span class=\"hljs-number\">1<\/span>], birthday = <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-title class_\">Date<\/span>(row[<span class=\"hljs-number\">2<\/span>]);\n       birthday.<span class=\"hljs-title function_\">setHours<\/span>(<span class=\"hljs-number\">0<\/span>,<span class=\"hljs-number\">0<\/span>,<span class=\"hljs-number\">0<\/span>,<span class=\"hljs-number\">0<\/span>);\n   \n       <span class=\"hljs-keyword\">if<\/span> (birthday.<span class=\"hljs-title function_\">getTime<\/span>() === today.<span class=\"hljs-title function_\">getTime<\/span>()) {\n         <span class=\"hljs-keyword\">var<\/span> payload = <span class=\"hljs-title class_\">JSON<\/span>.<span class=\"hljs-title function_\">stringify<\/span>({ <span class=\"hljs-attr\">text<\/span>: <span class=\"hljs-string\">`\ud83c\udf89 Happy Birthday, <span class=\"hljs-subst\">${name}<\/span> (<span class=\"hljs-subst\">${email}<\/span>)! \ud83c\udf89`<\/span> });\n         <span class=\"hljs-keyword\">var<\/span> options = { <span class=\"hljs-attr\">method<\/span>: <span class=\"hljs-string\">'post'<\/span>, <span class=\"hljs-attr\">contentType<\/span>: <span class=\"hljs-string\">'application\/json'<\/span>, <span class=\"hljs-attr\">payload<\/span>: payload };\n         <span class=\"hljs-title class_\">UrlFetchApp<\/span>.<span class=\"hljs-title function_\">fetch<\/span>(webhookUrl, options);\n       }\n     });\n   }<\/code><\/pre>\n<\/li>\n<li><strong>Save and Run the Script<\/strong>: Click the disk icon to save, then click the play button to run your script manually.<\/li>\n<li><strong>Automate Daily Notifications<\/strong>: To have this script run daily, click on the clock icon (Triggers) and set a time-based trigger for the<span>\u00a0<\/span><strong><code>sendSlackNotifications<\/code><\/strong><span>\u00a0<\/span>function.<\/li>\n<\/ol>\n<h3><strong>Final thoughts<\/strong><\/h3>\n<p>Integrating Slack with Google Sheets through Apps Script is a powerful way to automate notifications. Whether you\u2019re celebrating birthdays, tracking project milestones, or reminding team members of important dates, this setup simplifies communication and ensures no special occasion goes unnoticed. Always remember to keep your webhook URL secure and test your setup thoroughly before rolling it out to your entire team. With a little setup, your team\u2019s communication can become more efficient and engaging.<\/p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][\/et_pb_section]\n","protected":false},"excerpt":{"rendered":"<p>Note: This post was originally published in our community forum. In the modern workplace, automating routine tasks is key to efficiency. One common task is sending notifications based on spreadsheet data, such as birthdays or anniversaries. Slack, a popular communication tool for teams, can be integrated with Google Sheets to send automated notifications, making it [&hellip;]<\/p>\n","protected":false},"author":49,"featured_media":44470,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_et_pb_use_builder":"on","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[37],"tags":[],"class_list":["post-52647","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-google-sheets-features"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.sheetgo.com\/fr\/wp-json\/wp\/v2\/posts\/52647","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sheetgo.com\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sheetgo.com\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sheetgo.com\/fr\/wp-json\/wp\/v2\/users\/49"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sheetgo.com\/fr\/wp-json\/wp\/v2\/comments?post=52647"}],"version-history":[{"count":0,"href":"https:\/\/www.sheetgo.com\/fr\/wp-json\/wp\/v2\/posts\/52647\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sheetgo.com\/fr\/wp-json\/wp\/v2\/media\/44470"}],"wp:attachment":[{"href":"https:\/\/www.sheetgo.com\/fr\/wp-json\/wp\/v2\/media?parent=52647"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sheetgo.com\/fr\/wp-json\/wp\/v2\/categories?post=52647"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sheetgo.com\/fr\/wp-json\/wp\/v2\/tags?post=52647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}