Create a link to start a new personal message with pre-filled information

Discourse now supports composing a new (pre-filled) personal message via URL! :sunny:

To compose a new pre-filled message, modify URL params like this:

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

This will open a composer window pre-filled with username, title and body.

Breaking down the link / URL to show the available options, we have:

  • the base URL / link: https://discourse.example.com/new-message
  • the ? URL operator to add the different options
  • the username of the community member you want to message: username=techapj
  • the & URL operator to include multiple options
  • the message title: title=message%20title
  • the & URL operator again to include multiple options
  • the body of the message: body=message%20body

Try it out live on try.discourse.org! :smile:

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).

Tips and tricks

  • 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.

Want to compose a pre-filled topic instead? See: Create a link to start a new topic with pre-filled information

55 Likes