3
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のUser GroupにHubot経由で全体通知する

3
Posted at

やりたいこと

Hubotから @usergroup でユーザグループに通知を飛ばしたい。

ユーザグループとは?

特定のチャンネルの全員ではなく、特定の人に通知をしたい場合に使える機能。
グループに参加すると特定のチャンネルにjoinさせることもできる。

ユーザグループの利用シーン

  • チャンネルはトピックごとに参加者がいる(例えば開発チャンネルには開発に関わる全ての人がいるはず)。そのうちの一部(例えばインフラエンジニア)だけに通知したいとか。
  • 新入社員が1000個あるチャンネルから必須チャンネル10個とかを登録してもらうとかめんどくさい。グループにjoinしてもらうと一括で必須チャンネルに登録できる。

詳細は公式の説明をお読み下さい

やり方

以下のドキュメントに方法が書いてある。
Message Formatting | Slack

制限

For paid teams

とあるように、有料で使っていないとできない。

グループIDを取得する

usergroups.list APIを使って通知したいグループのIDを取得する。
ドキュメント:usergroups.list method | Slack

取得結果が以下だったと仮定する

  • "id": "S0*******"
  • "team_id": "T0*******"
  • "is_usergroup": true
  • "is_subteam": true
  • "handle": "mygroup"

指定のフォーマットで通知先を書く

<!subteam^ID|handle>の項目を埋めていく。

"<!subteam^S0*******|mygroup>"

hubot経由で上の文字列をSlackにポストすると、@mygroupとしてグループに通知される。

3
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
3
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?