# How can I access composePrivateMessage from a post menu button?

**URL:** https://meta.discourse.org/t/how-can-i-access-composeprivatemessage-from-a-post-menu-button/237352
**Category:** Development
**Created:** [August 27, 2022, 6:38pm UTC](https://meta.discourse.org/t/how-can-i-access-composeprivatemessage-from-a-post-menu-button/237352 "2022-08-27T18:38:52Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![tarek](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tarek/32/124831_2.png) [@tarek](https://meta.discourse.org/u/tarek)
#### Post date: [August 27, 2022, 6:38pm UTC](https://meta.discourse.org/t/how-can-i-access-composeprivatemessage-from-a-post-menu-button/237352/1 "2022-08-27T18:38:52Z")

</div>

Hello,

I wrote [a plugin for mailing list type behaviour](https://meta.discourse.org/t/allow-reply-to-individual-instead-of-topic-forum-mailing-list-feature/44905), where emails can be replied to (only the sender) and reply-all (to the whole topic). I want to recreate this in the web UI as well by having a “reply” and “reply all” button on each post in the topic. The “reply” would mimic clicking on a post author’s card and then “message”. This is the default behaviour it gives:

 ![image](https://global.discourse-cdn.com/meta/original/4X/9/5/e/95ee3ff8cca0dc5220fbc40fac4f0a1ce1d888f2.png)

 ![image](https://global.discourse-cdn.com/meta/original/4X/2/f/b/2fb17177a5a69b74508d7e20858a7f3963f4f56d.png)

Despite writing the plugin above, I am not very familiar with rails and struggle significantly with it. I think I found the correct ‘action’ here. It is `composePrivateMessage`, which is found in `/discourse/app/assets/javascripts/discourse/app/routes/application.js`. As indicated by the path, it’s a route, which is throwing me off, and I am struggling to turn that into a clickable button.

Here is what I have right now:

```plaintext
  api.addPostMenuButton("reply-privately", (attrs, state) => {
    return {
      action: composePrivateMessage(user, post),
      title: "reply-privately",
      icon: "reply",
      position: "last",
      className: "reply-privately",
    };
  });

```

Any thoughts on how to make the ‘action’ fit into the ‘route’?
