Skip to content

unterstein/elastic-alexa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elasticsearch Alexa skill

Skill for Amazon echo to enable Alexa to talk to Elasticsearch.

Current possible interaction

Configured IntentSchema:

ElasticCount Count {emptyTerm|term}

Explanation:

  1. Search for term in elasticsearch and count result set

Example:

Alexa? Ask Elastic to count error

is transformed to skill (intent) and variable configuration (slots):

intent=ElasticSearch
slot(term)=error

Note: Data type number can be translated from five to 5 directly.

Java application called by alexa

Amazon provided a nice SDK and a nice way to interact with alexa. After registering your skill to amazon developer console, your endpoint get called with relevant payload. I decided to use a spring boot application handling these requests. Java code is in src, relevant business logic is included in

src/main/java/info/unterstein/alexa/elastic/alexa/ElasticSpeechlet.java

Get this app up and running

Currently you need to configure the target ElasticSearch cluster within code. This should be changed to be configured during installing this skill to amazon echo, see section Option issues. But, for now, you need to go to

src/main/java/info/unterstein/alexa/elastic/ElasticSpeechlet.java

and do something like:

  // TODO
  public ElasticSpeechlet.java() {
    client = new ElasticSearchClient("your.elastic.url", 9300, "your.cluster.name");
  }

Then you need to package this app and start it somewhere:

mvn clean package
# deploy it somewhere with following command
java -jar elastic-alexa-0.0.1-SNAPSHOT.jar --server.port=19002

Walkthrough amazon developer console

Step 1: Skill information

alt text

Step 2: Interaction model

alt text

Text entered:

speechAssets/IntentSchema.json
speechAssets/SampleUtterances.txt

Step 3: Configuration

alt text

I needed an http endpoint with valid ssl certificate. You can choose between onprem installation or AWS lamba. I decided to deployed the app directly to my server, proxied behind NGINX using the following configuration:

server {
        listen 443 ssl;
        server_name unterstein.info;

...

        ssl_certificate      /etc/nginx/ssl/unterstein.info.crt;
        ssl_certificate_key  /etc/nginx/ssl/unterstein.info.key;

...

        location /alexa {
                proxy_pass http://127.0.0.1:19002/alexa;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
}

Step 4: SSL Certificate

alt text

Step 5: Test

alt text

At this point it is possible to enable this skill for all amazon echos, registered to the current amazon account and can be used directly.

Short demo video

https://twitter.com/unterstein/status/832302202702196736

Useful reads

Open issues

About

Have some fun with alexa and elasticsearch

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages