Skip to content

Commit cd9fc34

Browse files
authored
Merge pull request #705 from aws-samples/development
Version 0.20.4
2 parents f44b371 + e0f7c50 commit cd9fc34

31 files changed

+1483
-2250
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7-
## [0.21.2] - 2024-06-27
7+
## [0.21.4] - 2024-07-15
8+
- The Lex Web UI can now act as a passthrough for Q Business, allowing users to converse directly with their Q Business application while inheriting all the features of the Web UI such as embedding, CSS customizations and more.
9+
- Upgraded version of amazon-connect-chatjs
10+
11+
## [0.21.3] - 2024-06-27
812
- Dependency & documentation updates
913
- Fixed a bug that was causing builds on Windows machines to fail
1014

README-qbusiness.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Amazon Q Business Integration
2+
3+
Amazon Q is a new generative AI-powered application that helps users get work done. Amazon Q can become your tailored business expert and let you discover content, brainstorm ideas, or create summaries using your company’s data safely and securely. For more information see: [Introducing Amazon Q, a new generative AI-powered assistant](https://aws.amazon.com/blogs/aws/introducing-amazon-q-a-new-generative-ai-powered-assistant-preview)
4+
5+
This feature of the Web UI lets you use Amazon Q's generative AI directly with the Web UI, using a deployed sample bot as a passthrough to the Q Business application. This allows your solution to take advantage of the native Web UI features - embedding, customization, etc - while still leveraging the answering capabilities of Amazon Q.
6+
7+
This feature supports integration with file attachments, enable both to allow QBusiness to read files uploaded via Lex Web UI. There's more information on this feature in the [File Upload README](https://github.com/aws-samples/aws-lex-web-ui/blob/master/README-file-upload.md).
8+
9+
**Note:*** - The default deployed solution will return a failure message if the user is not logged in or does not have a valid Q Business subscription. This can be customized in the Fulfilment Lambda that is deployed by the CloudFormation template.
10+
11+
### Prerequisites
12+
1. An existing deployment of a Q Business application is required for this solution. Please reference the AWS docs for creating a new [Q Business application](https://docs.aws.amazon.com/amazonq/latest/qbusiness-ug/create-application.html)
13+
14+
### Deploy the Web UI
15+
1. A deployment of the Lex Web UI with login enabled is required for Q Business integration. To launch a new
16+
17+
2. The other bot fields for both V1 & V2 bots must be empty for the template to create the Q Business integration bot, please ensure that `Lex V1 Bot Configuration Parameters` and `Lex V2 Bot Configuration Parameters` are blank.
18+
19+
3. To enable login, set `EnableCognitoLogin` to true. To force users to login to your bot, set `ForceCognitoLogin` to true. The ForceCognitoLogin setting will automatically redirect users to the login page if they are not logged in to the bot.
20+
21+
4. In the `Q Business Parameters` section of the template, provide the Amazon Q Application ID. For now, leave the 'IDCApplicationARN' field blank. This application must be created after Cognito is deployed by the initial Web UI deployment and the stack can be updated later to provide this value.
22+
23+
5. Deploy the stack.
24+
25+
6. When the stack is finished deploying (showing a CREATE_COMPLETE status) go the Outputs tab. You will need the following Outputs for setting up the Identity Center Application:
26+
- CognitoUserPoolClientId
27+
- CognitoUserPoolPubKey
28+
- QBusinessLambdaRoleARN
29+
30+
### Creating an Trusted token issuer in Identity Center
31+
32+
1. The Cognito user pool created by the Web UI will need to be added as **Trusted token issuer** to Identity Center by doing the following steps. Note that if you are not an admin in your organization, an administrator with Identiy Center access might need to create the token issuer and application.
33+
1. Go to Identity Center and click on `Settings`, click the `Authentication` tab and then scroll down and select `Create trusted token issuer`
34+
2. The issuer URL will be the **CognitoUserPoolPubKey, but remove /.well-known/jwks.json from the end of the URL**, the issuer URL you supply shoudl be in the form of `https://cognito-idp.[region].amazonaws.com/[cognito-pool-id]`. The application also needs to be provided with attribute mapping between Identity Center and Cognito to recognize users, this should be a unique attribute for each user (the default is email address)
35+
![Issuer](./img//token-issuer.PNG)
36+
3. With a trusted token issuer in place, the custom application can now be created.
37+
38+
### Creating a Identity Center Application w/ Cognito trust
39+
40+
1. A custom application will need to be created in Identity Center to handle the connection between your Q Business application and your Cognito pool. Follow these steps to create the application.
41+
1. Go to Identity Center and click on `Applications` then `Add application`
42+
2. Select `I have an application I want to set up` and `OAuth 2.0` on the next page for Selecting Application type, then hit `Next`
43+
3. For `Application URL`, provide the **Web experience URL** of your Q Business application. You can either opt to assign specific users/groups to this application or allow any Identity Center users/groups to access the application. Your Q Business subscriptions will still apply however so only users with a subscription can successfully chat with the application. Then hit `Next`.
44+
4. Select the Trusted token issuer that was created in Step 2 of this guide, you will now need an aud claim so that the token issuer can identify the application. The aud claim is the **CognitoUserPoolClientId** output value from the Web UI stack. Take this value and paste it into the aud claim field, then select `Next`
45+
![Claim](./img//aud-claim.PNG)
46+
5. Under `Enter IAM roles`, take the role that was created by the Web UI stack for the QBusiness Lambda function. This is the **QBusinessLambdaRoleARN**. Paste this value into field and select `Next`.
47+
6. Hit `Submit` to complete creation of the application.
48+
7. The application is accessible under the `customer managed` tab of the Identity Center applications. Select the just created application to make changes.
49+
8. Depending on the selection in step 3 above, users may still need to be assigned to the application. These will be the same users you have assigned to the Q Business application.
50+
7. Finally, make Amazon Q a trusted application for identity propagation by selecting `Specify trusted applications` and finding QBusiness in the list of potential application for trust. When complete your app should appear similar to the below configuration
51+
![IdentityPropagation](./img//identity-propagation.PNG)
52+
8. Copy the `Application ARN` found on this page, it will be used to update the Lex Web UI stack.
53+
54+
### Adding users to Cognito
55+
56+
1. Any user who has a Q Business subscription will need a user account in Cognito, linked by the attribute mapping defined when the `Trusted token issuer` was created.
57+
2. These users can be added manually or by integrating it via [SAML to a 3rd party provider](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-integrating-3rd-party-saml-providers.html).
58+
59+
60+
### Update the Lex Web UI stack
61+
62+
1. Return to CloudFormation and click on the stack that was initially used to deploy the Web UI.
63+
2. On the top-right menu, select `Update`
64+
3. Leave the default of 'Use existing template' and hit `Next`
65+
4. Under Q Business Parameters, find the **IDCApplicationARN** and paste the `Application ARN` copied at the end of the previous section.
66+
5. Launch the update of the stack.
67+
68+
## Validate deployment
69+
70+
Your deployment of the Web UI should now talk directly to Amazon Q Business and return the same responses as the default web experience. In addition, by turning on upload capabilities you can ask Q Business questions about documents and get GenAI answers.
71+
72+
![QBusinessDemo](./img//QBusiness.gif)

build/Makefile

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ VPATH := $(OUT)
2121

2222
# upload files to bootstrap bucket
2323
# NOTE: files uploaded with public read permissions
24-
upload: upload-templates upload-custom-resources-zip upload-src-zip \
25-
upload-response-card-image upload-initiate-chat-lambda upload-streaming-lambda
24+
upload: upload-templates upload-src-zip upload-response-card-image \
25+
upload-initiate-chat-lambda upload-streaming-lambda upload-qbusiness-lambda
2626
.PHONY: upload
2727

2828
# create the output directory for tracking dependencies
@@ -39,34 +39,6 @@ upload-templates: $(TEMPLATES) | $(OUT)
3939
| tee "$(OUT)/$(@)"
4040
@echo "[INFO] master template: https://s3.amazonaws.com/$(BOOTSTRAP_BUCKET_PATH)/templates/master.yaml"
4141

42-
# cfn custom resource lambda files are found under this directory
43-
CUSTOM_RESOURCES_DIR := $(TEMPLATES_DIR)/custom-resources
44-
45-
# zip cfn custom resource lambda files
46-
BOT_DEFINITION_FILE := $(CUSTOM_RESOURCES_DIR)/bot-definition.json
47-
PY_MODULES := $(CUSTOM_RESOURCES_DIR)/py_modules
48-
CUSTOM_RESOURCES_ZIP := custom-resources-$(VERSION).zip
49-
CUSTOM_RESOURCES_FILES := $(wildcard $(CUSTOM_RESOURCES_DIR)/*.py)
50-
CUSTOM_RESOURCES_FILES += $(BOT_DEFINITION_FILE)
51-
CUSTOM_RESOURCES_FILES += $(PY_MODULES)
52-
$(PY_MODULES):
53-
pushd $(CUSTOM_RESOURCES_DIR) ; \
54-
[ -f requirements.txt ] && \
55-
python3 -m pip install --upgrade -r requirements.txt -t ./py_modules || true ; \
56-
popd ;
57-
$(CUSTOM_RESOURCES_ZIP): $(CUSTOM_RESOURCES_FILES) | $(OUT)
58-
@echo "[INFO] Creating custom resource Lambda zip file"
59-
zip -u -j "$(OUT)/$(@)" $(?) ; \
60-
pushd $(CUSTOM_RESOURCES_DIR)/py_modules ; \
61-
zip -r -q "../../../build/$(OUT)/$(@)" . ; \
62-
popd ;
63-
upload-custom-resources-zip: $(CUSTOM_RESOURCES_ZIP) | $(OUT)
64-
@echo "[INFO] Uploading custom resources Lambda zip file"
65-
aws s3 cp --acl public-read \
66-
"$(OUT)/$(CUSTOM_RESOURCES_ZIP)" \
67-
"s3://$(BOOTSTRAP_BUCKET_PATH)/$(CUSTOM_RESOURCES_ZIP)" \
68-
| tee -a "$(OUT)/$(@)"
69-
7042
# initiate chat lambda function
7143

7244
INITIATE_CHAT_LAMBDA_DIR := $(SOURCE_DIR)/initiate-chat-lambda
@@ -99,6 +71,20 @@ upload-streaming-lambda:
9971
"$(OUT)/$(STREAMING_LAMBDA_ZIP)" "s3://$(BOOTSTRAP_BUCKET_PATH)/$(STREAMING_LAMBDA_ZIP)" \
10072
| tee -a "$(OUT)/$(@)"
10173

74+
QBUSINESS_LAMBDA_DIR := $(SOURCE_DIR)/qbusiness-lambda
75+
QBUSINESS_LAMBDA_ZIP := qbusiness-lambda-$(VERSION).zip
76+
QBUSINESS_LAMBDA_RESOURCES_FILES := $(wildcard $(QBUSINESS_LAMBDA_DIR)/*.py)
77+
78+
$(QBUSINESS_LAMBDA_ZIP): $(QBUSINESS_LAMBDA_DIR)/index.py
79+
@echo "[INFO] Creating qbusiness Lambda zip file"
80+
zip -r -j "$(OUT)/$(QBUSINESS_LAMBDA_ZIP)" $(QBUSINESS_LAMBDA_DIR) ;
81+
82+
upload-qbusiness-lambda:
83+
@echo "[INFO] uploading qbusiness lambda"
84+
aws s3 cp --acl public-read \
85+
"$(OUT)/$(QBUSINESS_LAMBDA_ZIP)" "s3://$(BOOTSTRAP_BUCKET_PATH)/$(QBUSINESS_LAMBDA_ZIP)" \
86+
| tee -a "$(OUT)/$(@)"
87+
10288
# files in this repo are bundled in a zip file to boostrap the codecommit repo
10389
SRC_ZIP := src-$(VERSION).zip
10490
SRC_FILES := $(shell git ls-files ..)

build/release.sh

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@ case $unamestr in
77
"Darwin" | "FreeBSD")
88
sed -i '' -e "s/(v.*)/($VERSION)/g" \
99
-e "s/Timestamp:.*/Timestamp: $timestamp/g" \
10-
-e "s/custom-resources-.*zip/custom-resources-$VERSION.zip/g" \
1110
-e "s/src-.*zip/src-$VERSION.zip/g" \
1211
-e "s/initiate-chat-lambda-.*zip/initiate-chat-lambda-$VERSION.zip/g" \
1312
../templates/master.yaml;
1413

1514
sed -i '' -e "s/(v.*)/($VERSION)/g" \
1615
-e "s/Timestamp:.*/Timestamp: $timestamp/g" \
17-
-e "s/custom-resources-.*zip/custom-resources-$VERSION.zip/g" \
1816
-e "s/src-.*zip/src-$VERSION.zip/g" \
1917
-e "s/initiate-chat-lambda-.*zip/initiate-chat-lambda-$VERSION.zip/g" \
2018
../templates/master-pipeline.yaml;;
@@ -25,15 +23,15 @@ sed -i -e "s/(v.*)/($VERSION)/g" \
2523
-e "s/src-.*zip/src-$VERSION.zip/g" \
2624
-e "s/initiate-chat-lambda-.*zip/initiate-chat-lambda-$VERSION.zip/g" \
2725
-e "s/streaming-lambda-.*zip/streaming-lambda-$VERSION.zip/g" \
28-
-e "s/custom-resources-.*zip/custom-resources-$VERSION.zip/g" \
26+
-e "s/qbusiness-lambda-.*zip/qbusiness-lambda-$VERSION.zip/g" \
2927
../templates/master.yaml;
3028

3129
sed -i -e "s/(v.*)/($VERSION)/g" \
3230
-e "s/Timestamp:.*/Timestamp: $timestamp/g" \
33-
-e "s/custom-resources-.*zip/custom-resources-$VERSION.zip/g" \
3431
-e "s/src-.*zip/src-$VERSION.zip/g" \
3532
-e "s/initiate-chat-lambda-.*zip/initiate-chat-lambda-$VERSION.zip/g" \
3633
-e "s/streaming-lambda-.*zip/streaming-lambda-$VERSION.zip/g" \
34+
-e "s/streaming-lambda-.*zip/qbusiness-lambda-$VERSION.zip/g" \
3735
../templates/master-pipeline.yaml;;
3836

3937
*)
@@ -42,15 +40,15 @@ sed -i -e "s/(v.*)/($VERSION)/g" \
4240
-e "s/src-.*zip/src-$VERSION.zip/g" \
4341
-e "s/initiate-chat-lambda-.*zip/initiate-chat-lambda-$VERSION.zip/g" \
4442
-e "s/streaming-lambda-.*zip/streaming-lambda-$VERSION.zip/g" \
45-
-e "s/custom-resources-.*zip/custom-resources-$VERSION.zip/g" \
43+
-e "s/qbusiness-lambda-.*zip/qbusiness-lambda-$VERSION.zip/g" \
4644
../templates/master.yaml;
4745

4846
sed -i -e "s/(v.*)/($VERSION)/g" \
4947
-e "s/Timestamp:.*/Timestamp: $timestamp/g" \
50-
-e "s/custom-resources-.*zip/custom-resources-$VERSION.zip/g" \
5148
-e "s/src-.*zip/src-$VERSION.zip/g" \
5249
-e "s/initiate-chat-lambda-.*zip/initiate-chat-lambda-$VERSION.zip/g" \
5350
-e "s/streaming-lambda-.*zip/streaming-lambda-$VERSION.zip/g" \
51+
-e "s/qbusiness-lambda-.*zip/qbusiness-lambda-$VERSION.zip/g" \
5452
../templates/master-pipeline.yaml;;
5553

5654

@@ -61,9 +59,9 @@ npm run build-dist
6159
cd ..
6260
make
6361
cd build
64-
make "custom-resources-$VERSION.zip"
6562
make "initiate-chat-lambda-$VERSION.zip"
6663
make "streaming-lambda-$VERSION.zip"
64+
make "qbusiness-lambda-$VERSION.zip"
6765
cd ..
6866
cd dist
6967
make

build/upload-bootstrap.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,19 @@ popd
2626
aws s3 cp out/src-$version.zip \
2727
"s3://${BOOTSTRAP_BUCKET_PATH}/src-$version.zip"
2828

29-
aws s3 cp out/custom-resources-$version.zip \
30-
"s3://${BOOTSTRAP_BUCKET_PATH}/custom-resources-$version.zip"
31-
3229
aws s3 cp out/initiate-chat-lambda-$version.zip \
3330
"s3://${BOOTSTRAP_BUCKET_PATH}/initiate-chat-lambda-$version.zip"
3431

3532
aws s3 cp out/streaming-lambda-$version.zip \
3633
"s3://${BOOTSTRAP_BUCKET_PATH}/streaming-lambda-$version.zip"
3734

35+
aws s3 cp out/qbusiness-lambda-$version.zip \
36+
"s3://${BOOTSTRAP_BUCKET_PATH}/qbusiness-lambda-$version.zip"
37+
3838
aws s3 sync --exclude "*" --include "*.yaml" \
3939
../templates "s3://${BOOTSTRAP_BUCKET_PATH}/templates/"
4040

41+
aws s3 cp ..templates/layers.zip \
42+
"s3://${BOOTSTRAP_BUCKET_PATH}/layers.zip"
43+
4144
echo "[INFO] master template: https://s3.amazonaws.com/${BOOTSTRAP_BUCKET_PATH}/templates/master.yaml"

dist/lex-web-ui-loader.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/lex-web-ui-loader.min.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* lex-web-ui v0.21.3
2+
* lex-web-ui v0.21.4
33
* (c) 2017-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
44
* Released under the Amazon Software License.
55
*/

dist/lex-web-ui.min.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/wav-worker.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/wav-worker.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

img/QBusiness.gif

3.63 MB
Loading

img/aud-claim.PNG

68.1 KB
Loading

img/identity-propagation.PNG

105 KB
Loading

img/token-issuer.PNG

127 KB
Loading

0 commit comments

Comments
 (0)