Giter Club home page Giter Club logo

aws-lex-proxy's Introduction

aws-lex-proxy

NPM library providing proxy functionality for those needing AWS Lex to be used outside AWS infrastructure without aws-sdk in deployable artifact

version travis build codecov coverage Codacy Badge dependency status MIT License semantic-release Commitizen friendly stability-stable Greenkeeper code style

Table of Contents

Motivation

As AWS Lex does not provide external API endpoint when being setup it results in only two possibilities of using the NLP product:

  • deploying exclusively on AWS infrastructure (Lambda) to access the functionality
  • using AWS SDK

This is meant to provide third option:

  • vanilla HTTPS endpoint to query Lex.

This is achieved by setting up an microservice using AWS API Gateway and Lambda. The HTTPS endpoint will be the API Gateway that triggers Lambda which queries Lex and returns data. CloudFormation stack setup is provided with all needed commands.

Installation

npm i aws-lex-proxy

Setup

You can either setup the infrastructure in one of the following ways:

  1. Create manually via Console API a stack similar to below architecture diagram as Gateway -> Lambda -> Lex with API Gateway Request Template for application/json and Lambda content as in usage below.
  2. Clone this package's GitHub repository and
  • Change package.json -> config -> profile to your profile name
  • Change package.json -> config -> s3BucketName to your bucket's name
  • Change src/bin/lambda.ts BOT_ALIAS and BOT_NAME to your values
  • Run npm run setup will deploy the CloudFormation stack and in output you will have the API endpoints to use with your application

Usage

NOTE: The proxy function takes in AWS SDK configured(if used locally during testing without IAM). This puts SDK version used at users discretion as long as it contains the LexRuntime functionality.

This is the Lambda function content

import LexProxy from 'aws-lex-proxy';
/// AWS SDK setup here
const BOT_ALIAS = 'AwesomeBotAlias';
const BOT_NAME = 'AwesomeBotName';

const handler = (event, context, cb) => {
    const lexProxy = new LexProxy(BOT_ALIAS, BOT_NAME, awsSdk);
    lexProxy.proxy(event, context, cb);
}

export default handler

Documentation

You can find the documentation here

Architecture

Architectural Diagram

aws-lex-proxy's People

Contributors

crisboarna avatar

Watchers

 avatar  avatar  avatar

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.