Amazon lex-chatbot-not 能够使用预定义的库进行嵌入
Amazon lex-chatbot-not able to embed using predefined libraries
我已经开发了聊天机器人,并希望在 website.I 之后集成到 github link 中,它具有用于 chatbotUI 的预定义库以作为 iframe 嵌入。 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>
我转到 parent.html(几乎与上面的代码类似)在 src/website/parent.html 文件夹的 github 中,并对 srcipt src 路径进行了更改, cognito poolid 和 lex name 参考上面的代码。
1) 在上面代码中的配置 url 中,我不知道要为 chatbot-ui-loader-config 提供什么路径。json.There 在 dist [ 中没有这样的 json 文件=32=] 我自己创建?
2)我使用 EC2 linux instance.I 创建了一个网站,在我的 var/www/html.Inside 中有我的索引文件和 aws-lex-web-ui(github 文件夹)索引文件,我调用aws-lex-web-ui的parent.htmlfolder.Is这个方法正确吗?
在输出中我得到 parent .html 页面的标题内容。但它似乎没有调用 lex-web-ui-loader.js 。我不确定我要去哪里错了。
我给了一个错误的路径。我将加载程序文件 lex-web-ui-loader.js 指向我文件夹中的正确位置并且它起作用了。
我已经开发了聊天机器人,并希望在 website.I 之后集成到 github link 中,它具有用于 chatbotUI 的预定义库以作为 iframe 嵌入。 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>
我转到 parent.html(几乎与上面的代码类似)在 src/website/parent.html 文件夹的 github 中,并对 srcipt src 路径进行了更改, cognito poolid 和 lex name 参考上面的代码。
1) 在上面代码中的配置 url 中,我不知道要为 chatbot-ui-loader-config 提供什么路径。json.There 在 dist [ 中没有这样的 json 文件=32=] 我自己创建?
2)我使用 EC2 linux instance.I 创建了一个网站,在我的 var/www/html.Inside 中有我的索引文件和 aws-lex-web-ui(github 文件夹)索引文件,我调用aws-lex-web-ui的parent.htmlfolder.Is这个方法正确吗?
在输出中我得到 parent .html 页面的标题内容。但它似乎没有调用 lex-web-ui-loader.js 。我不确定我要去哪里错了。
我给了一个错误的路径。我将加载程序文件 lex-web-ui-loader.js 指向我文件夹中的正确位置并且它起作用了。