• Stars
    star
    150
  • Rank 247,323 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 10 years ago
  • Updated almost 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Slack API Library for Google Apps Script

SlackApp

Slack API Library for Google Apps Script

Library Key

M3W5Ut3Q39AaIwLquryEPMwV62A3znfOO

API Document

https://script.google.com/macros/library/versions/d/M3W5Ut3Q39AaIwLquryEPMwV62A3znfOO

How to use.

Use Slack API Token.

  1. Import SlackApp library to your project. See Documents
  • Library Key M3W5Ut3Q39AaIwLquryEPMwV62A3znfOO
  1. Get a Slack API token from Slack.
  2. Write a code!
function myFunction(){

  //Get properties.
  var prop =  PropertiesService.getUserProperties().getProperties();

  //Create an instance.
  var slackApp = SlackApp.create(prop.slackToken); 
 
  //My first Message!
  slackApp.chatPostMessage(prop.slackChannel, "Hi Slack.", {
    username : "My First Bot",
    icon_emoji : ":+1:" 
  });
}

//If you want to create a replyable bot, you can use doGet method and [Outgoing WebHooks](https://exchaos.slack.com/services/new/outgoing-webhook) via Slack.

function doGet(e) {

  //Get properties.
  var prop =  PropertiesService.getScriptProperties().getProperties();
  if (!e) {

    //for Test
    e = {
      parameter : {
        token : prop.verifyToken,
        team_id : "T0001",
        channel_id : "C2147483705",
        channel_name : "test",
        timestamp : "1355517523.000005",
        user_id : "U2147483697",
        user_name : "Steve",
        text : "MyFirstBot: Hi",
        trigger_word : "MyFirstBot:"
      }
    };
  }

  if (prop.verifyToken != e.parameter.token) {
    throw new Error("invalid token.");
  }

  //Create an instance.
  var slackApp = SlackApp.create(prop.slackToken); 
 
  //My first Message!
  slackApp.chatPostMessage(e.parameter.channel_id, "Hi " + e.parameter.user_name, {
    username : "My First Bot",
    icon_emoji : ":+1:" 
  });

  return null;
}

Use OAuth2

TODO (Library is already supported, but not documented.)

More Repositories

1

SpreadsheetDB-For-Google_Apps_Script

Google Spreadsheet as a DB for Google Apps Script.
JavaScript
67
star
2

gas-manager

Google Apps Script Manager for nodejs
CoffeeScript
60
star
3

GasLoader

script loader for Google Apps Script
JavaScript
19
star
4

swift-cloud-endpoint-sample

Swift with Google Cloud Endpoint
Objective-C
11
star
5

backlog-android-client

backlogのAndroidクライアント androidannotations ormlite roboguice の組み合わせ
Java
10
star
6

ScriptManager

Script Manager of Google Apps Script / Apps Script Library
CoffeeScript
9
star
7

gmail-api-with-go

Go
5
star
8

gas-library-box-go

Go
4
star
9

gas-github

Github API for Google Apps Script
CoffeeScript
4
star
10

gas-library-manager

CoffeeScript
4
star
11

cloud-former-visualizer

Visualize a cloud former json file.
CSS
3
star
12

TypetalkApp

Typetalk API Client for Google Apps Script
JavaScript
2
star
13

gcp-ja-night-27-go-endpoints

Go
2
star
14

analog-digital-convert

AndroidThings A/D converting by MCP3008
Kotlin
1
star
15

twbootstrap

1
star
16

android-di-apt-orm

android-androidannotaions-ormlite-roboguilce-examples
Java
1
star
17

SampleUserDriver

AndroidThings user driver sample implementation
Kotlin
1
star
18

SampleServo

AndroidThings servo example
Kotlin
1
star
19

github-actions-playground

Playground for github actions
1
star
20

google-endpoint-v2

Sample project for google-endpoint-v2
1
star
21

devfest-2015-google-apps-script-handson

JavaScript
1
star
22

gcf-httpcallable-client-generator

A generator for Cloud Functions for firebase http callable client
1
star
23

gas-library-box-server

gas-library-box-server
Java
1
star
24

ZipUploader

Zip Attachment file on Google Sites by google apps script
1
star
25

gtug-girls-17-google-apps-script-handson

GTUG Girls #17(2014/06/19) Google Apps Script ハンズオン
Gosu
1
star