Expose external_id in embed.js

I think I understand now. You are wanting to use the script that’s shown here: https://meta.discourse.org/t/embed-discourse-comments-on-another-website-via-javascript/31963#alternate-configuration-linking-to-existing-topics-6. But instead of using the topicId parameter you want to use the external_id parameter.

Possibly this could be added as a feature.

It might also be possible to make a request on the client to (for example)
http://localhost:4200/t/external_id/1.json
Then extract the topic’s actual URL from the response and either parse that URL to extract the topic’s id, or make a second request to the topic’s URL to get the topic id.
This seems likely to be error prone.

If you’re adding the embed script on the server instead of the client, you could just make a GET request to http://localhost:4200/t/external_id/1.json, perform any actions you need to get the Discourse topic’s id, then insert the script onto your web page using that id.