anjishnu / ask-alexa-pykit

A minimalist SDK for developing skills for the Amazon Echo's ASK - Alexa Skills Kit using Amazon Web Services's Python Lambda Functions. Currently supported profiles are for Linux servers and AWS Lambda. Check the appropriate release branch. The cherrypy release branches have added components for request validation.
MIT License
275 stars 58 forks source link

Usage of Alexa WITHOUT AWS / Lambda? #5

Closed ablakey closed 8 years ago

ablakey commented 8 years ago

Is it possible to make use of the Alexa API on a local machine? Ie. I want to host my own script that will make calls to the API, get responses, and do other things accordingly.

Does the ask-alexa-pykit support that in any manner?

anjishnu commented 8 years ago

There are only two options to running as ASK skill. Either you run it on a server (locally or on EC2 or whatever) and somehow route calls to it - or you abstract it away and load it on Lambda.

If you are running it as a server - it's basically the same - just import lambda_function and pass your input in json form to lambda_function.lambda_handler.

You can check out one of the cherrypy release branches to get a feel for what it looks like when you are running the server version.

With flask running it on a local server can be as easy as:

from flask import Flask, request
from lambda_function import lambda_handler
app = Flask(__name__)

@app.route('/')
def hello_world():
    request_obj = request.get_json()
    return lambda_handler(request_obj)

if __name__ == '__main__':
    app.run()

However the Alexa Skills Kit requires a lot more authentication if you take this approach - so you can look at the certificate generation scripts in the cherrypy branches as well as the validation_utils file, or use an AWS Lambda Function as a 'proxy' to avoid the certification requirements. I personally find it really annoying and tedious to do the validation (but earlier releases of this project DO include code which does that for you on a Linux platform), but it adds a lot of code bloat - so I recommend the Lambda approach, specially for a newbie.

ablakey commented 8 years ago

Fantastic. I'll probably begin with the Lambda approach and then bring my implementation to a local server. I want it to make calls to an API that won't be accessible via. AWS.

Thanks for your help.

anjishnu commented 8 years ago

If you can give me a rough idea of what you hope to achieve maybe I can give you some more detailed advice - but yeah, what you outlined is a generally good strategy. I'd say lambda - > lambda_proxy (prototyping phase)-> standalone server with proper SSL auth (something this library does, but not very well well).

ablakey commented 8 years ago

I appreciate your eagerness to help! Though I'm hesitant because I learn better when I struggle through something myself. You pointed me in the right general direction, which is a good start.

If you're curious, my general plan is to be able to talk to a robot and ask it to do things or ask about its state. Ideally the server and robot are not exposed to the Internet, with exception for the speech API.

I'll be sure to share my results if I ultimately elect to use Alexa + Echo to achieve this.

meetdave06 commented 7 years ago

Hi @ablakey Were you able to run it on your server without Lambda function ? If yes, how ? Which branch of this repository should I use ?

Thanks a lot .