Giter VIP home page Giter VIP logo

chatbot's Introduction

Build Your Own Chatbot using Java

This repository explains how to create a Star Wars chatbot using Amazon Lex and Java.

logo

The users can interact with this chatbot using the following means:

  1. Voice (Alexa, Phone/Call)

  2. Text (Phone/SMS, Facebook Messenger, Slack)

Here are the key components of architecture:

architecture

Deploy Lex bot and Alexa backend function using Java

You need to install org.sample.aws.lex:lex-java:0.2 dependency as explained at https://github.com/arun-gupta/lex-java#install-jar-locally before building this project.

mvn -f starwars-chatbot/pom.xml clean package install

ARN for Alexa function: aws lambda get-function --function-name StarWarsChatbot --region us-east-1 | jq .Configuration.FunctionArn

Note
Getting Started with Alexa skill using Java is explained at https://github.com/arun-gupta/alexa-skill-java.

JSON Document

Data is loaded as JSON documents in DynamoDB. Here is a sample JSON document:

{
  "dead": true,
  "force-sensitive": true,
  "force-side": "light",
  "id": 1,
  "lightsaber": "green",
  "planet": "Dagobah",
  "quotes": [
    "When nine hundred years old you reach, look as good you will not.",
    "Truly wonderful, the mind of a child is",
    "A Jedi uses the Force for knowledge and defense, never for attack",
    "That is why you fail.",
    "Adventure. Excitement. A Jedi craves not these things.",
    "Judge me by my size, do you?",
    "Fear is the path to the dark side",
    "Wars not make one great",
    "Do, or do not. There is no try",
    "Size matters not",
    "The dark side clouds everything",
    "Impossible to see the future is",
    "Clear your mind must be",
    "Much to learn you still have ... my old padawan"
  ],
  "weapon": "lightsaber",
  "whoami": "Yoda"
}

Create Global Secondary Index on whoami

Different platforms

Twilio/SMS

  1. Send a message to 408-913-9827 as shown below:

sms

Alexa

  1. Test using http://echosim.io or Alexa

Web

TODO

Mobile

TODO

Logging using Amazon CloudWatch

Monitoring using AWS X-Ray

TODO

How to talk to the chatbot?

Use phrase Ask Star Wars for Alexa, otherwise just the text as is. The list of questions is at https://github.com/arun-gupta/chatbot/wiki/Typical-Questions.

chatbot's People

Contributors

arun-gupta avatar tawalke 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chatbot's Issues

Several characters are not recognized for Alexa skill

For example:

tell me a kylo ren quote gives an error for Alexa skill:

{
  "version": "1.0",
  "response": {
    "outputSpeech": {
      "text": "Are you sure kylo Ren was in Star Wars?",
      "type": "PlainText"
    },
    "card": {
      "content": "Star Wars Quotes",
      "title": "Are you sure kylo Ren was in Star Wars?"
    },
    "reprompt": {
      "outputSpeech": {
        "text": "Are you sure kylo Ren was in Star Wars?",
        "type": "PlainText"
      }
    },
    "speechletResponse": {
      "outputSpeech": {
        "text": "Are you sure kylo Ren was in Star Wars?"
      },
      "card": {
        "content": "Star Wars Quotes",
        "title": "Are you sure kylo Ren was in Star Wars?"
      },
      "reprompt": {
        "outputSpeech": {
          "text": "Are you sure kylo Ren was in Star Wars?"
        }
      },
      "shouldEndSession": false
    }
  },
  "sessionAttributes": {}
}

Add multi-turn conversations

Add an utterance that requires a conversation with the user. For example, bot may ask for missing data in an utterance with multiple slots.

Force intent not working for Kylo Ren

What side of the force was ​Kylo Ren on
An error has occurred: Invalid Lambda Response: Received error response from Lambda: Unhandled
What side of the force was ​Yoda on
Yoda was on the light side, and so was a Jedi

Character names should be case insensitive

ask me a line question
Who said "Clear your mind must be"
yoda
Who said "Clear your mind must be"
Yoda
Yep, you're right!

Another fail case:

Who said "You can run, but you'll only die tired"
boba FETT
Who said "You can run, but you'll only die tired"
Boba Fett
Yep, you're right!

new utterance for force side

Works:

was kylo ren a jedi or a sith
Kylo Ren was on the dark side, and so was a Sith

Does not work:

was kylo ren a jedi
Kylo Ren is from the planet Chandrila

Don't close application after answering question

When returning a SpeechletResponse, call its setShouldEndSession(false) to prevent the application from closing. Then, you can re-prompt the user and say something like "Would you like me to ask you another question?".

Additional information in the response could be confusing

Was Yoda​ on the Light or Dark side of the force
Yoda was on the light side, and so was a Jedi
Was ​yoda affiliated with the Jedi or the Sith
Yoda was on the light side, and so was a Jedi

The response should return only the information asked in the question

Fix 's not working

"What color is Yoda's lightsaber" does not work but "What color is Yoda lightsaber" does

Fix utterance

where planet was {character} born on should be which planet was {character} born on

"Ask me a line" with Twilio/SMS throws NPE

java.lang.NullPointerException: java.lang.NullPointerException
java.lang.NullPointerException
at org.sample.aws.chatbot.starwars.lex.StarWarsLexBot.handleRequest(StarWarsLexBot.java:41)
at org.sample.aws.chatbot.starwars.lex.StarWarsLexBot.handleRequest(StarWarsLexBot.java:16)

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.