Small Business Stack

Send New Google Form Responses to a Slack Channel

How do I send each new Google Form response to a Slack channel automatically?

Link the form to a response spreadsheet, open Extensions > Apps Script from that spreadsheet, and paste the script below. Store the Slack incoming webhook URL in Script Properties, then run the installer once. Each new submission is posted to the webhook's channel as question and answer pairs, with blank answers skipped.

What you need

  • A Google Form linked to a response spreadsheet
  • A Slack incoming webhook for the destination channel
  • Edit access to the spreadsheet and its bound Apps Script project
  • Permission to let the script read the spreadsheet and connect to an external service

How this script runs

  1. Someone submits the Google Form
  2. The response row lands in the linked spreadsheet
  3. The form-submit trigger runs the script
  4. It pairs each non-blank answer with its column header
  5. It posts one message to the Slack webhook and checks the reply

To get every new Google Form response into Slack, attach a short Apps Script to the form’s response spreadsheet and give it an installable form-submit trigger. Each time someone submits the form, the trigger hands the script the new row. The script pairs each answer with its question, drops the blank ones and posts one message to a Slack incoming webhook. The webhook decides the channel. The URL is kept in Script Properties, not in the code.

Which form answers end up in the Slack message?

Every non-blank answer in the new response row is posted, in the same order as the spreadsheet columns, with the column header as the label. Blank answers are left out, so optional questions nobody filled in do not clutter the channel. The Timestamp column that Google adds to the response sheet moves into the message title.

Take a contact form for a small catering business with these response columns:

Timestamp Name Email Event date Guests Notes
11/16/2026 10:42:05 Riley Placeholder riley@example.com 12/04/2026 40 Need two vegan options & a nut-free dessert
11/16/2026 11:15:30 Morgan Sample morgan@example.com 12

These are sample rows. The first one posts to Slack like this, assuming the spreadsheet is named Catering enquiries (Responses):

New response: Catering enquiries (Responses) (11/16/2026 10:42:05)

*Name*
Riley Placeholder

*Email*
riley@example.com

*Event date*
12/04/2026

*Guests*
40

*Notes*
Need two vegan options & a <b>nut-free</b> dessert

That is the text the script sends. Slack turns the escaped characters back into &, < and > when it shows the message, so readers see the note as typed. The second row posts only Name, Email and Guests, because Event date and Notes are blank.

How the script treats each kind of value:

Value in the response row What the script does
Blank or only spaces Skipped
Timestamp column Moved into the message title
Text containing &, < or > Escaped as &amp;, &lt;, &gt;
Answer longer than 1,000 characters Cut to 1,000 characters ending in ...
Line breaks inside an answer Kept
Every answer blank Nothing is posted; the execution log says so

Escaping matters here. Slack’s formatting guide reserves &, < and > for its own markup, such as links and mentions. Without escaping, a form answer containing <!channel> could notify the whole channel. With escaping, it shows up as plain text.

How do you create the webhook and store it in Script Properties?

Slack’s incoming webhook documentation walks through creating a Slack app, turning on Incoming Webhooks, clicking Add New Webhook to Workspace and choosing a channel. To use a private channel, you must be in that channel first. Your workspace may require an admin to approve the app.

The resulting URL starts with https://hooks.slack.com/services/ and contains a secret. Slack’s docs say not to share it, and that leaked secrets are revoked. A webhook posts only to the channel picked during setup; you cannot change the channel from the script.

Then set up the script:

  1. In the Google Form, link it to a spreadsheet if it is not linked already. Open that spreadsheet.
  2. Select Extensions > Apps Script. This creates a script project bound to the spreadsheet.
  3. Open Project Settings, find Script Properties and add SLACK_WEBHOOK_URL with the full webhook URL as its value, without quotes.
  4. If more than one form sends responses to this spreadsheet, also add RESPONSE_SHEET_NAME with the exact tab name, for example Form Responses 1. The script then ignores responses that land in other tabs.
  5. Replace the starter code in the editor with the script in the next section and save.

Anyone who can edit the script project can read Script Properties. Keep the editor list short, and replace the webhook if the URL is ever exposed.

The Apps Script that posts each response

The script has three functions you run or trigger: postFormResponseToSlack does the work, testWithLastRow replays the newest row by hand, and installFormSubmitTrigger creates the trigger.

const HANDLER = 'postFormResponseToSlack';
const MAX_ANSWER_LENGTH = 1000;
const MAX_MESSAGE_LENGTH = 35000;

function postFormResponseToSlack(e) {
  if (!e || !e.range || !e.values) {
    throw new Error('Run this from the form-submit trigger. Use testWithLastRow to try it by hand.');
  }

  const props = PropertiesService.getScriptProperties();
  const sheet = e.range.getSheet();

  const onlySheet = (props.getProperty('RESPONSE_SHEET_NAME') || '').trim();
  if (onlySheet && sheet.getName() !== onlySheet) {
    console.log('Response landed in ' + sheet.getName() + '; skipped.');
    return;
  }

  const webhookUrl = (props.getProperty('SLACK_WEBHOOK_URL') || '').trim();
  if (!webhookUrl) {
    throw new Error('Set SLACK_WEBHOOK_URL in Script Properties.');
  }

  const firstColumn = e.range.getColumn();
  const headers = sheet
    .getRange(1, firstColumn, 1, e.values.length)
    .getDisplayValues()[0];

  let timestamp = '';
  const lines = [];

  e.values.forEach(function (value, index) {
    const question = String(headers[index] || 'Column ' + (firstColumn + index)).trim();
    const answer = String(value === null || value === undefined ? '' : value).trim();

    if (answer === '') {
      return; // skip blank answers
    }
    if (question === 'Timestamp') {
      timestamp = answer;
      return;
    }

    lines.push('*' + escapeSlackText(question) + '*\n' +
      escapeSlackText(shorten(answer, MAX_ANSWER_LENGTH)));
  });

  if (lines.length === 0) {
    console.log('Every answer was blank; no Slack message sent.');
    return;
  }

  const title = 'New response: ' + escapeSlackText(sheet.getParent().getName()) +
    (timestamp ? ' (' + escapeSlackText(timestamp) + ')' : '');
  const text = title + '\n\n' + lines.join('\n\n');

  if (text.length > MAX_MESSAGE_LENGTH) {
    throw new Error('Message is over ' + MAX_MESSAGE_LENGTH + ' characters; lower MAX_ANSWER_LENGTH.');
  }

  const response = UrlFetchApp.fetch(webhookUrl, {
    method: 'post',
    contentType: 'application/json',
    payload: JSON.stringify({
      text: text,
      unfurl_links: false,
      unfurl_media: false
    }),
    muteHttpExceptions: true,
    followRedirects: false
  });

  const code = response.getResponseCode();
  const body = response.getContentText().trim();
  if (code !== 200 || body !== 'ok') {
    throw new Error('Slack rejected the message. HTTP ' + code + ': ' + body.slice(0, 200));
  }

  console.log('Posted response from row ' + e.range.getRow() + ' to Slack.');
}

function escapeSlackText(value) {
  return String(value)
    .replace(/\r\n?/g, '\n')
    .replace(/&/g, '&amp;')
    .replace(/</g, '&lt;')
    .replace(/>/g, '&gt;');
}

function shorten(value, max) {
  return value.length > max ? value.slice(0, max - 3) + '...' : value;
}

function testWithLastRow() {
  const props = PropertiesService.getScriptProperties();
  const name = (props.getProperty('RESPONSE_SHEET_NAME') || '').trim();
  const spreadsheet = SpreadsheetApp.getActive();
  const sheet = name ? spreadsheet.getSheetByName(name) : spreadsheet.getSheets()[0];

  if (!sheet || sheet.getLastRow() < 2) {
    throw new Error('No response rows found to test with.');
  }

  const range = sheet.getRange(sheet.getLastRow(), 1, 1, sheet.getLastColumn());
  postFormResponseToSlack({ range: range, values: range.getDisplayValues()[0] });
}

function installFormSubmitTrigger() {
  const spreadsheet = SpreadsheetApp.getActive();

  ScriptApp.getProjectTriggers()
    .filter(function (trigger) { return trigger.getHandlerFunction() === HANDLER; })
    .forEach(function (trigger) { ScriptApp.deleteTrigger(trigger); });

  ScriptApp.newTrigger(HANDLER)
    .forSpreadsheet(spreadsheet)
    .onFormSubmit()
    .create();

  console.log('Installed one form-submit trigger for ' + HANDLER + '.');
}

The script reads two fields from the event. Google’s event objects reference lists, for the spreadsheet form-submit trigger, values (an array in the same order as the spreadsheet columns) and range (the cells for the new response). The script reads the header row above range to label each value. The same event also carries namedValues, an object keyed by question title. The script does not use it because column order is easier to rely on with an array, and two questions with the same title would share one key in an object.

Before posting, it checks that the webhook URL exists. After posting, it checks Slack’s reply. Slack’s webhook docs say a successful post usually returns HTTP 200 with the plain text ok. Anything else makes the script throw an error, which shows up as a failed execution instead of disappearing.

If you bind the script to the Form instead of the spreadsheet, the event is different: it has response, a FormResponse object, and source, the Form. This script expects the spreadsheet version.

Installing the form-submit trigger on the response spreadsheet

The trigger is installed by running a function once, not by naming a function onFormSubmit. The installer uses ScriptApp.newTrigger(...).forSpreadsheet(...).onFormSubmit().create(), the pattern shown in Google’s SpreadsheetTriggerBuilder reference.

  1. Select installFormSubmitTrigger in the editor’s function menu and click Run.
  2. Approve the permissions prompt, signed in as the account that should own the trigger.
  3. Open the Triggers page in the Apps Script sidebar and confirm there is exactly one trigger for postFormResponseToSlack.
  4. Submit a test response to the form, using a name like Avery Example, and check the channel.
  5. To resend the newest row without submitting the form, run testWithLastRow. It sends a real message.

Google’s installable triggers guide says installable triggers always run under the account of the person who created them. It also says one account cannot see triggers installed from a second account. Have one person install the trigger. If two people each run the installer, the form posts twice, and neither can remove the other’s trigger from their own view.

What to check when a response does not reach Slack

Start in the Apps Script Executions page. Each form submission should create one run of postFormResponseToSlack.

What you see Likely cause and fix
No execution after a submission Trigger missing or installed on another spreadsheet. Run the installer again from the linked spreadsheet.
Run this from the form-submit trigger You clicked Run on the main function. Use testWithLastRow instead.
Set SLACK_WEBHOOK_URL The property is missing or misspelled. Check the name in Script Properties.
Slack rejected the message. HTTP 404 or 403 The webhook was removed, revoked or its app was uninstalled. Create a new webhook and update the property.
Response landed in ... skipped RESPONSE_SHEET_NAME does not match the tab. Copy the tab name exactly.
Each response posts twice Two triggers exist, often from two accounts. Remove the extra one while signed in as its owner.

If the title shows no timestamp, check the first header. The script looks for the exact text Timestamp. A spreadsheet in another language may use a different header, so change that string in the code to match.

Cases where a webhook post is the wrong tool

Posting every response suits forms that get a handful of submissions a day and need a quick human look: enquiries, equipment requests, incident reports. It fits less well in these cases.

Before you share the form, clean up the response columns you plan to post. Short, clear question titles make short, clear Slack labels. For other connections between everyday tools, see the small business stack guides.

Sources

Free, from Producfy

Get the next guide before you need it

One email when a new guide or tool goes up: working formulas, queries and scripts for spreadsheets, SQL and the CRM and billing exports that end up in them. At most one a week.

Esc