# מצא את מפתח התגובה לנושא ספציפי. קסם קונסול Rails?

**URL:** https://meta.discourse.org/t/find-the-reply-key-for-a-specific-topic-rails-console-magic/278288
**Category:** Support
**Tags:** email
**Created:** [8 בספטמבר,‏ 2023,‏ 12:21pm UTC](https://meta.discourse.org/t/find-the-reply-key-for-a-specific-topic-rails-console-magic/278288 "2023-09-08T12:21:24Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![jbrains](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jbrains/32/208183_2.png) [@jbrains](https://meta.discourse.org/u/jbrains)
#### Post date: [8 בספטמבר,‏ 2023,‏ 12:21pm UTC](https://meta.discourse.org/t/find-the-reply-key-for-a-specific-topic-rails-console-magic/278288/1 "2023-09-08T12:21:25Z")

</div>

Hi, folks. I’m trying to set up automated forwarding of certain emails to a topic and/or to create a new topic in a given category. I’m struggling to test and it would help me to be able to generate the “reply key” for an existing topic or category on demand. Is there some Rails console magic that I could perform to generate the reply key without sending myself email notifications? Am I stuck with end-to-end testing to figure this out? (Create dummy topics, wait for email notifications, and so on.)

Thank you.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [8 בספטמבר,‏ 2023,‏ 2:53pm UTC](https://meta.discourse.org/t/find-the-reply-key-for-a-specific-topic-rails-console-magic/278288/2 "2023-09-08T14:53:24Z")

</div>

> [@jbrains](#):
>
> I’m trying to set up automated forwarding of certain emails to a topic and/or to create a new topic in a given category.

If you want to create new topics in a given category, then you set that up in the `Custom incoming email address:` setting in the category settings. See [Configuring incoming email to create new topics or group messages](https://meta.discourse.org/t/configure-incoming-email-to-create-new-topics-or-group-messages/62977), I think.

I don’t think there’s any way to do that for a topic, as each reply key is tied to a topic and a username.

---

<div class="post-metadata">

### Author: ![jbrains](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jbrains/32/208183_2.png) [@jbrains](https://meta.discourse.org/u/jbrains)
#### Post date: [9 בספטמבר,‏ 2023,‏ 11:45am UTC](https://meta.discourse.org/t/find-the-reply-key-for-a-specific-topic-rails-console-magic/278288/3 "2023-09-09T11:45:18Z")

</div>

Indeed, I have things working for creating new topics, which works well enough for my purposes, but I’d like to go farther.

Is there really no function I can invoke to get the reply key given a topic and a user? That seems a shame. I don’t think I have the energy to go caving to find it and extract it. I’d be shocked if it weren’t already extracted somewhere…

By chance, does anyone else know?

---

<div class="post-metadata">

### Author: ![renato](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/renato/32/383632_2.png) [@renato](https://meta.discourse.org/u/renato)
#### Post date: [9 בספטמבר,‏ 2023,‏ 12:44pm UTC](https://meta.discourse.org/t/find-the-reply-key-for-a-specific-topic-rails-console-magic/278288/4 "2023-09-09T12:44:57Z")

</div>

> [@jbrains](#):
>
> Is there really no function I can invoke to get the reply key given a topic and a user?

To be honest, I wasn’t very familiar with this part of the system, but it seems simple enough. This is where the reply key is created or retrieved for a given post and user, to be used when sending an email:

> <https://github.com/discourse/discourse/blob/8c6b1fbbc1815945b7b88d40f6b9ac21b46a7de1/lib/email/sender.rb#L495>

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [9 בספטמבר,‏ 2023,‏ 12:51pm UTC](https://meta.discourse.org/t/find-the-reply-key-for-a-specific-topic-rails-console-magic/278288/5 "2023-09-09T12:51:46Z")

</div>

> [@jbrains](#):
>
> I don’t think I have the energy to go caving to find it and extract it.

It’s emailed to them when it’s created. It’s good just for a single user and post. What are you going to do when you find it? I think it’s probably easier to just generate a new one if you want one, but then what are you going to do with it?

---

<div class="post-metadata">

### Author: ![jbrains](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jbrains/32/208183_2.png) [@jbrains](https://meta.discourse.org/u/jbrains)
#### Post date: [9 בספטמבר,‏ 2023,‏ 12:56pm UTC](https://meta.discourse.org/t/find-the-reply-key-for-a-specific-topic-rails-console-magic/278288/6 "2023-09-09T12:56:19Z")

</div>

> [@pfaffman](#):
>
> > [@jbrains](#):
> >
> > I don’t think I have the energy to go caving to find it and extract it.
> 
> It’s emailed to them when it’s created. It’s good just for a single user and post. What are you going to do when you find it? I think it’s probably easier to just generate a new one if you want one, but then what are you going to do with it?

I have been trying for two days on and off to get email notifications of new topics in this category and I’m not receiving them. I am tired of trying to figure out which magic configuration options are wrong. I was hoping to do more directly the thing I’m actually trying to achieve: to be able to send an email to reply to a topic.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [9 בספטמבר,‏ 2023,‏ 2:09pm UTC](https://meta.discourse.org/t/find-the-reply-key-for-a-specific-topic-rails-console-magic/278288/7 "2023-09-09T14:09:30Z")

</div>

You need to change the category settings to watching (go to the category and click the c little 🔔 on the right) and see that in your profile settings you have enroll me when set to always, otherwise, discourse won’t email you posts that you have seen already.

---

<div class="post-metadata">

### Author: ![jbrains](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jbrains/32/208183_2.png) [@jbrains](https://meta.discourse.org/u/jbrains)
#### Post date: [11 בספטמבר,‏ 2023,‏ 3:28pm UTC](https://meta.discourse.org/t/find-the-reply-key-for-a-specific-topic-rails-console-magic/278288/9 "2023-09-11T15:28:35Z")

</div>

And finally it is behaving the way I expected. Evidently I needed to enable mailing list mode in my user profile in addition to enabling it as a site administrator.

I genuinely don’t know if I read that and failed to notice it or it’s not spelled out enough in the various bits of documentation.

I definitely needed someone to say “Do this” and for it to work. I appreciate you for doing exactly that.

Even so, it would be very convenient to be able to generate a reply key to an existing topic that I wasn’t Watching when it was created, so that I could start replying to it by sending email. This seems like a non-obvious-but-helpful scenario to me.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [11 בספטמבר,‏ 2023,‏ 4:30pm UTC](https://meta.discourse.org/t/find-the-reply-key-for-a-specific-topic-rails-console-magic/278288/10 "2023-09-11T16:30:00Z")

</div>

> [@jbrains](#):
>
> And finally it is behaving the way I expected. Evidently I needed to enable mailing list mode in my user profile in addition to enabling it as a site administrator.

You do if you want every single message to be emailed to you. You can also watch particular categories and see that you have changed your settings so that Discourse emails you messages that you have already read in your web browser.

> [@jbrains](#):
>
> it would be very convenient to be able to generate a reply key to an existing topic that I wasn’t Watching when it was created,

It would be useful only if you wanted to use the web interface to generate the key and then go to your mail client and start a message. How is that more convenient than just sending a reply? (Maybe you want everything you write to exist in your mail client?)
