本指南介绍如何创建链接以启动带有预填充信息的新的私信,包括最佳实践。
所需用户级别:所有用户
Discourse 允许您通过 URL 参数撰写带有预填充信息的新私信。这可以节省时间并确保常见消息的一致性。
URL 的结构
要创建新的预填充消息,请按如下格式设置您的 URL:
https://discourse.example.com/new-message?username=techapj&title=message%20title&body=message%20body
分解后,URL 参数包括:
- 基础 URL:
https://discourse.example.com/new-message - 用户名:
username=techapj - 标题:
title=message%20title - 正文:
body=message%20body ?URL 运算符,用于添加不同的选项
您可以在 try.discourse.org 上尝试此操作:
https://try.discourse.org/new-message?username=rudy&title=message%20title&body=message%20body
您也可以通过 URL 为群组撰写预填充消息:
https://meta.discourse.org/new-message?groupname=team&title=topic%20title&body=topic%20body
注意上面 URL 中的 groupname 参数,这意味着您想为群组创建新的预填充消息(与用于为用户撰写消息的 username 相对应)。您也可以使用 group_name 作为 groupname 的替代项。
标签
您可以通过添加 tags 参数来预填充私信中的标签:
https://discourse.example.com/new-message?username=techapj&title=Bug%20Report&body=Details&tags=tag1,tag2
这要求 pm_tags_allowed_for_groups 站点设置包含用户所属的群组。如果未为用户启用 PM 标记,则 tags 参数将被静默忽略。
最佳实践
-
您可以通过逗号分隔用户名来向多个用户发送消息。例如:
https://meta.discourse.org/new-message?username=foo,bar -
您不需要填写所有参数。例如,以下任何一个都有效:
https://meta.discourse.org/new-message https://meta.discourse.org/new-message?username= https://meta.discourse.org/new-message?title=foo&body=bar https://meta.discourse.org/new-message?groupname= -
您可以使用
%0A和%0A%0D代码添加换行符,为消息正文提供一些结构:https://yoursite.discourse.org/new-message?username=test_user&title=Bug%20Report&body=Please%20include%20all%20relevant%20details.%0A%0DCPU:%0AMemory:%0A%0DDescribe%20Issue: -
如果您有 DiscourseConnect (SSO),您可以链接到
example.com/session/sso,然后设置return_path以创建私信。如果用户已登录,他们将自动重定向到return_path提供的 URL。如果他们未登录,他们将被带到 DiscourseConnect 登录页面,然后重定向到return_pathURL。return_path需要进行 URL 编码。href="http://localhost:3000/session/sso?return_path=http%3A%2F%2Flocalhost%3A3000%2Fnew-message%3Fusername%3Dscossar%26title%3DInformation+requested+about+gentle+yoga+classes">
当前不支持的功能
- 使用预填充 URL 向多个群组撰写消息。
- 使用预填充 URL 在用户摘要页面上打开撰写器。
- 使用电子邮件而不是用户名来预填充私信。