aws-lex-web-ui icon indicating copy to clipboard operation
aws-lex-web-ui copied to clipboard

Place the same bot on multiple pages

Open chiragchhita opened this issue 6 years ago • 4 comments

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

chiragchhita avatar Apr 02 '18 15:04 chiragchhita

  1. add support for multiple domains in corrs configuration

  2. use a wildcard in the corrs configuration to allow all domains

JohnCalhoun avatar Jun 15 '18 13:06 JohnCalhoun

When will this feature become available? As an agency I see no point in building the same bot again and again for my clients.

p-nitin avatar Apr 05 '22 16:04 p-nitin

Is this feature supported now?

kmaramr avatar Sep 30 '22 22:09 kmaramr

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

israelias avatar Dec 15 '23 18:12 israelias