Topics with same title, generated from mail

Hi Discourse Experts —

We have some scripts that generate mails to our Discourse categories to automatically track project events like test results, new user issues being filed, etc. I had naively assumed that if two mails showed up with the the same subject line (say, “linux64 testing”), they would automatically end up in the same topic; yet it seems like we’re getting a separate topic for each such mail. (replying to a topic by mail keeps it in the same topic, as you’d expect of course).

Searching the forums about this a bit, I came across mentions of the “Allow topics with identical, duplicate titles” and “Allow topics with identical, duplicate titles if the category is different” settings. To my surprise, neither is checked on our site, yet we do have topics with the same title due to these scripts. Is it the case that these settings only apply to topics generated from the website interface, and not from email?

In any case, is there any way to configure a Discourse site such that mails sent to a given category with a given subject line are auto-merged into a single topic rather than resulting in a topic per mail message? (I understand that this could cause mild confusion if two users happen to post topics by mail with the identical subject, but that seems like a reasonable tradeoff to me).

Thank you,
-Brad

Having experimented a bit more now, it looks to me like the “Allow topics with identical, duplicate titles” settings only apply to topics created via the website, and not those received by email. I’ve opened up a feature request to extend topics when an email’s subject matches its title rather than creating a multitude of topics with the identical title.

If you’re not looking at the site, how do you know if a title has already been used?

If you’re not looking at the site, how do you know if a title has already been used?

I’m not certain I’m understanding your question (because I worry that I’m repeating myself), but taking a stab at it:

The scenario that motivates this question for our Discourse site is one in which posts are generated by scripts that use predictable subject lines (e.g., “linux64 testing”) where the intention is that they be grouped together within a single topic. For these scripts, it doesn’t matter whether the title has been used or not, so long as the behavior is “if a topic with the subject line’s title already exists, have the mail add a post to the existing topic rather than creating a new one; if it does not already exist, create a new topic with the subject line as its title.”

Getting a bit more hypothetical, I could imagine a user who works within a secure environment and is not allowed to interact directly with websites; but whose sysadmins reflect the contents of a website of interest into their environment for read-only browsing. Knowing the subject line of a given topic would permit such a user to add a new post to a given topic by email without needing a mail about that topic in their inbox to reply to.

Let me know if I’ve misunderstood what you’re asking.

That’s a very specific use case to ask to change a whole behavior.

Have you considered using something other than SMTP for message delivery?

Have you considered using something other than SMTP for message delivery?

We haven’t, but could certainly consider it if that’s considered best practice. To make sure I’m understanding, are you suggesting having our scripts post to Discourse by interacting with the website through HTML like a human would? Or do Discourse sites support an API that the scripts could target directly? If you have pointers or examples of how we might approach this, that would be very useful; we’re definitely still very new to Discourse administration.

Or, I was wondering whether there might be some other trick that we could use in the email headers to cause Discourse to append them to the existing topic rather than creating a new one. I’m assuming making the subject line “Re: linux64 testing” is insufficient and that it’s the Reply-to: address and/or email header metadata that causes a reply to append to a topic rather than starting a new one? (in which case, we could manually create topics for every possible script subject line in the category, figure out what that meta-data was, and then embed it into our script, but that would feel pretty fiddly if there were already a way to auto-merge mails into an existing topic by subject line, particularly for scripts that might generate new subject lines over time).

That’s a very specific use case to ask to change a whole behavior.

Perhaps, but to be fair, in the OP, I was only asking about whether there’s a way to achieve what we wanted and expressing confusion that we were getting multiple topics with the same title in spite of having the “allow duplicate topic” settings unchecked. I wasn’t able to find any documentation indicating that this was the expected behavior and thought that since Discourse rejects mails on all sorts of bases (e.g., “that subject line doesn’t seem to be a sentence”) we might’ve gotten bounces saying “that topic title already exists within this category” (not that it would’ve made me any happier, it just would’ve seemed more consistent with the checkbox titles).

But, I also don’t think the behavior change is all that odd to request: I think it’s really great and powerful that Discourse sites can accept posts by email. And in our case, it’s 80% of the way to a good solution for having scripts generate updates to existing Discourse topics. And the feature request seemed similar to others I’d seen on Discourse-meta that did get implemented in that it seems clearly useful (in that lots of projects have scripts that generate mails) and didn’t strike me as being inherently in opposition to Discourse’s philosophy (though again, we’re new to the administration side of things). That’s not to say that it’s a no-brainer in any way, just that it wasn’t obvious to me that posing the question was unreasonable.

Start here

1 Like

When it’s a user interacting with the site, the email reply keys are what’s used to keep everything in the same topic. You would be using mailing list mode here to get the reply keys into the secure environment.

The “email-in” functionality (as distinct from “reply by email”) will only ever create topics, currently, and will never add to an existing topic.

2 Likes

Hi @riking and @Stephen

I thought I understood the state of Discourse after your comments on this issue last week (which I’d summarize as “by design, duplicate titles are accepted when sent in via the “email-in” functionality regardless of the status of the ‘allow duplicate topics’ settings because it’s not clear what else the site could do?”). But today, I find I’m confused because our scripts got a bounce for certain mails, stating:

Title has already been used

Did I misunderstand the state of things, or has something changed on your side since last week?

A few things have changed on our side which could explain the change in behavior:

  • I made the email address from which our scripts send mails into a “known user” on the Discourse site because otherwise I was getting occasional bounces, so thought I’d give it a higher trust level to work around that (in my previous messages, the script was acting as an “anonymous user”).

  • I added this known user to a group so that I could permit it to post topics to an otherwise restricted group (due to running into Category not accepting "anonymous email" from known users).

  • I turned off the ability for anonymous users to post to this category now that our script is a known user.

Assuming nothing changed on your end, is it correct that registered users are held to a higher standard w.r.t. not being able to mail in topics with duplicate titles than anonymous users? And is there a rationale for that choice? (I’d generally expect a registered user’s abilities to exceed that of an anonymous users).

Thanks for any insight here.

1 Like