33> Sample Amazon Lex Web Interface
44
55## Overview
6- This repository provides a sample [ Amazon Lex] ( https://aws.amazon.com/lex/ )
7- web interface that can be integrated in your website. This web interface
8- allows to interact with a Lex bot directly from a browser using by text
9- or voice (from a webRTC capable browser).
10- Here is a screenshot of it:
6+ This is a sample [ Amazon Lex] ( https://aws.amazon.com/lex/ )
7+ web interface. It provides a chatbot UI component that can be integrated
8+ in your website. The interface allows to interact with a Lex bot directly
9+ from a browser using text or voice (on webRTC capable browsers).
1110
12- <img src =" ./img/webapp-screenshot.png " width =480 >
11+ ## Quick Launch
12+ Click the button below to test drive this project using
13+ [ AWS Mobile Hub] ( https://aws.amazon.com/mobile/ ) .
14+ It will deploy the chatbot UI to
15+ [ S3] ( https://aws.amazon.com/s3/ ) and
16+ [ CloudFront] ( https://aws.amazon.com/cloudfront/ ) . It also deploys
17+ the sample [ Order Flowers Lex bot] ( http://docs.aws.amazon.com/lex/latest/dg/gs-bp-create-bot.html )
18+ automatically for you.
19+
20+ <p >
21+ <a target =" _blank " href =" https://console.aws.amazon.com/mobilehub/home?#/?config=https://github.com/awslabs/aws-lex-web-ui/blob/master/dist/lex-web-ui-mobile-hub.zip " >
22+ <span >
23+ <img height="100%" src="https://s3.amazonaws.com/deploytomh/button-deploy-aws-mh.png"/>
24+ </span >
25+ </a >
26+ </p >
27+
28+ ** NOTE** : If the Mobile Hub deployed site causes the browser to download
29+ the files instead of rendering it, you can re-upload the files to the
30+ S3 bucket using the S3 console or aws cli.
1331
1432## Integrating into your Site
15- You can consume this project as a library that renders the chatbot
16- UI component in your site. The library can be included in your web
17- application by importing it as a module in a
18- [ webpack] ( https://webpack.github.io/ )
19- based project or by directly sourcing it in an HTML ` <script> ` tag.
20- Additionally, this project provides a set of
21- [ AWS CloudFormation] ( https://aws.amazon.com/cloudformation/ ) templates
22- that can be used to automatically build and deploy the chatbot UI and
23- related resources.
24-
25- ### Script Tag
26- This project provides a pre-built version of the library under the
27- [ dist] ( dist ) directory. You can copy the JavaScript and CSS files from
28- that directory to your web server and use them to load the chatbot
29- UI. Similarly, for quick testing, you could directly source the library
30- and other dependencies from a CDN distribution.
31-
32- You would need to pass required parameters such as the
33- [ Amazon Cognito Identity Pool] ( http://docs.aws.amazon.com/cognito/latest/developerguide/identity-pools.html ) and Lex bot when you instantiate the
34- component. See an example here: [ index.html] ( dist/index.html ) .
33+ This project provides a sample page showing how to load the chatbot
34+ UI and related dependencies in a full page. There is also a sample
35+ page showing how to load the chatbot UI into an existing site
36+ using an iframe. These pages and their configuration can be
37+ automatically deployed using the Mobile Hub button above.
38+
39+ This project also provides a set of
40+ [ AWS CloudFormation] ( https://aws.amazon.com/cloudformation/ )
41+ templates that can be used to automatically build and deploy the chatbot
42+ UI and related resources. Additionally, you can consume this project as an
43+ [ npm] ( https://www.npmjs.com/ ) package that provides a component library.
44+
45+
46+ ### Full Page
47+ To display the chatbot UI as a full page, you can use the JavaScript
48+ and CSS files in the [ dist] ( dist ) directory. You can copy those files
49+ to your web server or host them in an S3 bucket. The JavaScript and CSS
50+ can be loaded in a web page by including them with ` script ` and ` link `
51+ HTML tags.
52+
53+ <img src =" ./img/webapp-full.gif " width =600 >
54+
55+ The chatbot UI component depends on libraries that should also be
56+ loaded in the page. For quick testing, you could directly source these
57+ dependencies from a CDN distribution. A sample page illustrating this
58+ setup is found in here: [ index.html] ( src/website/index.html ) .
59+
60+ #### Configuration
61+ You need to pass the chatbot UI configuration including
62+ required parameters such as the [ Amazon Cognito Identity
63+ Pool] ( http://docs.aws.amazon.com/cognito/latest/developerguide/identity-pools.html )
64+ and Lex bot name. The [ index.html] ( src/website/index.html )
65+ sample page loads this configuration from the both the
66+ [ bot-config.json] ( src/config/bot-config.json ) and Mobile Hub AWS SDK
67+ [ aws-config.js] ( src/config/aws-config.js ) files. You can modify the values
68+ in those files to change the chatbot UI configuration. When deploying
69+ with Mobile Hub or with the CloudFormation templates described below,
70+ the configuration will be done automatically for you. For details about
71+ the component configuration, see the
72+ [ Configuration and Customization] ( https://github.com/awslabs/aws-lex-web-ui/tree/master/lex-web-ui#configuration-and-customization )
73+ section of its README file.
74+
75+ #### Running Locally
76+ If you want to quickly test the [ src/website] ( src/website ) pages on
77+ your local host, modify the values in the ` bot-config.json ` and/or
78+ ` aws-config.js ` files under the ` src/config ` directory. Specifically,
79+ you would need to pass a Cognito Pool Id and Lex Bot name. If
80+ you deploy the site using Mobile Hub or CloudFormation, you can
81+ copy the configuration files from the S3 buckets automatically
82+ created in there. After you setup the configuration files in
83+ the ` src/config ` directory, issue the command: ` npm start ` . For
84+ a more advanced local host test, see the
85+ [ Dependencies and Build Setup] ( https://github.com/awslabs/aws-lex-web-ui/tree/master/lex-web-ui#dependencies-and-build-setup )
86+ documentation of the component.
87+
88+ ### Iframe
89+ You can embed the * Full Page* setup described above in an iframe to
90+ display it on your site as a chatbot widget. This project provides a
91+ sample page showing this setup here:
92+ [ parent.html] ( src/website/parent.html ) . This includes a loader script
93+ that creates an API between the iframe and the parent page. For details,
94+ see its:
95+ [ README] ( https://github.com/awslabs/aws-lex-web-ui/tree/master/lex-web-ui/static/iframe ) .
96+
97+ <img src =" ./img/webapp-iframe.gif " width =600 >
3598
3699### Npm Install
37100You can use the [ npm] ( https://docs.npmjs.com/ )
38101command to install this project. The npm install provides a library that
39- you can import as a module into your JavaScript code.
102+ you can import as a module into your JavaScript code. The library can
103+ be npm installed in your web application and imported as a module in a
104+ [ webpack] ( https://webpack.github.io/ ) based project. The component is
105+ built as a reusable [ Vue.JS] ( https://vuejs.org/ ) plugin. The library
106+ bundle files are found under the [ dist] ( dist ) directory.
107+
40108
41109Package installation using ` npm ` :
42110
@@ -55,6 +123,8 @@ You can then import the library in your project:
55123import LexWebUi from ' aws-lex-web-ui' ;
56124// or using require
57125var LexWebUi = require (' aws-lex-web-ui' );
126+ // import the debug non-minimized version
127+ import LexWebUi from ' aws-lex-web-ui/dist/lex-web-ui' ;
58128```
59129
60130### CloudFormation Deployment
@@ -64,6 +134,7 @@ the accompanying [templates](templates) directory and its
64134
65135## Details
66136The source of the chatbot UI component resides under the
67- [ lex-web-ui] ( lex-web-ui ) directory. The library provided here packages
68- this component and distributes it as a pre-built library. For details
69- about the chatbot UI component, see its [ README] ( lex-web-ui/README.md )
137+ [ lex-web-ui] ( lex-web-ui ) directory. The library provided in the
138+ [ dist] ( dist ) directory packages this component and distributes it as
139+ a pre-built bundle. For details about the chatbot UI component and its
140+ configuration, see its [ README] ( lex-web-ui/README.md ) file.
0 commit comments