0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Slack Applicationの作成と説明、ついでにIncoming Web hookをためす

Posted at

Slack Applicationの作成と説明、ついでにIncoming Web hookをためす

Table of Contents

  1. Slack とは
  2. Slack の代表的な機能
  3. Slack Application の作成
  4. Incoming Webhooksを利用したアプリケーションの設定

1. Slack とは

slack-app-index.png

メールに代わるビジネスコラボレーション「Slack」

と書かれているようにグループのチャットツールです。
類似サービスにchatworkMicrosoft Teamsがあります。
多分qiitaを見てる人なら誰でもしってそう。。。

2. Slackの代表的な機能

Slackの代表的な機能としては、6つです

features.png

ざっくり書くと

name description
Incoming Webhooks Slackにメッセージを投稿する機能です。
Intractive Components Slackのメッセージにダイアログやボタン、選択メニューなどのコンポーネントを追加し、ユーザーにインタラクティブな体験を提供する機能です。
Slash Commands Slack内でユーザーがコマンドを入力してアプリのアクションを実行できるようにする機能です。/のショートカットを利用します
Event Subscription Slackで行われたアクションをフックして何かをする機能です。
Bots ユーザーがチャネルと通信を通じてアプリを操作できるようにします
Permission Slack APIと対話できるようにアクセス許可を構成する

です。Slack内である程度のフックは可能なので覚えて置くと色々楽に仕事をこなせるアプリケーションを作成できます。

3. Slack Application の作成

slackのアプリケーションの作成(非公開)は、

  1. Slack Apiにいき Your Apps をクリック
  2. Slack Api Application にいき Create An App を押下
  3. 表示されたdialogに アプリケーションの名前 と 設定するWork Spaceを選択し Create App を押下

でアプリケーションの雛形は作成されます(ちなみに選択されたWork Spaceにのみアプリケーションが有効化されています)。

以下は画像つきで作成方法を設定していきます。

1. Slack Apiにいき Your Apps をクリック

slack-app.png

2. Slack Api Application にいき Create An App を押下

slack-app.png

3. 表示されたdialogに アプリケーションの名前 と 設定するWork Spaceを選択し Create App を押下

Slack API  Applications   Slack (1).png

さらっと作成されます。www

slack-app.png

4. Incoming Webhooksを利用したアプリケーションの設定

Incomingを利用するまでのステップは、

  1. Slack Applicationにいき、Incoming Webhook URLのCardをクリック
  2. ToggleをOnに変更する
  3. Add New Webhook to Workspaceをおして有効化します
  4. Incoming Web Hookを利用するチャンネルを選択してAllowをクリック

以上でweb hook urlの利用は開始することができます。

1. Slack Applicationにいき、Incoming Webhook URLのCardをクリック

select-application.png

2. ToggleをOnに変更する

actiavte-incoming-webhook.png

3. Add New Webhook to Workspaceをおして有効化します

add-new-webhook-url.png

4. Incoming Web Hookを利用するチャンネルを選択してAllowをクリック

sample-application is requesting permission to access the self Slack workspace   self Slack.png

以上で完了です。4つのステップが完了すると下のようにURLが発行されます。

success-incming-webhook.png

次にIncoming Web Hookを叩いてメッセージを送信します。

作成されたcurlコマンドをコピーして、ターミナルにはってためしてみます

68747470733a2f2f71696974612d696d6167652d73746f72652e73332e61702d6e6f727468656173742d312e616d617a6f6e6177732e636f6d2f302f3134343534332f31663730386231392d316532392d303838372d656137352d3538303731633163376136332e706e67  1496×1394 .png

$ curl -X POST -H 'Content-type: application/json' --data '{"text":"Hello, World!"}' https://hooks.slack.com/services/XXX/YYY/ZZZ

こんな感じで設定したwork spaceにメッセージが作成されます。

スクリーンショット 2020-01-30 2.47.29.png
0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?