如何在 slack 中添加@提及以响应斜线命令
How to add @ mention in response to slash commands in slack
如何使松弛解析 @someone
提及作为指向用户的链接而不是纯文本。我一直在阅读有关消息格式的松散文档,但仍未弄明白。这是我现在得到的示例:
{
"text": "*username:* @alexis",
"response_type": "ephemeral"
}
要正确 "clickable" 提及,您需要传递唯一的用户 ID 而不是明文名称。
用户 ID 的格式为:U024BE7LH
提及将如下所示:<@U024BE7LH>
执行斜杠命令的用户的用户 ID 将在 slack 发送到您的端点的有效负载中。您还可以通过调用 users.list 方法来查找用户 ID,这将使您可以访问团队中所有用户的用户 ID。
更多信息here
在 <>
引号内传递用户名,像这样 <@someone>
样本
{
"text": "*username:* <@alexis>",
"response_type": "ephemeral"
}
此外,如果您想通知频道而不是用户,则使用 !channel
、!group
、!here
或 !everyone
而不是 @username
例如
{
"text": "*username:* <!channel>",
"response_type": "ephemeral"
}
slack_web_client.chat_postMessage(
channel="channel_name",
text="Hi! <@User_id>"
)
将用户 ID 放在 <> 引号中并确保您的 app/bot 具有 命令 的范围。
如何使松弛解析 @someone
提及作为指向用户的链接而不是纯文本。我一直在阅读有关消息格式的松散文档,但仍未弄明白。这是我现在得到的示例:
{
"text": "*username:* @alexis",
"response_type": "ephemeral"
}
要正确 "clickable" 提及,您需要传递唯一的用户 ID 而不是明文名称。
用户 ID 的格式为:U024BE7LH
提及将如下所示:<@U024BE7LH>
执行斜杠命令的用户的用户 ID 将在 slack 发送到您的端点的有效负载中。您还可以通过调用 users.list 方法来查找用户 ID,这将使您可以访问团队中所有用户的用户 ID。
更多信息here
在 <>
引号内传递用户名,像这样 <@someone>
样本
{
"text": "*username:* <@alexis>",
"response_type": "ephemeral"
}
此外,如果您想通知频道而不是用户,则使用 !channel
、!group
、!here
或 !everyone
而不是 @username
例如
{
"text": "*username:* <!channel>",
"response_type": "ephemeral"
}
slack_web_client.chat_postMessage(
channel="channel_name",
text="Hi! <@User_id>"
)
将用户 ID 放在 <> 引号中并确保您的 app/bot 具有 命令 的范围。