Amazon lex-chatbot-не может встраивать с использованием предопределенных библиотек - PullRequest
0 голосов
/ 14 июля 2020
• 1000 https://github.com/aws-samples/aws-lex-web-ui Ниже приведен код из github:
<html>
  <head>
    <title>My Parent Page</title>
  </head>
  <body>
    <h1>Welcome to my parent page</h1>
    <!-- loader script -->
    <script src="./lex-web-ui-loader.js"></script>
    <script>
      /*
        The loader library creates a global object named ChatBotUiLoader
        It includes the IframeLoader constructor
        An instance of IframeLoader has the load function which kicks off
        the load process
      */

      // options for the loader constructor
      var loaderOptions = {
        // you can put the chatbot UI config in a JSON file
        configUrl: './chatbot-ui-loader-config.json',

        // the full page chatbot UI that will be iframed
        iframeSrcPath: './chatbot-index.html#/?lexWebUiEmbed=true'
      };

      // The following statement instantiates the IframeLoader
      var iframeLoader = new ChatBotUiLoader.IframeLoader(loaderOptions);

      // chatbot UI config
      // The loader can also obtain these values from other sources such
      // as a JSON file or events. The configUrl variable in the
      // loaderOptions above can be used to put these config values in a file
      // instead of explicitly passing it as an argument.
      var chatbotUiConfig = {
        ui: {
          // origin of the parent site where you are including the chatbot UI
          // set to window.location.origin since hosting on same site
          parentOrigin: window.location.origin,
        },
        iframe: {
          // origin hosting the HTML file that will be embedded in the iframe
          // set to window.location.origin since hosting on same site
          iframeOrigin: window.location.origin,
        },
        cognito: {
          // Your Cognito Pool Id - this is required to provide AWS credentials
          poolId: '<your cognito pool id>'
        },
        lex: {
          // Lex Bot Name in your account
          botName: '<your lex bot name>'
        }
      };

      // Call the load function which returns a promise that is resolved
      // once the component is loaded or is rejected if there is an error
      iframeLoader.load(chatbotUiConfig)
        .then(function () {
          console.log('iframe loaded');
        })
        .catch(function (err) {
          console.error(err);
        });
    </script>
  </body>
</html>

Я пошел к родительскому объекту. html (почти аналогично приведенному выше коду) внутри src / website / parent. html из папки github и внес изменения в srcipt sr c путь, идентификатор пула когнитивной информации и имя lex, ссылаясь на приведенный выше код.

1) В URL-адресе конфигурации внутри приведенного выше кода я не знаю, какой путь к give for chatbot-ui-loader-config. json. В каталоге dist нет такого файла json. Должен ли я создать свой собственный?

2) Я создал веб-сайт, используя экземпляр EC2 linux . У меня есть индексный файл и aws -lex-web-ui (папка github) внутри моего индексного файла var / www/html.Inside, я вызываю родительский. html из aws -lex-web-ui папки . Правильный ли этот метод?

На выходе я получаю содержимое заголовка родительской. html страницы. Но похоже, что он не вызывает lex-web-ui-loader. js. Я не уверен, где я go ошибаюсь.

1 Ответ

0 голосов
/ 21 июля 2020

Я указал неверный путь. Я указал файл загрузчика lex-web-ui-loader. js в правильное место внутри моей папки, и он сработал.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...