メインコンテンツにスキップ

gas-slack-incoming-webhook

A Slack Incoming Webhook client for Google Apps Script.

AI Summary

Slack Incoming Webhook for GAS

Slack Incoming Webhook client for GAS.

Target Users

GAS developers wanting to send notifications to Slack channels.

Problems Solved

Slack Node.js Incoming Webhook SDK unusable directly in GAS.

Script ID

  1. In GAS Editor: Click "Libraries +" → Paste into "Script ID" field → Click "Look up"
  2. "gas-slack-incoming-webhook" will appear in the search results
  3. Select the latest version (highest number) from "Version" dropdown
  4. Click "Add"

Tags

Main Features
1
Easy Install

Add Library ID to GAS project and set identifier to 'Slack'.

2
Simple API

Instantiate with URL and send messages via send() method.

3
Options Support

Send with options like channel, icon_emoji, username.

Examples

Main Functions

FunctionDescription
new Slack.IncomingWebhook(url)Create webhook instance from URL
webhook.send(text)Send simple text message
webhook.send(options)Send message with options

Examples

Simple Text Message
/**
 * シンプルテキスト送信
 * ・Webhook URL設定: var url = 'https://hooks.slack.com/services/your/incoming/webhooks/url'
 * ・インスタンス作成: new Slack.IncomingWebhook(url)
 * ・テキスト送信: webhook.send('Hello World!')
 */
function sendMessage() {
  var url = 'https://hooks.slack.com/services/your/incoming/webhooks/url'
  var webhook = new Slack.IncomingWebhook(url);
  webhook.send('Hello World!')
}

Message with Options
/**
 * オプション付き送信
 * ・オプションオブジェクト定義: const message = { channel: 'general', icon_emoji: ':ok:', ... }
 * ・インスタンス作成: new Slack.IncomingWebhook(url)
 * ・オプション送信: webhook.send(message)
 */
function sendMessageWithOpts() {
  const message = {
    channel: 'general',
    icon_emoji: ':ok:',
    username: 'Webhook for GAS',
    text: 'send Message With Opts',
  };
  const url = 'https://hooks.slack.com/services/your/incoming/webhooks/url';
  const webhook = new Slack.IncomingWebhook(url);
  webhook.send(message);
}

Sample Code

Post a Sample

No sample codes for this library yet

Be the first to post a sample!

Post a Sample