Embed Discourse using external_id

Hi all,

I’m migrating my community to Discourse. I have a lot of existing content in my current community. It seems that the Javascript embed option is a viable way to show topics and comments in my site’s pages.

To make it possible to link the community content after it is migrated to Discourse to the correct page, I’m considering to use the external_id property.

I can set the property_id for each topic programmatically via the API, but I don’t know how to make use of it in the embedded code.

I have tried this:

<script type="text/javascript">
  DiscourseEmbed = {
    discourseUrl: 'https://discourse.mydomain.com/',
    external_id: "296645"
  };

  (function() {
    var d = document.createElement('script'); d.type = 'text/javascript'; d.async = true;
    d.src = DiscourseEmbed.discourseUrl + 'javascripts/embed.js';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(d);
  })();
</script>

but it doesn’t work.

Is there something else I can try?

Did you get this figured out? I’m needing to accomplish the same thing with the external_id but I don’t think we have the variable name right.

To embed a specific topic, the variable is 'topicId". I’ve tried ‘externalId’ but haven’t found what works.

I think that what you are trying to do is outlined here https://meta.discourse.org/t/embed-discourse-comments-on-another-website-via-javascript/31963#alternate-configuration-linking-to-existing-topics-6

That would be useful for the case where you want to link existing posts from an external site with existing Discourse topics. That code would need to be added to each of the external posts that you wanted to link to Discourse. For each post, you would need to set the topicId parameter to the ID of the Discourse topic you wanted to link to.

If this doesn’t solve the problem for you, can you explain what you are trying to do in more details?

I split it out to it’s own thread which hopefully makes more sense: