A Slack Incoming Webhook client for Google Apps Script.
This Libray is published as Library-ID 1ZIccV8fPCz2UKpNfRxX6Xb-IkusswcAtDXeBbtM3k8IB-qvPToCfPcfX
.
- Create or Open your GAS project.
- Cliock Add Library link, then Library daialog is opened.
- Input
1ZIccV8fPCz2UKpNfRxX6Xb-IkusswcAtDXeBbtM3k8IB-qvPToCfPcfX
to Script ID, and click Search button. - Select library version.
- Change ID of this library to
Slack
- Click Add button.
You can use this library in your google apps script, like the following code.
function sendMessage() {
var url = 'https://hooks.slack.com/services/your/incoming/webhooks/url'
var webhook = new Slack.IncomingWebhook(url);
webhook.send('Hello World!')
}
function sendMessageWithOpts() {
const message: IncomingWebhookSendArguments = {
channel: 'general',
icon_emoji: ':ok:',
username: 'Webhook for GAS',
text: 'send Message With Opts',
};
const webhook = new Slack.IncomingWebhook(url);
webhook.send(message);
}
You can use other message options of Slack Incoming Webhook API. See Incoming Webhooks | Slack
- Node.js
- Yarn
- Clone this ripository.
- Install dependencies by
yarn install
- Create your GAS project, push code, and open web editor.
$ yarn clasp:create $ yarn clasp:push $ yarn clasp:open