Giter Club home page Giter Club logo

aws-solutions / qnabot-on-aws Goto Github PK

View Code? Open in Web Editor NEW
374.0 50.0 242.0 182.09 MB

AWS QnABot is a multi-channel, multi-language conversational interface (chatbot) that responds to your customer's questions, answers, and feedback. The solution allows you to deploy a fully functional chatbot across multiple channels including chat, voice, SMS and Amazon Alexa.

Home Page: https://aws.amazon.com/solutions/implementations/aws-qnabot

License: Apache License 2.0

Makefile 0.31% Shell 0.76% JavaScript 78.63% CSS 0.13% HTML 0.21% Vue 4.35% Python 15.48% Handlebars 0.02% SCSS 0.08% Pug 0.02% Stylus 0.01% EJS 0.01%
machine-learning artificial-intelligence amazon-lex

qnabot-on-aws's Introduction

QnABot on AWS

Overview

QnABot on AWS is a multi-channel, multi-language conversational interface (chatbot) that responds to your customer’s questions, answers, and feedback. It allows you to deploy a fully functional chatbot across multiple channels including chat, voice, SMS, and Amazon Alexa. The solution’s content management environment, and contact center integration wizard allow you to set up and customize an environment that provides the following benefits:

  • Enhance your customer’s experience by providing personalized tutorials and question and answer support with intelligent multi-part interaction

  • Reduce call center wait times by automating customer support workflows

  • Implement the latest machine learning technology to create engaging, human-like interactions for chatbots

Architecture Overview

Deploying this solution with the default parameters deploys the following components in your AWS account (bordered components are optional).

Architecture

Figure 1: QnABot on AWS architecture

The high-level process flow for the solution components deployed with the AWS CloudFormation template is as follows:

  1. The admin deploys the solution into their AWS account, opens the Content Designer UI or Amazon Lex web client, and uses Amazon Cognito to authenticate.

  2. After authentication, Amazon API Gateway and Amazon S3 deliver the contents of the Content Designer UI.

  3. The admin configures questions and answers in the Content Designer and the UI sends requests to Amazon API Gateway to save the questions and answers.

  4. The Content Designer AWS Lambda function saves the input in Amazon OpenSearch Service in a questions bank index. If using text embeddings, these requests will first pass through a ML model hosted on Amazon SageMaker to generate embeddings before being saved into the question bank on OpenSearch.

  5. Users of the chatbot interact with Amazon Lex via the web client UI, Amazon Alexa or Amazon Connect.

  6. Amazon Lex forwards requests to the Bot Fulfillment AWS Lambda function. Users can also send requests to this Lambda function via Amazon Alexa devices.

  7. The Bot Fulfillment AWS Lambda function takes the users input and uses Amazon Comprehend and Amazon Translate (if necessary) to translate non-Native Language requests to the Native Language selected by the user during the deployment and then looks up the answer in in Amazon OpenSearch Service. If using LLM features such as text generation and text embeddings, these requests will first pass through various ML models hosted on Amazon SageMaker to generate the search query and embeddings to compare with those saved in the question bank on OpenSearch.

  8. If an Amazon Kendra index is configured for fallback, the Bot Fulfillment AWS Lambda function forwards the request to Kendra if no matches were returned from the OpenSearch question bank. The text generation LLM can optionally be used to create the search query and to synthesize a response given the returned document excerpts.

  9. User interactions with the Bot Fulfillment function generate logs and metrics data, which is sent to Amazon Kinesis Data Firehose then to Amazon S3 for later data analysis.

Refer to the implementation guide for detailed instructions on deploying QnABot in your AWS account.

Alternatively, if you want to custom deploy QnABot on AWS, refer to the details below.

Custom deployment of QnABot on AWS

Environment Prerequisites

  • Run Linux. (tested on Amazon Linux)
  • Install npm >8.6.0 and node >18.X.X (instructions)
  • Install and configure git lfs (instructions)
  • Clone this repo.
  • Set up an AWS account. (instructions)
  • Configure AWS CLI and a local credentials file. (instructions)

Build a version

Navigate to the root directory of QnABot (directory will be created once you have cloned this repo).

Install node.js modules of QnABot:

npm install

Next, set up your configuration file:

npm run config

now edit config.json for the following parameters:

param description
region the AWS region to launch stacks in
profile the AWS credential profile to use
namespace a logical name space to run your templates in such as dev, test and/or prod
devEmail(required) the email to use when creating admin users in automated stack launches

Next, use the following command to launch a CloudFormation template to create the S3 bucket to be used for Lambda code and CloudFormation templates. Wait for this template to complete (you can watch progress from the command line or AWS CloudFormation console)

npm run bootstrap

Finally, use the following command to launch template to deploy the QnABot in your AWS account. When the stack has completed you will be able to log into the Designer UI (The URL is an output of the template). A temporary password to the email in your config.json:

npm run up

If you have an existing stack you can run the following to update your stack:

npm run update

Testing

Running Unit Tests

To run unit tests execute the following command from the root folder:

npm test

To update the test snapshots when modifying the /website or /templates directory, execute the following command:

npm run test:update:snapshot

Running Regression Tests

NOTE: Running regression tests will create, modify, and delete content and settings from the Content Designer. Only run regression tests on non-production bots where loss or modification of content and settings is acceptable.

This runs integration tests against a deployed QnABot deployment in your account. Before running the tests follow the above steps to build and deploy a version or deploy using the template from the QnABot landing page: Launch QnABot.

  1. Start from the /.nightswatch directory:
cd .nightswatch
  1. Install the dependencies of the automated testing:
brew install python@3
brew install geckodriver
brew install --cask chromedriver
pip3 install virtualenv
  1. Set up a virtual environment for testing, and install the project dependencies into it.
python3 -m virtualenv venv
source ./venv/bin/activate
pip install -r requirements.txt
  1. Ensure you are logged in to the AWS CLI.

Set the following environment variables to point to the a QnA Bot deployment under test:

export CURRENT_STACK_REGION='<QNA BOT Region>'
export CURRENT_STACK_NAME='<QNA BOT Cloudformation Stack Name>'
export EMAIL='<admin user e-mail>

Optionally provide a username and password for an Admin user to test with. If these environment variables are not set then a default 'QnaAdmin' user will be created during the initial test. If you want to run a specific test then provide a username since the default user will only be created in the initial test.

export USER='<QNA BOT existing admin user>'
export PASSWORD='<QNA BOT existing admin password>'

If you'd like to launch the browser while running tests then also set the below env variable:

export HEADLESS_BROWSER='false'

If you'd like to see to start and end time for each test:

export TIMESTAMPS='true'
  1. The LLM and Kendra tests will only run if the deployed bot has these features enabled. Follow the steps in the Implementation Guide to enable these features to test them:
  • LLM
    • Set LLMApi to SAGEMAKER. For more information, please Enabling LLM support. If stack update fails, check your quota for ml.g5.12xlarge for endpoint usage as mentioned in the note of this article.
  • Kendra
    • Create an index and note the Index ID. For IAM role, you can create a custom new role for this from the dropdown. Creating an index
    • Update deployed stack's parameter DefaultKendraIndexId with Index ID created in the previous step.
  1. Run the regression tests from within the test folder:
cd functional
pytest -v

Publishing

Power users interested in releasing a custom QnABot can use the following instructions for publishing the deployment artifacts available to external users.

Create an S3 bucket to host the templates from (see $DIST_OUTPUT_BUCKET below). You will also need regional buckets for each region your users will deploy from. The regional buckets must be named $DIST_OUTPUT_BUCKET-$AWS_REGION. You will need to provide appropriate access permissions to the buckets for your targeted users. Please refer to the below links for buckets security and access control best practices:

NOTE: All buckets must have versioning enabled, otherwise the stack will fail to deploy.

Set the following environment variables for your custom QnABot:

export DIST_OUTPUT_BUCKET='<name of the bucket to upload artifacts to>'
export SOLUTION_NAME='<name of your custom bot>'
export VERSION='<bot version>'
export AWS_REGIONS=("us-east-1" "us-west-2" "ap-southeast-1" "ap-southeast-2" "ca-central-1" "eu-west-1" "ap-northeast-1" "eu-central-1" "eu-west-2" "ap-northeast-2")

The above variables will determine the bucket URL path where your bot will be hosted from. The AWS_REGIONS array is a list of all regions QnABot supports. The list can be modified as necessary if your bot version will not be deployed in certain regions.

Run the following commands to upload the current local version to the specified bucket:

cd deployment
./build-s3-dist.sh $DIST_OUTPUT_BUCKET $SOLUTION_NAME $VERSION
aws s3 cp global-s3-assets/  s3://$DIST_OUTPUT_BUCKET/$SOLUTION_NAME/$VERSION/ --recursive --acl bucket-owner-full-control

Create S3 buckets for each region if they do not already exist. These buckets will need to be configured for public use:

for region in "${AWS_REGIONS[@]}";
do
  if aws s3api head-bucket --bucket "$DIST_OUTPUT_BUCKET-$region" 2>/dev/null
  then 
    echo "Bucket exists: s3://$DIST_OUTPUT_BUCKET-$region"
  else 
    aws s3api create-bucket --bucket "$DIST_OUTPUT_BUCKET-$region"
    echo "Created bucket: s3://$DIST_OUTPUT_BUCKET-$region"
  fi
done

Run the below command for each region:

for region in "${AWS_REGIONS[@]}";
do
  if aws s3api head-bucket --bucket "$DIST_OUTPUT_BUCKET-$region" 2>/dev/null
  then 
    aws s3 cp regional-s3-assets/ s3://$DIST_OUTPUT_BUCKET-$region/$SOLUTION_NAME/$VERSION/ --recursive --acl bucket-owner-full-control 
  else 
    echo "Bucket not found: s3://$DIST_OUTPUT_BUCKET-$region"
  fi
done

The template can be deployed from the following URL for all regions:

echo https://$DIST_OUTPUT_BUCKET.s3.amazonaws.com/$SOLUTION_NAME/$VERSION/qnabot-on-aws-main.template

Publishing best practices

  1. Never overwrite a published artifact when it is available to external users. Increment the version to upload new artifacts and keep previous versions immutable. Enable bucket versioning to recover artifacts. You may also decide to have a 'latest' version which will always contain the latest version of your bot.
  2. After uploading the artifacts, deploy and test from the S3 URL before releasing to any external users.

Run Webpack in Development Mode

In order to run Webpack in Development Mode, make sure to have the following

  • Existing deployment of QnABot on AWS

Navigate to the root directory of QnABot (directory will be created once you have cloned this repo).

npm install

Next, assign the environment variable, ASSET_BUCKET_NAME located in package.json in the npm script dev mode. This is the name of the bucket QnABot loads ./website assets to and is usually named <stack-name>-bucket-<randomly-generated-chars>.

Once set up correctly, run

npm run dev-mode

This should set Webpack to development mode and upload assets in ./website/build to ASSET_BUCKET_NAME. This will also watch for any changes in ./website and reload assets into your bucket if the assets change.

Designer UI Compatibility

Currently the only browsers supported are:

  • Chrome
  • Firefox

Built With

License

Refer to LICENSE.txt file for details.

New features

Refer to CHANGELOG.md file for details of new features in each version.

A workshop is also available that walks you through QnABot features.

QnABot Deployable Solution Versions

As QnABot evolves over the years, it makes use of various services and functionality which may go in and out of support. This section serves as a reference to the deployable solution versions along with links to their Public and VPC CloudFormation templates.

Note: Deployable solution versions refers to the ability to deploy the version of QnABot in their AWS accounts. Actively supported versions for QnABot is only available for the latest version of QnABot.

Deployable Versions

Undeployable Versions

  • All solutions less than v5.2.1 are no longer deployable due to Lambda Runtime deprecations.

Upcoming/Recent deprecations

Why would a solution version no longer be deployable?

For QnABot, the most common reason is due to AWS Lambda Runtimes being deprecated. When a Lambda runtime has been marked as deprecated, customers can no longer create new Lambda functions in their AWS account. This means that older versions of our solutions that make use of those runtimes will fail to deploy. This makes it hard for the community to provide support as we are unable to deploy a similar environment to investigate issues and reproduce bug reports.

What should I do if my version of the solution is no longer deployable?

If you've currently got an existing deployment working for you, there is nothing requiring you to update. However, it is strongly recommended that you build a plan to test and migrate production deployments to a supported version. The further away a deployment gets from latest the greater risk it is at to experiencing instability (especially with regards to deployment).

And for those looking to get started with the solution for the first time, it is always recommended you use the latest version. It is the most secure, stable, and feature-rich version of QnABot!

How do I update my solution version?

In most cases, a simple Update Stack operation should allow you to migrate your instance onto a newer version while maintaining your data on the new deployment.

Note: For those upgrading from v5.4.X to later versions, if you are upgrading from a deployment with LLMApi set to SAGEMAKER then set this value to DISABLED before upgrading. After upgrading, return this value back to SAGEMAKER.

The team strongly recommends that any upgrades (especially between minor/major versions) first be tested on a non-production instance to check for any regressions. This is critical if you have made custom modifications to your deployment, integrate with external services, or are jumping between multiple versions.

Some additional precautions you can take are:

  • export all of your questions using the Content Designer UI (instructions)
  • export all of your settings using the Content Designer UI (click Export Settings at the bottom of settings page)
  • backup DynamoDB table (instructions)
  • create a manual snapshot of your OpenSearch Domain (instructions)

Anonymous Metrics

This solution collects anonymous operational metrics to help AWS improve the quality of features of the solution. For more information, including how to disable this capability, please see the implementation guide.


Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

qnabot-on-aws's People

Contributors

aassadza avatar abhirpat avatar bobpskier avatar chrislott avatar dependabot[bot] avatar dontirun avatar fhoueto-amz avatar gmerton-amazon avatar greengangsta avatar ihmaws avatar johncalhoun avatar karldthomas avatar knihit avatar marcburnie avatar michaelin-96 avatar mike-last avatar mikemlin avatar mobri2a avatar mohsenari avatar mssarriman avatar mvp-cloud avatar pdkn avatar rdoshi99 avatar rstrahan avatar selvadharmes avatar t-jones avatar tabdunabi avatar tim-su avatar tremaineeto avatar trindfus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qnabot-on-aws's Issues

Backup to S3

Support Backup (export) and restore (import) using S3 bucket to store backups.
Add ability to schedule backups.

Remember context and apply to subsequent follow-up questions

Add new optional item field 'Topic' to Content Designer UI ("t":"string")
When user asks unambiguous question, such as "What is Amazon Redshift", the context will be set (via session attribute) to the topic value of the matching document.
When user asks a follow up question, such as "What price is it?", the elasticsearch query will have an additional query field on matching the topic tag to the remembered context.
We need to correctly respond to a new unambiguous question that would force a change of topic, such as "What is Amazon Athena service". If the best answer comes from a new topic (in this example, Athena) we should reset the remembered topic context.

Import large files fails

Expected Behavior

Be able to import a large file

Actual Behavior

Currently the api fails with a "timeout or 10000s" error

Steps to Reproduce the Problem

  1. create a large import file( i used 888kb)
  2. try and upload through UI

Specifications

  • Version:dev

Lambda Arn in Designer UI

Add an optional field in the designer UI to specify the Question Handler lambda for a QnA document

Development branch: refreshing page should not cause log out

Expected Behavior

browser refresh should simply refresh, while keeping login context

Actual Behavior

browser refresh is logging out the session

image

Steps to Reproduce the Problem

  1. Login
  2. Hit browser refresh
  3. Observe how it makes you log in again

Import Error Issue

When attempting an import with a local file, if that file is not formatted properly, an error message (Invalid JSON) is displayed properly. However, from that point on, attempting to reimport will never try to load the file. The page must be reloaded before the import feature will work again. This was confusing as I worked to get the import file format correct, and couldn't understand what was happening even after I got the format right.

Add code of conduct

Should add a code of conduct document. I am not sure what would be the best choice

QnABot Lambda Extension Hooks

Purpose: Support (a) item navigation and (b) dynamic content in responses through QnABot extension hooks implemented as AWS lambda functions.
Implementation:

  1. Content Designer UI supports (optional) selection and assignment of existing Lambda function to any item. Function selection pick list filterable by function name substring or tag.
  2. When extension hook function is specified, QnABot handler will call the referenced function, passing as input:
    a. full session/intent context (utterance, session attributes, etc.)
    b. elasticsearch response containing all fields of all matched items
  3. The function will return a response object containing one of the following response types:
    a. reply: { <Lex/Alexa response object>}
    This gives complete control of bot response to the extension hook function, including voice, text, attachments, and session attributes.
    Use cases are many:
  • Dynamic responses of all sorts, for example: “When is the next race?”, “Will there be an event tomorrow?”, etc.
  • Navigate through ordered items, for example: “Where can I go now?”, “What’s the next topic?”, etc.
  • Dynamically look up answers from external sources
  • Log and respond to user feedback, eg: “That answer was no good”
  • Perform actions, eg: “Email me me a copy of that answer”
  • and much more – the possibilities are endless.
    b. redirect: { }
    This allows the extension hook function to redirect the QnABot handler to a different item, rather than providing a direct response to the current item.
    Use cases:
  • Auto navigation through guided content, for example: “Next item please” could redirect QnAbot to automatically query the next question in an ordered list of questions corresponding to a guided curriculum or tour.
  1. QnABot handler will
    a. passback a ‘reply’ response object from an extension hook to Lex/Alexa
    b. reenter handler with a new question contained in a ‘redirect’ response object
  2. QnABot handler should also preserve most recent previously asked question + matched item response in a session attribute, so that extension hook functions can access previous Q&A details for feedback logging and navigation purposes.
  3. Provide QnABot Lambda Extension hook ‘function blueprints’ to simplify and standardize:
    a. Logging of inputs and outputs
    b. Normalizing Lex and Alexa request objects
    c. Creating Lex and Alexa response objects

Support SSML

Please add the ability to support SSML in the responses.

Guided Navigation

Purpose: Use extension hook mechanism to support guided navigation, forward and backward, through an ordered list of items. Example use cases:

  • Using QnABot for a guided virtual tour or facilities or artifacts, user can say “next room please”, or “next item please”, and the extension function will redirect QnABot to answer the next question in the ordered list. Or “go back”, “Previous item” item to navigate backward in the list.
  • Using QnABot for training curricula, user can say “next topic please”, and the extension function will redirect QnABot to answer the next question in the ordered list of topic questions.

Implementation:

  1. Automatically derive default question order from list of items sorted by ID.
  2. Provide easy mechanism for user to supply custom ordered list of questions
    a. One way this could be done it to leverage the existing content designer to specifiy the ordered list of questions in a well-known QnA item ID, eg: ‘RESERVED.QnA.Question.Order” that can be queried by the navigation function to retrieve the ordered list of questions.. Other methods are also possible, but may require extra implementation effort.

Handler Lambda incorrectly parses Alexa events

Error reported from customer:
"Alexa is logging this error TypeError: Cannot read property 'slots' of undefined at module.exports (/var/task/lib/parse.js:33:39)"

I think the problem is that the handler lambda does not parse the alexa LaunchRequest and SessionEndedRequest revents correctly.

first, replicate this problem.
second, added test cases for these events
third, added additional parsing logic to lambda function
last, verify fix

Twitter DM bot (?)

Short of AWS supporting Twitter DM APIs (now in beta, https://developer.twitter.com/en/docs/direct-messages/beta-features ) directly, perhaps support for Twitter DMs could be added to this project? I have done some work on that https://github.com/MSFREACH/msf-reach-chatbot/commit/b0d950f6a6d76ed970b9ec928797986be36f20de albeit using serverless rather than CloudFormation directly. Note this code isn't tested yet (so consider it beta) as I'm waiting on beta access to be approved for one of the Twitter accounts I run, however it's based on some code that does work.

Repeated display of image attachment

Observed that when lex web ui is configured with: reInitSessionAttributesOnRestart: false, any image attachment provided by an answer is repeatedly re-displayed for subsequent (different) answers that do not have images attached.

QnABot should explicitly clear the ‘appContext’ sessionAttribute if an answer has no attachments.

Log User Feedback

Purpose: Use extension hook mechanism to support ability for users to provide and log feedback on the quality of the answer received from previous question. Example use cases:

  • User can say “That did not answer my question”, or “That answer is wrong”, etc. (Utterances supported to be determined by content designer). Utterance matched to item created in content designer, which calls this Lambda extension function, which in turn logs the feedback in CloudWatch metrics and CloudWatch logs, making it easy for Content Administrator to assess user satisfaction with the answers, and therefore make informed adjustments to the content as needed.

Develop Branch: Admin user email is hardcoded in build/templates/test/master.json

Expected Behavior

Admin email address should not be hardcoded in build/templates/test/master.json
Suggest prompt for email address, and/or require email address as environment var or parameter.

Actual Behavior

Admin email address is hardcoded to:
"Email": "[email protected]",
When stack is created non interactively by a different user (using "npm run stack test/master up"), the Cognito QnABot signup email is not received.

Steps to Reproduce the Problem

  1. As a user that is not jcalho, create stack from cloned repo (develop branch) using 'npm run stack test/master up'
  2. try to log in to Content Designer UI

Specifications

  • Version:
  • Platform:

Add support for video files in response

Would love to have video file support for Show devices as part of the response (just like we do images today). I'm thinking we could continue to use the image link as-is, but augment it so that if it sees a .mp4 extension it will render as video instead of picture on the Echo Show.

Question Handler Lambda

Provide a hook for a lambda function, specified in QnA document, to be called with response object and whose response is returned by handler lambda. This will help implement more active and dynamic behavior

Link Parsing Behavior

Expected Behavior

www.google.com => says like that
link => behavior depends on format needed

Actual Behavior

does not parse urls with percent signs correctly.
does not recognize urls correctly

Specifications

  • Version: development
  • Platform:

solution

either
remove all link parsing from QnABot and let the client handle it
or
improve current behavior

my opinion: remove link parsing behavior, QnABot is responsible for content/format and the client is responsible for the representation of the content.

Adding a new question to a QnA item can change response to an existing question

Expected Behavior

Adding new questions to an item should not adversely affect any answers that were previously correctly matched.

Actual Behavior

Adding a new question can actually weaken the score of an existing good match, sometimes causing another item to have a stronger score. See example below.

Steps to Reproduce the Problem

Import two items in attached file:
test.txt

Switch to 'test' tab, and test question "tell me about snorkeling" - observe that the expected item is 'test.001' has the higher score (though by a slim margin)

image

Now edit 'test.001' and add a second question: "what should I know about snorkeling"
Rerun the test with the same question.. Now the other answer has the higher score.

image

It is counter intuitive, and undesirable, that adding the second question would change the answer.

Analysis

The QnABot uses elastic search ‘full text search’ capability to create ‘relevance scores’ for each QnA item. Relevance scores are computed by weighting a number of different factors in an effort to get the best match – see What is relevance

There are three factors to the scoring a) term frequency, b) inverse document frequency, and 3) field length norm.. I believe it is this third factor that is biting us here.

This is because the effect of adding the second question to the first item was to make the whole ‘question’ field longer, which reduced the relevance score of the match of item 1 (die to the ‘field length norm’ behavior aforementioned). The score was reduced to the point where it was slightly lower than the first item.

NOTE: This situation really only arises when the question results in very similar scores on multiple items.. Ie when similarilties between the questions prevent a strong unique match.

Options

A shortterm workaround can be to duplicate the question in order to increase the 'terms frequency' part of the scoring equation. ie adding a 3rd question to 'test.001' duplicating the initial question "tell me about snorkelling" once again results in this item having the highest score. Despite the fact that the 3rd question also lengthened the field further, the fact that it was a strong match to the question had the net effect of strengthening the overall score.
However, while this technique might be useful for avoiding this specific problem, I do worry that it could introduce new problems by weakening the score of other question variants. Could become a game of 'whack-a-mole'!

Better if we can fix a fix in the code

  1. (preferred) find a way to construct the doctype mapping or the query to negate the problematic 'field length norm' factor when matching on the question lists. The total number of or length of the questions should ideally not affect the scoring of a match. See disable field-length norm in mapping
  • UPDATE: disabling 'field-length norm' did resolve this issue but created a new issue.. namely with it disabled, the question "tell me about snorkeling" returned identical relevance scores for the two test items "tell me about snorkeling' and 'tell me about snorkel prices' since after stemming (snorkeling=snorkel) the matches were identical. So back to the drawing board. Next up - see if mapping the question array as a nested datatype will help.
  1. alternatively, enhance the elastic search document structure to model each question independently, either by duplicating answers where there are multiple questions, or using a parent/child nested mapping to next questions as separate documents under the parent answer.

Restrict Access

Create a way to restrict access to client ui.
first) get proper credentials, could use cognito hosted login
second) send credentials to lex web ui

Bot does not operate with Facebook messenger

Expected Behavior

After publishing the bot as a Facebook messenger bot, I should receive replies for queries that result in matches.

Actual Behavior

No reply received in messenger. Looking at the CloudWatch logs for the handler reveals the following error:

2017-12-01T00:10:49.253Z	159d39bc-d62c-11e7-aca4-39e3bde501a4	TypeError: Cannot convert undefined or null to object
at Object.exports.success (/var/task/lib/response.js:197:19)
at es.ping.tap.then.then.msg (/var/task/index.js:42:39)
at tryCatcher (/var/task/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/var/task/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/var/task/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/var/task/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/var/task/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (/var/task/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/var/task/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/var/task/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)

This error is because when using a Lex bot as a Facebook messenger bot, params.Session is not set (i.e. null) per http://docs.aws.amazon.com/lex/latest/dg/ex1-sch-appt-info-flow-details.html

Steps to Reproduce the Problem

  1. Deploy the bot as a Facebook messenger bot per http://docs.aws.amazon.com/lex/latest/dg/fb-bot-association.html
  2. Send a query that matches one of the questions.

Develop Branch: Content Designer UI - New Account sign up doesn't create functioning account.

Expected Behavior

Content Designer UI should not allow public users to sign up for an account. Access to Content designer must be restricted to content administrators only.

Suugest we allow new accounts to be created only by an existing Admin user.
I.e. remove the 'sign up' feature on the login page, but add a new 'Add/remove users' feature accessible only to existing authorized users.

Actual Behavior

Using the 'sign up' feature creates an account OK, but after logging in with the new account, Content designer doesn't work.

Steps to Reproduce the Problem

  1. Use the 'sign up' link in the login page to create a new account
  2. Login and try to use that new account

image

Specifications

  • Version:
  • Platform:

Microsoft Edge Compatability

QnABot currently does not work in Edge.
next steps)

  1. DesignerUI should detect browser and alert user to incompatibility
  2. This should be fixed

Update CF template to support Fault Tolerant Elastic Search domain (2xinstances)

Expected Behavior

Customer lost QnA Content after node failure on default single instance ES domain.

While the blog does state that the dafault ES domain should be increased to 2 instances for production deployments, we could increase awareness if QnABot CF template supported provisioning fault tolerant elastic search domain (2 x Instances) by default. User should still be allowed to provision single node non-fault-tolerant domain for non-production / non-critical deployments.

document the API

What I'd like to do is to use the API from other software (in this case https://github.com/MSFREACH/msf-reach ) for updating the list of questions and answers in JSON format, to match new events and reporting links in that software. I've been able to reverse engineer an understanding from the code and Chrome developer tools running on the chatbot designer, but API docs would be nice.

Alexa built in intents

QnABot should support the following built in alexa intents:

AMAZON.CancelIntent
AMAZON.HelpIntent
AMAZON.RepeatIntent
AMAZON.StopIntent

and may also:

AMAZON.NextIntent
AMAZON.NoIntent
AMAZON.YesIntent
AMAZON.PreviousIntent
AMAZON.MoreIntent

Hosted User Management

Switch Designer UI login to use Cognito Hosted Login. this will allow users to use the full features of Congito include password forgot/reset.

change lex static messages

add ability to edit:

  • lex-clarrification
  • lex-hangup
  • qna empty response
  • qna error response

steps)

  1. add crud methods to /bot/messages resource in api, will need to have lambda to make changes to both Lex messages and Lambda enviromental variables
  2. add page to UI for bot management

Cfn-user lambda update handler

The update event should delete the old user and create a new.

This would be the easiest way without parsing differences and using different signup/edit flows. since the user is used just for logging into the designer ui, there should be no side effects from a delete/create cycle.

Bulk delete

add delete method to /questions to delete multiple questions in a single request, body of request would be a list of qids to delete.

Not able to finish upload stage of setup, module not found.

I am attempting to setup the Q and A Bot on an EC2 t2.micro instance, with 2 GB of swap added on the EBS. I initially had some trouble when running "npm install", but after installing "chromedriver" beforehand, it completed successfully. However, when running "npm run upload", I get several errors for resources that seem to be missing or can't be found (I have omitted the working sections with [OMITTED WORKING SECTION]:

$ npm run upload

> [email protected] upload /home/ec2-user/aws-ai-qna-bot
> npm run build; make upload -j 4


> [email protected] build /home/ec2-user/aws-ai-qna-bot
> make website -B

mkdir -p build; mkdir -p build/lambda; mkdir -p build/templates;mkdir -p build/documents
node_modules/.bin/webpack --config ./website/admin/config/webpack.config.js
Hash: 3611870128cf05f4c24c
Version: webpack 2.7.0

[OMITTED WORKING SECTION]

ERROR in ./website/admin/entry.js
Module not found: Error: Can't resolve 'hint.css' in '/home/ec2-user/aws-ai-qna-bot/website/admin'
 @ ./website/admin/entry.js 16:9-28

ERROR in ./website/admin/entry.js
Module not found: Error: Can't resolve 'hint.css/hint.css' in '/home/ec2-user/aws-ai-qna-bot/website/admin'
 @ ./website/admin/entry.js 17:9-37

ERROR in ./website/admin/js/client.js
Module not found: Error: Can't resolve 'axios' in '/home/ec2-user/aws-ai-qna-bot/website/admin/js'
 @ ./website/admin/js/client.js 15:10-26

ERROR in ./website/admin/js/admin.js
Module not found: Error: Can't resolve 'idle-js' in '/home/ec2-user/aws-ai-qna-bot/website/admin/js'
 @ ./website/admin/js/admin.js 23:9-27
 @ ./website/admin/entry.js

ERROR in ./website/admin/js/lib/api.js
Module not found: Error: Can't resolve 'axios' in '/home/ec2-user/aws-ai-qna-bot/website/admin/js/lib'
 @ ./website/admin/js/lib/api.js 15:10-26
 @ ./website/admin/js/lib/auth.js
 @ ./website/admin/js/lib/router.js
 @ ./website/admin/js/lib/index.js
 @ ./website/admin/js/admin.js
 @ ./website/admin/entry.js

ERROR in ./website/admin/js/lib/cognito.js
Module not found: Error: Can't resolve 'axios' in '/home/ec2-user/aws-ai-qna-bot/website/admin/js/lib'
 @ ./website/admin/js/lib/cognito.js 15:10-26
 @ ./website/admin/js/lib/auth.js
 @ ./website/admin/js/lib/router.js
 @ ./website/admin/js/lib/index.js
 @ ./website/admin/js/admin.js
 @ ./website/admin/entry.js

ERROR in ./website/admin/js/lib/store/actions.js
Module not found: Error: Can't resolve 'axios' in '/home/ec2-user/aws-ai-qna-bot/website/admin/js/lib/store'
 @ ./website/admin/js/lib/store/actions.js 16:10-26
 @ ./website/admin/js/lib/store/index.js
 @ ./website/admin/js/lib/index.js
 @ ./website/admin/js/admin.js
 @ ./website/admin/entry.js

ERROR in ./website/admin/js/lib/sdk/lib/apiGatewayCore/sigV4Client.js
Module not found: Error: Can't resolve 'axios' in '/home/ec2-user/aws-ai-qna-bot/website/admin/js/lib/sdk/lib/apiGatewayCore'
 @ ./website/admin/js/lib/sdk/lib/apiGatewayCore/sigV4Client.js 28:10-26
 @ ./website/admin/js/lib/sdk/lib/apiGatewayCore/index.js
 @ ./website/admin/js/lib/sdk/index.js
 @ ./website/admin/js/lib/api.js
 @ ./website/admin/js/lib/auth.js
 @ ./website/admin/js/lib/router.js
 @ ./website/admin/js/lib/index.js
 @ ./website/admin/js/admin.js
 @ ./website/admin/entry.js

ERROR in ./website/admin/js/lib/sdk/lib/apiGatewayCore/simpleHttpClient.js
Module not found: Error: Can't resolve 'axios' in '/home/ec2-user/aws-ai-qna-bot/website/admin/js/lib/sdk/lib/apiGatewayCore'
 @ ./website/admin/js/lib/sdk/lib/apiGatewayCore/simpleHttpClient.js 29:10-26
 @ ./website/admin/js/lib/sdk/lib/apiGatewayCore/index.js
 @ ./website/admin/js/lib/sdk/index.js
 @ ./website/admin/js/lib/api.js
 @ ./website/admin/js/lib/auth.js
 @ ./website/admin/js/lib/router.js
 @ ./website/admin/js/lib/index.js
 @ ./website/admin/js/admin.js
 @ ./website/admin/entry.js

 
[OMITTED WORKING SECTION]

 
 make: *** [website] Error 2

npm ERR! Linux 4.9.51-10.52.amzn1.x86_64
npm ERR! argv "/home/ec2-user/.nvm/versions/node/v4.4.5/bin/node" "/home/ec2-user/.nvm/versions/node/v4.4.5/bin/npm" "run" "build"
npm ERR! node v4.4.5
npm ERR! npm  v2.15.5
npm ERR! code ELIFECYCLE
npm ERR! [email protected] build: `make website -B`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] build script 'make website -B'.
npm ERR! This is most likely a problem with the aws-ai-qna-bot package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     make website -B
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs aws-ai-qna-bot
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR!     npm owner ls aws-ai-qna-bot
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/ec2-user/aws-ai-qna-bot/npm-debug.log
node_modules/.bin/webpack --config ./website/admin/config/webpack.config.js
Hash: 3611870128cf05f4c24c
Version: webpack 2.7.0

[OMITTED WORKING SECTION]

ERROR in ./website/admin/entry.js
Module not found: Error: Can't resolve 'hint.css' in '/home/ec2-user/aws-ai-qna-bot/website/admin'
 @ ./website/admin/entry.js 16:9-28

ERROR in ./website/admin/entry.js
Module not found: Error: Can't resolve 'hint.css/hint.css' in '/home/ec2-user/aws-ai-qna-bot/website/admin'
 @ ./website/admin/entry.js 17:9-37

ERROR in ./website/admin/js/client.js
Module not found: Error: Can't resolve 'axios' in '/home/ec2-user/aws-ai-qna-bot/website/admin/js'
 @ ./website/admin/js/client.js 15:10-26

ERROR in ./website/admin/js/admin.js
Module not found: Error: Can't resolve 'idle-js' in '/home/ec2-user/aws-ai-qna-bot/website/admin/js'
 @ ./website/admin/js/admin.js 23:9-27
 @ ./website/admin/entry.js

ERROR in ./website/admin/js/lib/api.js
Module not found: Error: Can't resolve 'axios' in '/home/ec2-user/aws-ai-qna-bot/website/admin/js/lib'
 @ ./website/admin/js/lib/api.js 15:10-26
 @ ./website/admin/js/lib/auth.js
 @ ./website/admin/js/lib/router.js
 @ ./website/admin/js/lib/index.js
 @ ./website/admin/js/admin.js
 @ ./website/admin/entry.js

ERROR in ./website/admin/js/lib/cognito.js
Module not found: Error: Can't resolve 'axios' in '/home/ec2-user/aws-ai-qna-bot/website/admin/js/lib'
 @ ./website/admin/js/lib/cognito.js 15:10-26
 @ ./website/admin/js/lib/auth.js
 @ ./website/admin/js/lib/router.js
 @ ./website/admin/js/lib/index.js
 @ ./website/admin/js/admin.js
 @ ./website/admin/entry.js

ERROR in ./website/admin/js/lib/store/actions.js
Module not found: Error: Can't resolve 'axios' in '/home/ec2-user/aws-ai-qna-bot/website/admin/js/lib/store'
 @ ./website/admin/js/lib/store/actions.js 16:10-26
 @ ./website/admin/js/lib/store/index.js
 @ ./website/admin/js/lib/index.js
 @ ./website/admin/js/admin.js
 @ ./website/admin/entry.js

ERROR in ./website/admin/js/lib/sdk/lib/apiGatewayCore/sigV4Client.js
Module not found: Error: Can't resolve 'axios' in '/home/ec2-user/aws-ai-qna-bot/website/admin/js/lib/sdk/lib/apiGatewayCore'
 @ ./website/admin/js/lib/sdk/lib/apiGatewayCore/sigV4Client.js 28:10-26
 @ ./website/admin/js/lib/sdk/lib/apiGatewayCore/index.js
 @ ./website/admin/js/lib/sdk/index.js
 @ ./website/admin/js/lib/api.js
 @ ./website/admin/js/lib/auth.js
 @ ./website/admin/js/lib/router.js
 @ ./website/admin/js/lib/index.js
 @ ./website/admin/js/admin.js
 @ ./website/admin/entry.js

ERROR in ./website/admin/js/lib/sdk/lib/apiGatewayCore/simpleHttpClient.js
Module not found: Error: Can't resolve 'axios' in '/home/ec2-user/aws-ai-qna-bot/website/admin/js/lib/sdk/lib/apiGatewayCore'
 @ ./website/admin/js/lib/sdk/lib/apiGatewayCore/simpleHttpClient.js 29:10-26
 @ ./website/admin/js/lib/sdk/lib/apiGatewayCore/index.js
 @ ./website/admin/js/lib/sdk/index.js
 @ ./website/admin/js/lib/api.js
 @ ./website/admin/js/lib/auth.js
 @ ./website/admin/js/lib/router.js
 @ ./website/admin/js/lib/index.js
 @ ./website/admin/js/admin.js
 @ ./website/admin/entry.js

 
[OMITTED WORKING SECTION]

 
 make: *** [website] Error 2

npm ERR! Linux 4.9.51-10.52.amzn1.x86_64
npm ERR! argv "/home/ec2-user/.nvm/versions/node/v4.4.5/bin/node" "/home/ec2-user/.nvm/versions/node/v4.4.5/bin/npm" "run" "upload"
npm ERR! node v4.4.5
npm ERR! npm  v2.15.5
npm ERR! code ELIFECYCLE
npm ERR! [email protected] upload: `npm run build; make upload -j 4`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] upload script 'npm run build; make upload -j 4'.
npm ERR! This is most likely a problem with the aws-ai-qna-bot package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run build; make upload -j 4
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs aws-ai-qna-bot
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR!     npm owner ls aws-ai-qna-bot
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/ec2-user/aws-ai-qna-bot/npm-debug.log

mailto URIs not supported

Expected Behavior

[email link](mailto:[email protected])

should result in a mailto link

Actual Behavior

No link. Maybe #29 will help address this?

Steps to Reproduce the Problem

  1. Create a mailto link in markdown for a response
  2. Send a query that triggers that response

env variable SKIP_LINK_PARSING has no effect

Expected Behavior

When environement variable SKIP_LINK_PARSING is set to TRUE on QNA-master-1-master-***-Handler-1- function, responses can include URLs

Actual Behavior

URL's are parsed and throw error as seen in logs below, instead of passing through, as expected from code on lambda/handler/lib/response.js line 38

Steps to Reproduce the Problem

  1. Set environment variable SKIP_LINK_PARSING = TRUE on the handler lambda.
  2. Create test question where answer includes:
    <a href="http://www.google.com">ask google!! </a>
  3. Trigger question.

Specifications

  • Version: master
  • Platform: Amazon Linux running on EC2

error log:

{ DependencyFailedException: Invalid Lambda Response: Received invalid response from Lambda: Can not construct instance of GenericAttachment$Builder, problem: Attachment Url is not in range <1,2048> at [Source: {"sessionAttributes":{"":"STRING_VALUE","appContext":"{"responseCard":{"version":1,"contentType":"application/vnd.amazonaws.card.generic","genericAttachments":[{"title":"Additional Information","attachmentLinkUrl":"http://www.google.com\">ask"}]}}"},"dialogAction":{"type":"Close","fulfillmentState":"Fulfilled","message":{"contentType":"PlainText","content":"

\n\n <a href=" google!! "},"responseCard":{"version":1,"contentType":"application/vnd.amazonaws.card.generic","genericAttachments":[{"title":"Additional Information","attachmentLinkUrl":"http://www.google.com">ask"}]}}}; line: 1, column: 985]

Export All Error

I tried to build a backup by Exporting all
What I got instead was an empty JSON file contests = {}

After attempting to use the export filter option all questions were erased from the GUI
and now I'm unable to import or create any questions.

ElasticSearch 6.0

Upgrade ElasticSearch from 5.1 => 6.0

why?
best practice to use newest version if possible

Development branch - Alexa instructions - Interaction model

Refers to button below, but there is no button on this page. (Buttons seem to appear on next page)
Also, maybe use 'courier' / monospaced font instead on inverted color for text to be entered.

Suggest revisit of Alexa instructions to ensure instructions match developer console steps, page by page.

image

Development branch: Alexa instructions - Skill information page errors

  1. Typo - should be 'Custom Interaction Model'
  2. Don't invert font colors for skill and invokation names (makes it look like these are buttons to be clicked (per usage of this style on previous page). Suggest using monospaced (courier) font for text to be entered.
  3. This page in the developer console has a 'Save' button, not a 'next' button

image

Implement Alexa AMAZON.StopIntent

Expected Behavior

The Alexa skill associated with QnABot should support the Cancel intent to close the skill.

Actual Behavior

Currently the QnABot skill remains open until it times out, even after a cancel request, which can cause issues if user attempts to invoke another skill.

Long questions (>140chars) break 'Rebuild Lex Bot' action

Any question longer that 140 characters prevents "Rebuild Lex Bot" action from having any effect, though UI nevertheless reports 'Success".

Two aspects to this issue:

  1. The Content Designer UI should detect and report bot rebuild failures.

  2. QnABot should enforce the Lex slot type length limit by disallowing entry of questions longer than 140 characters.

Steps to reproduce

  1. Add a long question to an item (> 140 characters), save item
  2. Rebuild bot from ContentDesigner console
  3. Observe Content designer reports 'Success'. Observe failures logged by Lambda 'Handler' function. Observe from Lex console that Lex bot is not actually rebuilt.

Microsoft Edge not signing request

Edge on windows 10 gives the following error after logging into Desginer UI:

request was: GET (apigateway endpoint)?from=0&filter=&perpage=15
response was: 403: MissingAuthenticationToken

The ApiGateway generated sdk is not sigv4 signing request to api.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.