aws-lex-web-ui
aws-lex-web-ui copied to clipboard
Place the same bot on multiple pages
Hey Oliver! Is there a way to place the same Chatbot on multiple pages of a website yet? We have multiple domains where the same chatbot needs to live without any modifications, so wanted to see if we can extend the parent origin to multiple domains without creating multiple JSON config files.
Thanks! Chirag
-
add support for multiple domains in corrs configuration
-
use a wildcard in the corrs configuration to allow all domains
When will this feature become available? As an agency I see no point in building the same bot again and again for my clients.
Is this feature supported now?
I'm curious if this is sill the name of the game. Because we came up with a solution that just adds conditionals in the loader snippet that checks the current window.location.origin
and sets the baseUrl
(iframe origin) that's serving the bundle for that named parentOrigin. In this case, we did/are giving a baseUrl per expected parentOrigin. (even if it's just one json file that changes). We also had to treat subdomains of a main root domain as unique to each other and sibling subdomains.
<script>
(function() {
let iframeOrigin = IFRAME_ORIGIN_DEFAULT;
var parentOrigin = window.location.origin;
if (parentOrigin === PARENT_ORIGIN_B){
iframeOrigin = IFRAME_ORIGIN_B;
};
if (parentOrigin === PARENT_ORIGIN_C) {
iframeOrigin = IFRAME_ORIGIN_C;
};
var lexScript = document.createElement("script");
lexScript.src = `${iframeOrigin}/lex-web-ui-loader.min.js`;
lexScript.type = "text/javascript";
lexScript.addEventListener("load", function() {
var loaderOpts = {
baseUrl: `${iframeOrigin}/`,
shouldLoadMinDeps: true,
};
var loader = new ChatBotUiLoader.IframeLoader(loaderOpts);
loader.load().catch(function (error) {
console.error(error);
});
});
document.body.appendChild(lexScript);
})();
</script>
cc @atjohns