Migrating embedded topics from topicId to automatic topic creation

The environment: I have a Discourse forum and a website. The website has pages. The pages use embedded Discourse topics for commenting.

As part of a migration process I am currently using a hard-coded mapping of “webpage url” to “Discourse topic id” and use server-side code on the webpages to embed the appropriate Discourse topic.

This works well for all existing webpages because I migrated previous comments into Discourse topics.

For new webpages it would be too much overhead to a) create a new topic and b) continue to track the new mappings between webpages and topics. So I would like to switch to Discourse’s own logic for creating topics on-demand and not specify the existing topic IDs on the webpages anymore.

I assume that Discourse has its own mapping table to know which topic to serve if a request for an embedded comment thread comes in.

Is that the case and can I manually insert my existing mappings there, then switch my webpages to use that functionality?

So you want to Embed Discourse comments on another website via Javascript?

That is what I already do and where I want to change the configuration.

Currently I use Embed Discourse comments on another website via Javascript (“Configuring Discourse for Embedding (simple setup)”)

And I want to change to the standard Embed Discourse comments on another website via Javascript (“(Alternate Configuration) Linking to existing topics”)

1 Like

I added a simple if switch to my website that uses a stored topicId if available and the page’s discourseEmbedUrl otherwise.

Sadly I had a bad URL for some pages and now I have bad thread references between the pages and the threads. I found the table topic_embeds, that seems to be it. Can I safely delete from that table and re-visit the pages to regenerate threads? Or do I need to clean up some related rows elsewhere?