Send Slack Notifications

Slack's Incoming Webhooks let you POST messages to any Slack channel with a simple HTTP request. Combined with Apps Script, you can send deal alerts, daily summaries, and automated notifications directly from your Sales Tracker — no Slack SDK needed.

Setting Up a Slack Webhook

  1. Go to your Slack workspace → Apps → search for Incoming Webhooks
  2. Click Add to Slack, choose a channel, and copy the Webhook URL
  3. Store it in PropertiesService:
function storeSlackWebhook() { PropertiesService.getScriptProperties() .setProperty("SLACK_WEBHOOK_URL", "https://hooks.slack.com/services/YOUR/WEBHOOK/URL"); Logger.log("Webhook URL saved."); }

Sending a Simple Text Message

function sendSlackMessage(text) { var webhookUrl = PropertiesService.getScriptProperties().getProperty("SLACK_WEBHOOK_URL"); var payload = JSON.stringify({ text: text }); UrlFetchApp.fetch(webhookUrl, { method: "POST", contentType: "application/json", payload: payload }); Logger.log("Slack message sent."); } // Usage sendSlackMessage("📊 Daily sales report is ready. Check the tracker.");

Sending a Deal Closed Alert

Fire this from an onEdit or form submit trigger when a deal status changes to Closed:

function notifySlackDealClosed(customerName, product, amount, salesRep, region) { var webhookUrl = PropertiesService.getScriptProperties().getProperty("SLACK_WEBHOOK_URL"); var payload = JSON.stringify({ text: "🎉 *New Deal Closed!*", attachments: [ { color: "#36a64f", fields: [ { title: "Customer", value: customerName, short: true }, { title: "Product", value: product, short: true }, { title: "Amount", value: "$" + amount + "/mo", short: true }, { title: "Region", value: region, short: true }, { title: "Sales Rep", value: salesRep, short: true } ], footer: "Acme Corp Sales Tracker", ts: Math.floor(new Date().getTime() / 1000) } ] }); UrlFetchApp.fetch(webhookUrl, { method: "POST", contentType: "application/json", payload: payload }); } // Example: called from onEdit when status = Closed notifySlackDealClosed("Sarah Johnson", "Pro Plan", 299, "Alex Martinez", "North");

Sending a Daily Summary to Slack

function sendDailySlackDigest() { var sheet = SpreadsheetApp .getActiveSpreadsheet() .getSheetByName("Sales Tracker"); var data = sheet.getRange(2, 1, sheet.getLastRow() - 1, 8).getValues(); // Columns: [Customer Name, Email, Product, Amount, Region, Sales Rep, Status, Date] var closed = data.filter(function(r) { return r[6] === "Closed"; }); var inProgress = data.filter(function(r) { return r[6] === "In Progress"; }); var totalMRR = closed.reduce(function(sum, r) { return sum + r[3]; }, 0); var today = Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "MMMM dd, yyyy"); var webhookUrl = PropertiesService.getScriptProperties().getProperty("SLACK_WEBHOOK_URL"); var payload = JSON.stringify({ text: "*Daily Sales Digest – " + today + "*", attachments: [ { color: "#1a73e8", fields: [ { title: "Closed Deals", value: closed.length.toString(), short: true }, { title: "In Progress", value: inProgress.length.toString(), short: true }, { title: "Total MRR (Closed)", value: "$" + totalMRR + "/mo", short: true } ] } ] }); UrlFetchApp.fetch(webhookUrl, { method: "POST", contentType: "application/json", payload: payload }); Logger.log("Daily Slack digest sent."); }

With the sample data, Slack receives: Closed Deals: 2, In Progress: 1, Total MRR: $398/mo.

Tagging a Person in a Slack Message

To mention a user, you need their Slack Member ID (found in their profile):

function mentionSalesRepInSlack(slackMemberId, customerName) { var webhookUrl = PropertiesService.getScriptProperties().getProperty("SLACK_WEBHOOK_URL"); var payload = JSON.stringify({ text: "<@" + slackMemberId + "> you have a new follow-up task for *" + customerName + "*. Check the Sales Tracker." }); UrlFetchApp.fetch(webhookUrl, { method: "POST", contentType: "application/json", payload: payload }); }