TL;DR;
- Slack API経由でのメンション方法が変わる
- 2017/9/11に変更を始めており、2018/9/12には完全に移行される
- 新形式は
<@user_id> - 旧形式の
<@username>は使えなくなる - メッセージ中の
@usernameがメンションになるlink_namesオプションも廃止される
変更内容
仕様変更のうち、関係の深い内容をいくつかピックアップします。
Mentioning users in messages より
メッセージ中のメンションの記法についてです。
The user mentioning syntax <@W123|bronte> is now deprecated and will eventually be removed.
<@W123|bronte> 記法は廃止予定であり、そのうち消すよ。
Use the simpler user ID-only form <@W123> instead
代わりに <@user_id> を使ってね。
Using link_names when posting messages is also deprecated. We'll continue matching @mentions with usernames, but for now please mention users with the <@W123> user ID format instead.
link_names オプションは廃止予定。今のところ @username も取り扱うけど、今後は <@user_id> 形式を使ってね。
The undocumented approach to mentioning users via the API — <@username> — will no longer function
<@username> っていう隠しコマンドは今後使えなくなるよ(…あれ非公式のものだったのか)。
補足
@channel, @here, @everyone は <!channel>, <!here>, <!everyone> が対応している。
https://api.slack.com/docs/message-formatting#linking_to_urls
対応方法
-
user_idを取得する- 個別: Slackクライアントのプロフィールから取得(member IDという名前になっている)
- @ryo-yamaoka さんの記事: SlackのIncoming Webhooksでメンションを飛ばす方法にキャプチャ付きの解説があります
- チーム内一括: API users.listで取得
- 取得したJSON中の
idがこれに該当する
- 取得したJSON中の
- 個別: Slackクライアントのプロフィールから取得(member IDという名前になっている)
- APIからのメンションをすべて新形式の
<@user_id>に変更する