Slack ボット(App)をメンションで反応させる方法
GASプロジェクトの作成と設定
手順1
Google Drive 内の空いているスペースで右クリックし、「その他」から「Google Apps Script」を押し、GASプロジェクトを作成する。
Slack のメッセージのボタンが押された際の処理を記述するGASプロジェクトは必ず Google Drive 内に単体で存在しなければならない。

手順2
作成したプロジェクト開いた後、左の「ライブラリ」の「+」を押し、「ライブラリの追加」内の「スクリプトID」に「1on93YOYfSmV92R5q59NpKmsyWIQD8qnoLYk-gkQBI92C58SPyA2x1-bq」と入力し、「検索」を押す。

手順3
「バージョン」を最も大きい数字(今回は22)に設定して、右下の「追加」を押す。

手順4
適切なコードを記述し、上の「実行」を押す。

手順5
下の画像を参考にして権限を承認する。





手順6
右上の「デプロイ」から「新しいデプロイ」を押す。

手順7
「種類の選択>歯車マーク」から「ウェブアプリ」を押す。

手順8
「アクセスできるユーザー」を「全員」に設定し、右下の「デプロイ」を押す。

手順9
「新しいデプロイ>ウェブアプリ>URL」の「コピー」を押して、URLをコピーした後、右下の「完了」を押す。

ボット(App)の設定
手順10
Slack API に行き、対象のボットを選択する。

まだ Slack ボットを作成していない場合は下の記事を参考にボットを作成する。
手順11
「Features>OAuth & Permissions>Scopes>Bot Token Scopes」で「app_mentions:read」を追加する。

手順12
左から「Event Subscriptions」に行き、右上の「Enable Events」を「On」に切り替え、「手順9」でコピーしたURLを「Request URL」にペーストする。

手順13
「Features>Event Subscriptions>Subscribe to bot events」で「app_mention」を追加し、右下の「Save Changes」を押す。

手順14
「Settings>Install App>OAuth Tokens for Your Workspace」で「Reinstall to Workspace」を押す。

手順15
右下の「許可する」を押す。

デバッグ
手順16
Slack でボットをメンションした際に処理が走る事を確認する。
