
Slack Appってどうやって作るんだろう?
Slack App(以後Slackアプリと呼ぶ)を使えば、GmailをSlackに通知できたり、チャンネルを自動で作ったりできて便利ですよね。
このページでは、Slackアプリの作り方の手順とUser TokenとBot Tokenの違いを解説します。
Slackアプリを作る手順
[Create New App]をクリックする


Slack API: Applicationsのページの右上にある[Create New App]をクリックします。
[From scratch]をクリックする


[From scratch]をクリックします。
アプリ名を入力し、ワークスペースを選ぶ


以下の2つを設定します。
App Name | これから作るアプリの名前 |
---|---|
Pick a workspace to develop your app in: | アプリを入れるSlackのワークスペース |
アプリ名はあとで変更できます。
▼入力が終わったら[Create App]をクリックしましょう。


▼アプリが作成されたら、以下のような画面が開きます。


[App Home]→App Display Nameの[Edit]をクリックする


左側のメニューの中から[App Home]をクリックします。
[App Home]の中のApp Display Name欄にある[Edit]をクリックしましょう。
[Display Name]と[Username]を入力し[Add]をクリックする


[Display Name]と[Username]を入力します。
設定事項 | 内容 | 命名規則 |
---|---|---|
Display Name | Slack上でのアプリの表示名 | 80字以内 日本語OK アポストロフィーとピリオドは使える |
Username | アプリに割り振られているユーザー名です。 適当で問題ないですが、アプリの内容を表したものにしたほうがわかりやすいと思います。 | 21字以内で以下のものを含められる。 半角英字(小文字) 半角数字 ピリオド ハイフン アンダースコア |
▼入力が終わったら[Add]をクリックしましょう。


▼設定が終われば「Bot user added!」と表示されます。


[OAuth & Permissions]をクリックする
▼左側のメニューから[OAuth & Permissions]をクリックします。


[Add an OAuth Scope]をクリックする
Scopes欄で、目的にあったTokenのScopeを設定します。
Tokenは2つあり、どちらを使うかは目的によって異なります。
Bot Token | ボットに実行させたい場合 |
---|---|
User Token | ユーザー自身が実行する場合 |
▼実際に、Bot TokenとUser Tokenをそれぞれ使って、Slackに文字を投稿してみました。


- Bot Tokenの場合:Slackアプリが投稿者になる
- User Tokenの場合:ユーザーが投稿者になる
今回はBot Tokenを使うと仮定して解説を進めます。
▼Bot Token Scopes欄の[Add an OAuth Scope]をクリックします。


必要なScopeを選択する
必要なScopeを選びましょう。やりたいことに応じて、必要なScopeが異なります。
どのScopeが必要かは、Google検索もしくは生成AIに質問すると良いと思います。
(参考:Slack API「Permission scopes」)


▼Scopeが追加されるとこんな感じになります。


[Install to Workspace]をクリックする
▼同じページにある[OAuth Tokens for Your Workspace]欄の[Install to Workspace]をクリックします。


[許可する]をクリックする
▼[許可する]をクリックして、ワークスペースにアプリをインストールします。


画面上部に「Success」と表示されれば、インストール完了です。
このとき表示される「Bot User OAuth Token」は、GASのコーディングで使います。


さいごに
今回の手順で、Slackアプリがつくれます。
手順の中でうまくいかないことがあれば、他の読者の方々の参考になるので、このページのコメント欄に投稿いただけると大変ありがたく思います。
コメント