Author: By Raj

Part of our Apps Script API Integrations guides. Need this built for your team? Hire a Google Apps Script developer.

Estimated reading time: 10 minutes

Google Apps Script Slack Integration: Send Messages & Read Channels

Beyond incoming webhooks, Slack's Web API enables posting to channels, reading history, and uploading files from Apps Script with bot tokens stored securely.

Use chat.postMessage with channel ID, not display name, and include blocks for structured alerts. Scopes must match bot installation: chat:write, channels:read, etc.

Sheet row notifications often use webhooks (/blog/google-sheets-send-slack-notification); this guide covers full API access.

Bot tokens and workspace install

Create Slack app, install to workspace, copy xoxb- token to Script Properties. Rotate if token leaks in an accidental Logger.log.

Never expose token client-side in HtmlService, only server-side UrlFetchApp.

chat.postMessage patterns

POST https://slack.com/api/chat.postMessage with Authorization Bearer and JSON body channel, text, blocks.

Check ok field in JSON response; Slack returns 200 HTTP even on logical errors.

Reading channel history

conversations.history requires channel ID from conversations.list. Paginate with cursor for long backfills into Sheets audit tabs.

Respect retention policies, do not archive entire #random into compliance sheets without policy review.

files.upload from Sheets exports

Build CSV blob from getDataAsString or temporary Sheet export, multipart upload via advanced UrlFetchApp payload forms.

Large exports may need Drive link posted instead of direct upload.

Example code

function slackPostMessage(channelId, text) {
  const token = PropertiesService.getScriptProperties().getProperty('SLACK_BOT_TOKEN');
  const res = UrlFetchApp.fetch('https://slack.com/api/chat.postMessage', {
    method: 'post',
    contentType: 'application/json',
    headers: { Authorization: 'Bearer ' + token },
    payload: JSON.stringify({ channel: channelId, text: text }),
  });
  const data = JSON.parse(res.getContentText());
  if (!data.ok) throw new Error(data.error);
  return data.ts;
}
ApproachBest forTradeoff
Apps Script nativeGoogle Workspace-centric workflows6-min limit, quotas
Zapier / MakeNo-code, many connectorsPer-task cost, vendor lock-in
Python + CloudHeavy data / MLHosting cost, separate auth
API integration servicesProduction custom logicBuild cost, you own code

FAQ

Webhook or Web API for alerts?

Webhooks are simpler for one-way posts. Web API adds threads, emoji reactions, and channel discovery.

How do I find channel ID?

Open channel details in Slack UI or call conversations.list and match by name, IDs start with C.

Can Apps Script respond to slash commands?

Yes via doPost web app URL configured in Slack app settings, validate signing secret.

Why error channel_not_found?

Bot not invited to channel. /invite @YourBot in that channel before posting.

Rate limits?

Slack tier 2 methods allow bursts; batch messages and handle not_in_channel gracefully.

Need this done for you? I handle this as part of my consulting work, fixed-price quote within 24 hours.

Book a call with Raj →

Get the full Google Apps Script Slack Integration script template

I'll email you a production-ready, commented version you can deploy in 10 minutes.

Need help with this? I handle this as part of my Apps Script API Integrations service.

Shopify, Stripe, Slack, HubSpot, webhooks, and REST API connections.

See how it works →