GithubHelp home page GithubHelp logo

abhijit85 / mongodb-awslex-searchmovies Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rlondner/mongodb-awslex-searchmovies

0.0 0.0 0.0 69.29 MB

Amazon Lex Movie Search demo bot powered by MongoDB Atlas

License: Apache License 2.0

Shell 12.25% JavaScript 87.75%

mongodb-awslex-searchmovies's Introduction

Amazon Lex Search Movies App

MongoDB Atlas setup

  1. Make sure MongoDB 3.4 is installed on your machine (we will need it to restore the movie dataset to MongoDB Atlas)
  2. Sign up at MongoDB Atlas or sign in into your existing Atlas account.
  3. From the Clusters page, build a new cluster if you don't already have one (using the Build a New Cluster button). Since we'll use AWS technologies only available in the us-east-1 (N. Virginia) region (as of November 2017), it's best if you create a cluster using the AWS cloud provider in that region.
  4. Select your cluster and press the Connect button. In the window that opens, click on Connect with the Mongo Shell and press the Copy button.
  5. Paste the value into the /data/restore.sh script and replicate the modifications done from the original script into the modified script (adding the --host parameter, replacing mongodb:/ with the replicaSet value and adding the --gzip parameter). Please check the mongorestore documentation for additional information.
  6. From the data folder, run the restore.sh script to restore the moviesDB database into MongoDB Atlas.
  7. To follow least privilege access best practices, it is highly recommended to create a specific database user with only read/write access to the movies collection of the moviesDB database (see this screenshot for an example)

Amazon Lex chat bot setup

Review the setup instructions available in this blog post

AWS Lambda function

This is the Lambda function used by our Lex chatbot to fulfill the intent and retrieve the list of movies featuring the actor/actress specified by the user.

Configuration

  1. Sign in to MongoDB Atlas and retrieve the connection string of the cluster containing your moviesDB database and customize the username and password to match the credentials of a database user having read permissions on the moviesDB database (i.e. read@moviesDB permissions) (as a best practice, do not use your Atlas administrator account).
  2. In the code/template.yaml file, fill out the MONGODB_URI environment variable with the connection string you just customized.

Test

  1. Install Docker on your machine
  2. Install SAM Local on your machine
  3. Run sh sam-invoke.sh from Terminal to test your Lambda function locally. You can customize the values of the currentIntent element of the event.json file to test different values.

Deployment

  1. In AWS, create an S3 bucket. In code/sam-package.sh, replace <S3-BUCKET-NAME> with the name of the bucket you just created
  2. In the following instructions, all the scripts use a lex profile so you can either:
    • create such a profile in your AWS credentials file. You will need to create an IAM user with the following permissions: AWSLambdaFullAccess, AmazonLexFullAccess and the custom permissions available in this AWS Policy file.
    • or replace it with the default profile if your default AWS CLI user has full admin priviledges.
  3. Run sh package.sh from Terminal to package your SAM package. This will package your SAM package and upload it to your S3 bucket.
  4. Run sh deploy.sh from Terminal to deploy your SAM package to AWS Lambda and API Gateway
  5. Once the script has completed (without errors), sign in into the AWS Console and navigate the AWS Lambda section.
  6. You should see a LexMovieSearch Lambda function. Select it and use the event.json file to create a test event and test that the Lambda function works.

Lex bot fulfillment configuration

  1. Once you have validated that your Lambda function works, navigate back to the AWS Lex home.
  2. Select the SearchMoviesBot bot and in the Fulfillment section, select AWS Lambda function and select the LexMovieSearch lambda function. An Add permission to Lambda Function window may pop up, press OK to confirm.
  3. At the top of the page, press the Build button twice
  4. Use the chat bot and enter the following prompt: Looking for a movie. This should kick off the SearchMovies intent we just configured. You can then test the following answers to the consecutive questions prompted by the bot:
    • cOmedY
    • anGeliNa JOLIE
    • 0
  5. You should get the following answer from the bot, coming right from your MongoDB Atlas database:
Angelina Jolie played in the following comedy movies: Hackers (1995), Mojave Moon (1996), Playing by Heart (1998), Pushing Tin (1999), Life or Something Like It (2002), Mr. & Mrs. Smith (2005)

mongodb-awslex-searchmovies's People

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.