# Embedding, but don't automatically create a topic until a user chooses to comment

**URL:** https://meta.discourse.org/t/embedding-but-dont-automatically-create-a-topic-until-a-user-chooses-to-comment/61450
**Category:** Feature
**Tags:** pr-welcome
**Created:** [September 23, 2015, 9:03am UTC](https://meta.discourse.org/t/embedding-but-dont-automatically-create-a-topic-until-a-user-chooses-to-comment/61450 "2015-09-23T09:03:12Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![avorio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/avorio/32/120939_2.png) [@avorio](https://meta.discourse.org/u/avorio)
#### Post date: [September 23, 2015, 9:03am UTC](https://meta.discourse.org/t/embedding-but-dont-automatically-create-a-topic-until-a-user-chooses-to-comment/61450/1 "2015-09-23T09:03:12Z")

</div>

This is a fantastic feature! I look forward to making good use of it.

Would it be possible to **not** automatically create a topic until a user chooses to comment on the article? I want to prevent having a ton of topics with no replies (i.e. which were created automatically by visitors who only read articles and not commented on them). I’m specifically thinking of a site with a large number of articles; only a few of them will actually have comments.

What would be the most reasonable way to achieve that? Any thoughts?

Thanks.

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [September 23, 2015, 2:37pm UTC](https://meta.discourse.org/t/embedding-but-dont-automatically-create-a-topic-until-a-user-chooses-to-comment/61450/2 "2015-09-23T14:37:52Z")

</div>

> [@Embed Discourse comments on another website via Javascript](https://meta.discourse.org/t/embed-discourse-comments-on-another-website-via-javascript/31963/32):
>
> Would it be possible to not automatically create a topic until a user chooses to comment on the article?

No this is not possible. Discourse doesn’t support commenting on things that don’t exist yet, so the topic needs to be in place when they navigate over to post.

---

<div class="post-metadata">

### Author: ![avorio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/avorio/32/120939_2.png) [@avorio](https://meta.discourse.org/u/avorio)
#### Post date: [September 25, 2015, 1:37pm UTC](https://meta.discourse.org/t/embedding-but-dont-automatically-create-a-topic-until-a-user-chooses-to-comment/61450/3 "2015-09-25T13:37:23Z")

</div>

Robin, thanks for your response.

> [@Embed Discourse comments on another website via Javascript](https://meta.discourse.org/t/embed-discourse-comments-on-another-website-via-javascript/31963/33):
>
> No this is not possible. Discourse doesn’t support commenting on things that don’t exist yet, so the topic needs to be in place when they navigate over to post.

I understand. But _when_ exactly is the topic created? When (a) the blog post is loaded, or (b) when the user clicks on the link to write a comment? What I want to prevent is a ton of topics being created as users read blog posts (and not comment). That’s because all these topics would end up being empty topics with no posts. For a site with millions of articles, that would swamp the forums.

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [September 25, 2015, 2:02pm UTC](https://meta.discourse.org/t/embedding-but-dont-automatically-create-a-topic-until-a-user-chooses-to-comment/61450/4 "2015-09-25T14:02:15Z")

</div>

The blog post is created the first time Discourse successfully crawls it. This usually happens shortly after the first request for the `IFRAME` that shows the comments. So if people are viewing your blog entries, you will be getting topics generated.

---

<div class="post-metadata">

### Author: ![avorio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/avorio/32/120939_2.png) [@avorio](https://meta.discourse.org/u/avorio)
#### Post date: [September 25, 2015, 2:19pm UTC](https://meta.discourse.org/t/embedding-but-dont-automatically-create-a-topic-until-a-user-chooses-to-comment/61450/5 "2015-09-25T14:19:35Z")

</div>

> [@Embed Discourse comments on another website via Javascript](https://meta.discourse.org/t/embed-discourse-comments-on-another-website-via-javascript/31963/35):
>
> The blog post is created the first time Discourse successfully crawls it. This usually happens shortly after the first request for the IFRAME that shows the comments. So if people are viewing your blog entries, you will be getting topics generated.

That is exactly what I thought, and what I think might not be the desired behaviour for many sites, specially large-scale ones. And that is precisely because of the number of empty topics that would be created as people are simply reading articles. For a site like the one I manage, this would mean millions of empty topics being generated as soon as the integration is in place (as we have millions of articles).

That would be far from ideal.

Would it be possible to only create the topic when someone publishes a comment?

Or, at least when someone clicks on “Write a comment”, or something along these lines…

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [September 25, 2015, 2:38pm UTC](https://meta.discourse.org/t/embedding-but-dont-automatically-create-a-topic-until-a-user-chooses-to-comment/61450/6 "2015-09-25T14:38:40Z")

</div>

> [@Embed Discourse comments on another website via Javascript](https://meta.discourse.org/t/embed-discourse-comments-on-another-website-via-javascript/31963/36):
>
> Would it be possible to only create the topic when someone publishes a comment?

No, it is a huge change architecture wise. On Discourse you need to post replies on topics. There is no concept of “replying to a topic that doesn’t exist yet.”

---

<div class="post-metadata">

### Author: ![avorio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/avorio/32/120939_2.png) [@avorio](https://meta.discourse.org/u/avorio)
#### Post date: [September 25, 2015, 2:54pm UTC](https://meta.discourse.org/t/embedding-but-dont-automatically-create-a-topic-until-a-user-chooses-to-comment/61450/7 "2015-09-25T14:54:24Z")

</div>

> [@Embed Discourse comments on another website via Javascript](https://meta.discourse.org/t/embed-discourse-comments-on-another-website-via-javascript/31963/37):
>
> No, it is a huge change architecture wise. On Discourse you need to post replies on topics. There is no concept of “replying to a topic that doesn’t exist yet.”

Yeah, I wouldn’t suggest changing such a fundamental part of the underlying architecture. But I reckon we could change the way we automatically create those topics as triggered by the JavaScript embed code. Instead of creating a topic once the `iframe` is loaded, couldn’t we make the link “Write a comment” point to a script that will _then_ create the topic _and then_ display the post editor?

That would be a huge improvement to the terrible scenario I described above.

Thoughts?

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [September 25, 2015, 3:16pm UTC](https://meta.discourse.org/t/embedding-but-dont-automatically-create-a-topic-until-a-user-chooses-to-comment/61450/8 "2015-09-25T15:16:32Z")

</div>

> [@Embed Discourse comments on another website via Javascript](https://meta.discourse.org/t/embed-discourse-comments-on-another-website-via-javascript/31963/38):
>
> couldn’t we make the link “Write a comment” point to a script that will then create the topic and then display the post editor?

There are issues with this approach too. The first is that the topics to embed are crawled as a background job. You wouldn’t want it to happen on click as it involves perhaps multiple HTTP requests back to the source it’s embedding to get the right content.

We could I suppose show a huge spinner that says “please wait before replying” the first time someone clicks it, but that would be tricky to build and I’m not sure it would be a great experience for the user. Also, people could still create empty topics by clicking that link and never making a post.

---

<div class="post-metadata">

### Author: ![avorio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/avorio/32/120939_2.png) [@avorio](https://meta.discourse.org/u/avorio)
#### Post date: [September 25, 2015, 4:12pm UTC](https://meta.discourse.org/t/embedding-but-dont-automatically-create-a-topic-until-a-user-chooses-to-comment/61450/9 "2015-09-25T16:12:56Z")

</div>

> [@Embed Discourse comments on another website via Javascript](https://meta.discourse.org/t/embed-discourse-comments-on-another-website-via-javascript/31963/39):
>
> We could I suppose show a huge spinner that says “please wait before replying” the first time someone clicks it, but that would be tricky to build and I’m not sure it would be a great experience for the user. Also, people could still create empty topics by clicking that link and never making a post.

I’m confident that even that would be better than swamping the forum with two million new topics.

> [@Embed Discourse comments on another website via Javascript](https://meta.discourse.org/t/embed-discourse-comments-on-another-website-via-javascript/31963/39):
>
> There are issues with this approach too. The first is that the topics to embed are crawled as a background job. You wouldn’t want it to happen on click as it involves perhaps multiple HTTP requests back to the source it’s embedding to get the right content.

Couldn’t we have an API call of some sort for whatever is needed to create the topic? I’d love to have Discourse call a data feed, perhaps passing the blog post URL as an argument and receiving a title as the bare minimum (in JSON). This could work beautifully and allow some amazing integrations with existing content management systems.

---

<div class="post-metadata">

### Author: ![avorio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/avorio/32/120939_2.png) [@avorio](https://meta.discourse.org/u/avorio)
#### Post date: [September 25, 2015, 4:20pm UTC](https://meta.discourse.org/t/embedding-but-dont-automatically-create-a-topic-until-a-user-chooses-to-comment/61450/10 "2015-09-25T16:20:19Z")

</div>

> [@Embed Discourse comments on another website via Javascript](https://meta.discourse.org/t/embed-discourse-comments-on-another-website-via-javascript/31963/40):
>
> Couldn’t we have an API call of some sort for whatever is needed to create the topic? I’d love to have Discourse call a data feed, perhaps passing the blog post URL as an argument and receiving a title as the bare minimum (in JSON). This could work beautifully and allow some amazing integrations with existing content management systems.

Also — actually, if the bare minimum is the topic title, couldn’t we include that in the list of variables inside `DiscourseEmbed = {}`? That makes **a lot more** sense to me than making one (or more) HTTP request(s) for more data.

For example:

```plaintext
  DiscourseEmbed = { discourseUrl: 'http://discourse.example.com/',
                     discourseEmbedUrl: 'http://example.com/blog/entry-123.html',
                     discourseEmbedTitle: 'Title of the topic to be created' };

```

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [September 25, 2015, 4:53pm UTC](https://meta.discourse.org/t/embedding-but-dont-automatically-create-a-topic-until-a-user-chooses-to-comment/61450/11 "2015-09-25T16:53:53Z")

</div>

No, that would be very insecure. You can’t trust what the client passes to you to create topics. It’s important that the Discourse instance makes a GET request to a server you have whitelisted as embeddable.

I appreciate the enthusiasm but you’ll have to trust me when I say this is not easy to do.

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [September 25, 2015, 6:46pm UTC](https://meta.discourse.org/t/embedding-but-dont-automatically-create-a-topic-until-a-user-chooses-to-comment/61450/12 "2015-09-25T18:46:32Z")

</div>

> [@Embed Discourse comments on another website via Javascript](https://meta.discourse.org/t/embed-discourse-comments-on-another-website-via-javascript/31963/36):
>
> And that is precisely because of the number of empty topics that would be created as people are simply reading articles. For a site like the one I manage, this would mean millions of empty topics being generated as soon as the integration is in place (as we have millions of articles).

You can have your server not output the JS for articles published prior to setting up the embedding.

---

<div class="post-metadata">

### Author: ![avorio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/avorio/32/120939_2.png) [@avorio](https://meta.discourse.org/u/avorio)
#### Post date: [September 28, 2015, 10:49am UTC](https://meta.discourse.org/t/embedding-but-dont-automatically-create-a-topic-until-a-user-chooses-to-comment/61450/13 "2015-09-28T10:49:56Z")

</div>

> [@Embed Discourse comments on another website via Javascript](https://meta.discourse.org/t/embed-discourse-comments-on-another-website-via-javascript/31963/43):
>
> You can have your server not output the JS for articles published prior to setting up the embedding.

Thank you for the suggestion, but that of course wouldn’t allow users to start a discussion on an old article, which is also not the desired behaviour.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [September 28, 2015, 4:02pm UTC](https://meta.discourse.org/t/embedding-but-dont-automatically-create-a-topic-until-a-user-chooses-to-comment/61450/14 "2015-09-28T16:02:31Z")

</div>

There seems to be conflicting goals here  
I don’t want topics that don’t have any replies  
I want users to be able to reply to topics that don’t have any replies

I can think of two possible approaches  
Compromise - determine an arbitrary cut-off point for “old” so it won’t swamp the forum with topics yet will allow members to post replies on the topics that are there  
Have all topics - but - set them as Closed so they will “fall away” off of lists, requiring members to “Reply as linked topic” to start a discussion.

---

<div class="post-metadata">

### Author: ![erlend\_sh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/erlend_sh/32/119475_2.png) [@erlend\_sh](https://meta.discourse.org/u/erlend_sh)
#### Post date: [October 1, 2015, 9:42am UTC](https://meta.discourse.org/t/embedding-but-dont-automatically-create-a-topic-until-a-user-chooses-to-comment/61450/15 "2015-10-01T09:42:57Z")

</div>

> [@Embed Discourse comments on another website via Javascript](https://meta.discourse.org/t/embed-discourse-comments-on-another-website-via-javascript/31963/32):
>
> Would it be possible to not automatically create a topic until a user chooses to comment on the article? I want to prevent having a ton of topics with no replies (i.e. which were created automatically by visitors who only read articles and not commented on them). I’m specifically thinking of a site with a large number of articles; only a few of them will actually have comments.

I see your predicament. But instead of the potentially messy solutions discussed so far, what if the topics are indeed created normally, but _until they have a reply_, they are **unlisted** , i.e. not visible in the forum stream and only accessible via a direct link. Would that be an acceptable compromise?

In other words, the basic spec request becomes something like this:

- Option to set topics generated for embedded comments as unlisted by default.
- Special flag that can be put on selected unlisted topics (in this case automatically) to make them unlisted if they receive a reply.

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [October 1, 2015, 7:05pm UTC](https://meta.discourse.org/t/embedding-but-dont-automatically-create-a-topic-until-a-user-chooses-to-comment/61450/16 "2015-10-01T19:05:31Z")

</div>

> [@Embed Discourse comments on another website via Javascript](https://meta.discourse.org/t/embed-discourse-comments-on-another-website-via-javascript/31963/47):
>
> Special flag that can be put on selected unlisted topics (in this case automatically) to make them unlisted if they receive a reply.

Hey, we could use the same “boring” flag I proposed for PM usage! Any new posts on a topic are supposed to clear the boring flag.

---

<div class="post-metadata">

### Author: ![avorio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/avorio/32/120939_2.png) [@avorio](https://meta.discourse.org/u/avorio)
#### Post date: [October 5, 2015, 4:54pm UTC](https://meta.discourse.org/t/embedding-but-dont-automatically-create-a-topic-until-a-user-chooses-to-comment/61450/17 "2015-10-05T16:54:17Z")

</div>

> [@Embed Discourse comments on another website via Javascript](https://meta.discourse.org/t/embed-discourse-comments-on-another-website-via-javascript/31963/47):
>
> I see your predicament. But instead of the potentially messy solutions discussed so far, what if the topics are indeed created normally, but until they have a reply, they are unlisted, i.e. not visible in the forum stream and only accessible via a direct link. Would that be an acceptable compromise?

Thanks for approaching this, @erlend_sh. Out of all the options discussed thus far, I reckon this might be the best one. It is still inefficient given that a lot of topics will be created but never used —how much do we know about the impact of millions of topics in the performance of a Discourse instance?—, but insofar as user experience is concerned, I guess your approach prevents the swamping we were talking about.

Question now is: how do we get to your solution?

Thanks again.

---

<div class="post-metadata">

### Author: ![avorio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/avorio/32/120939_2.png) [@avorio](https://meta.discourse.org/u/avorio)
#### Post date: [October 5, 2015, 5:00pm UTC](https://meta.discourse.org/t/embedding-but-dont-automatically-create-a-topic-until-a-user-chooses-to-comment/61450/18 "2015-10-05T17:00:08Z")

</div>

> [@Embed Discourse comments on another website via Javascript](https://meta.discourse.org/t/embed-discourse-comments-on-another-website-via-javascript/31963/45):
>
> There seems to be conflicting goals here I don’t want topics that don’t have any replies I want users to be able to reply to topics that don’t have any replies

Mmmm.. it’s more like:

- I don’t want the _unnecessary_ creation of topics;
- I don’t want to swamp the forums with millions of “empty” topics, compromising UX;
- I want users to be able to comment on all articles, regardless of when they were posted.

The fact that we need a **topic object** to exist before a **post object** can be created is a _construct_ within the system. I’m not challenging the architecture, just the flow / user experience. We might want to start with some _text_ (e.g. the user’s comment), **then** create the _topic object_ and then create the _post object_.

---

<div class="post-metadata">

### Author: ![erlend\_sh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/erlend_sh/32/119475_2.png) [@erlend\_sh](https://meta.discourse.org/u/erlend_sh)
#### Post date: [October 5, 2015, 6:04pm UTC](https://meta.discourse.org/t/embedding-but-dont-automatically-create-a-topic-until-a-user-chooses-to-comment/61450/19 "2015-10-05T18:04:30Z")

</div>

> [@Embed Discourse comments on another website via Javascript](https://meta.discourse.org/t/embed-discourse-comments-on-another-website-via-javascript/31963/50):
>
> Question now is: how do we get to your solution?

If @eviltrout is willing to accept a PR that adds the functionality I described, your best bet is to

a. Become a paying Discourse customer and politely ask for this feature to be prioritised, or;  
b. Pay an independent developer to work on a PR

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [October 6, 2015, 11:53pm UTC](https://meta.discourse.org/t/embedding-but-dont-automatically-create-a-topic-until-a-user-chooses-to-comment/61450/20 "2015-10-06T23:53:33Z")

</div>

> [@Embed Discourse comments on another website via Javascript](https://meta.discourse.org/t/embed-discourse-comments-on-another-website-via-javascript/31963/50):
>
> how much do we know about the impact of millions of topics in the performance of a Discourse instance?

Do you actually have millions of blog posts that would be created as topics? Because that would definitely create a lot of data and performance would be a concern. However, if you are just creating thousands, the performance impact is negligable to create them invisibly. I think @erlend_sh’s idea is a good one!

[Next page](https://meta.discourse.org/t/embedding-but-dont-automatically-create-a-topic-until-a-user-chooses-to-comment/61450.md?page=2)
