Calendar icons created by Maxim Basinski Premium - Flaticon
以下のURLへ移動し、 「Create New App」を選択
OAuth & Permissons > Scopes > Bot Token Scopes
以下を設定
- chat:write(messageを送るため)
- chat:write.customize(リッチテキスト、bot名を変更するため)
- chat:write(DMへ送る場合に追加)
設定後、InstallAppへ移動 Install to Workspaceを選択
以上で、SlackAppが作成されます。
作成後、 Bot User OAuth Tokenが発行されるので、どこかに保存しておいてください。
git clone https://github.com/Hina1008/google-calendar-for-slack
1.vscodeの場合 F1キー > Remote-Containers: Rebuild and Reopen in Container
2.コマンドの場合
docker-compose exec gas bash
以下のコマンドを入力して、Google Accountと連携する。
node@cxxxxxxx:/home/gas$ clasp login
以下のページが開かれるので、「許可」を選択する。
以下のコマンドを入力して、 Google Apps Scriptを作成する。
node@cxxxxxxx:/home/gas$ clasp create --title [GAS_NAME] --type standalone
- title: プロジェクト名
- type: プロジェクトの種類
- デフォルトは、standalone(←使用)
- spreadsheet, Document等があり、指定したものにアタッチしたプロジェクトが作成される。
Google Accountと連携時に作成された.clasp.json
を修正する。
デフォルト
{
"scriptId":"xxxxxx999999",
"rootDir":"/home/gas"
}
rootDirの値を "/home/gas"
から"/home/gas/src
に修正。
{
"scriptId":"xxxxxx999999",
"rootDir":"/home/gas/src"
}
以下のコマンドを使って、pushする。
node@cxxxxxxx:/home/gas$ clasp push
Google Driveから移動 or clasp open
コマンドを使用して、Google Apps Scriptを開く
mainファイルの setProperties
関数内の変数に値を代入する。
// 隠したい変数を代入
function setProperties(){
var scriptProperties = PropertiesService.getScriptProperties();
scriptProperties.setProperties({
"SLACK_TOKEN": "xoxb-",
"SLACK_CHANNEL": "CHANNEL_ID",
"SCHEDULE_ID": "SCHEDULE_ID",
"APP_NAME": "スケジュール管理"
})
}
Slack Appを作成した際の Token ID
投稿したいSLACKチャンネルのID
読み込みたいカレンダーのID
https://calendar.google.com/calendar/ へ移動
設定 > マイカレンダーの設定 > 使用したいカレンダー選択 > カレンダーの統合
アプリの名前(投稿者名) 下記画像の「スケジュール管理」部分
設定後、 setProperties
関数を実行する。
トリガー > トリガーの設定
以上の設定後、保存を押すことで使用できる。
それでは、よきSlackライフを✋