Coder Social home page Coder Social logo

react-lex's Introduction

react-lex

ReactJS AWS Lex Chat Component

Demo

http://react-lex.s3-website-us-east-1.amazonaws.com/

Prerequisites

The AWS Javascript SDK for the browser is required. This package will install the entire SDK, but all you need is AWS.LexRuntime and AWS.CognitoIdentity. We recommend you build your own version of the AWS SDK for JavaScript using the builder to include only the services you need.

You will need to set up an AWS Cognito federated identity pool, and pass the IdentityPoolId as props to the component. Be sure to enable access to unauthenticated identities, and modify the IAM roles to allow access to Amazon Lex. From the IAM console, attach the AmazonLexRunBotsOnly and AmazonPollyReadOnlyAccess policies. This blog post walks through the process in detail.

Installing react-lex

npm install --save react-lex

Using the Component

Example:

import LexChat from "react-lex";

class App extends Component {
  render() {
        <LexChat botName="OrderFlowers"
                 IdentityPoolId="us-east-1:7292b8c0-56f1-4441-b2a6-xxxxxxxxxxxx"
                 placeholder="Placeholder text"
                 style={{position: 'absolute'}}
                 backgroundColor="#FFFFFF"
                 height="430px"
                 region="us-east-1"
                 headerText="Chat with our awesome bot" />
  }
}
export default App;
  • Your botname (ie. "OrderFlowers") is a required prop.
  • Your IdentityPoolId is a required prop.

##License

The MIT License (MIT)

Copyright (c) 2017.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

react-lex's People

Contributors

ab320012 avatar promediacorp avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

react-lex's Issues

Issue with the property "botName"

I'm using this library to test my bot.

When I type something it gives me the following error:

I'm sure that I'm using the correct name of my bot.

NotFoundException: The specified resource 'BookTrip' does not exist. Choose another resource.

BotError

This is my code:

import React, { useEffect } from 'react';
import LexChat from 'react-lex';
import AWS from 'aws-sdk';

const ChatbotComponent = () => {

    useEffect(() => {
            AWS.config.update({
                region: "us-west-2",
                credentials: new AWS.CognitoIdentityCredentials({
                  IdentityPoolId: "<MY POOL ID HERE>"
                })
              });
      }, []);


    return (
        <div>
            <LexChat 
                 botName="BookTrip"
                 IdentityPoolId="<MY POOL ID HERE>"
                 placeholder="Type something"
                 style={{position: 'absolute'}}
                 backgroundColor="#FFFFFF"
                 height={430}
                 region="us-west-2"
                 headerText="Chat with our bot" />
        </div>
    )
}
export default ChatbotComponent

UI Header position shifts when bootstrap is imported

I'm building a react app to which I imported bootstrap v4.5 into my application. I noticed once I apply bootstrap styling, react-lex's header text is shifted down to the bottom of the header. How can I address this issue?

Please add the option to customize the header in additional to "style" attribute.

Screen Shot 2020-08-04 at 8 44 42 AM

Add support for initial message

Right now the chatbot window just loads a blank chat screen waiting for user input. It would be cool to allow a phrase that I can pass as prop to the component as an initial greeting message to the user.

additional region Support

It would be nice if there where a posibility to change the region of lex (since lex launched in ireland recently)

wanted behaviour:

read out region from config file to connect to

current behaviour:

region us-east-1 is hard coded

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.