创建预填充个人消息链接

:bookmark: This guide describes how to create a link to start a new personal message with pre-filled information, including best practices.

:person_raising_hand: Required user level: All users

Discourse allows you to compose a new personal message with pre-filled information via URL parameters. This can save time and ensure consistency for common messages.

Structure of the URL

To create a new pre-filled message, format your URL like this:

https://discourse.example.com/new-message?username=techapj&title=message%20title&body=message%20body

When broken down, the URL parameters include:

  • Base URL: https://discourse.example.com/new-message
  • Username: username=techapj
  • Title: title=message%20title
  • Body: body=message%20body
  • The ? URL operator to add the different options

You can try this on try.discourse.org:

https://try.discourse.org/new-message?username=rudy&title=message%20title&body=message%20body

You can also compose a pre-filled message for a group via URL:

https://meta.discourse.org/new-message?groupname=team&title=topic%20title&body=topic%20body`

Notice the groupname param in above URL, this means that you want to create a new pre-filled message for a group (as opposed to username for composing a message for user).

Best practices

  • You can send message to multiple users by comma separating the usernames. For example

    https://meta.discourse.org/new-message?username=foo,bar
    
  • You don’t need to fill in all of the params. For example any of these would work:

    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=
    
  • You can add line spaces using the %0A and %0A%0D codes to give some structure to the body of the message:

    https://yoursite.discourse.org/new-message?username=test_user&title=Bug%20Report&body=Please%20include%20all%20relevant%20details.%0A%0DCPU:%0AMemory:%0A%0DDescribe%20Issue:
    
  • If you have SSO, you can link to example.com/session/sso and then set the return path to create the personal message. If the user is already logged in they will be redirected automatically to the url supplied by the return path. If they aren’t logged in they will be taken to the sso login page and then redirected to the return path url. The return path will need to be url encoded.

    href="http://localhost:3000/session/sso?return_path=http%3A%2F%2Flocalhost%3A3000%2Fnew-message%3Fusername%3Dscossar%26title%3DInformation+requested+about+gentle+yoga+classes">
    

Currently not supported

  • Use the pre-filled URL to compose a message to multiple groups.
  • Use the pre-filled URL to open the composer in a user’s summary page.
  • Using email instead of the username to pre-fill a personal message.

Additional resources

Last edited by @hugh 2024-06-28T02:53:33Z

Check documentPerform check on document:
56 个赞

也可以为此分配标签吗?我尝试模仿这里的标签实现,但没有成功。

我相当确定这是相同的代码。您尝试了哪个 URL?如果需要,您可以将主机名替换为 meta.discourse.org(只是不要实际创建主题!)。

您确定您使用的是类似 tags=email,planned 的内容,并且标签存在并且可以由尝试使用该链接的用户应用吗?

1 个赞

这是我正在使用的 URL:

https://developer.sailpoint.com/discuss/new-message?groupname=community_managers&title=Livestream%20Presentation%20Submission&tags=livestream&body=I%20would%20like%20to%20present%20a%20livestream%21%20Here%20is%20an%20overview%20of%20my%20presentation%3A%0A%0ATopic%3A%20%5B%5Binsert%20topic%20here%5D%5D%0ADescription%3A%20%5B%5Binsert%20description%20here%5D%5D

你提出了一个关于标签权限的有效观点。项目经理(PM)能否在隐藏标签的情况下创建?

用户是否可以通过用户体验正常创建带有所需标签的PM?(提示:不是你配置的方式。)URL只是用来引导用户在用户体验中可能进行的操作。它没有魔力。

有一个站点设置可以为PM启用标签。不,用户无法创建他们无权查看的标签。

1 个赞

我已确认:

:frowning:

是否可以在(PM正文中)包含用户当前所在的URL?我们希望在我们的主题中添加一些PM链接,供特定用户群使用,以便他们可以给我们发送消息,引用特定主题。

1 个赞