EchoPy - Amazon Echo Hello World Demo In Python

I have been getting a few requests for my EchoPy Hello World demo to get posted on my GitHub because the complexity of the EchoPyNest and EchoPySmartThings is a little much to learn how to work with the Amazon Echo.

This Hello World demo is a clone of the demo provided by Amazon on their developer portal but written in Python instead of Java or Node.js. It is designed to be hosted on a cloud server but it can also be run from your house if you are able to forward https on port 443 to the computer that is running the code.

For my main Alexa server I am using DigitalOcean. I have been using them for a long time now and pricing starts at $5 a month. If you are interested please check them out at https://digitalocean.com. By clicking that link you will receive my referral code and get $10 free.

Rules set in place by Amazon:

  • Must be publicly available using https
  • Must use port 443

The Story

With those Ideas in place I started to work on my first ASK App.. Hello World.. Amazon has lots of sample code and documentation on their developer website on how to do simple apps.. But all of these use Java or Node.js on Amazon Lambda.. So most of that was useless to me..

After digging around some I found samples of the requests that Amazon will send to your service and what it expects back as a response.. Once I found that things started coming together..

curl -v -k -H "Content-Type: application/json" -X POST http://localhost:5000/EchoPyAPI --data-binary  '{              
  "version": "1.0",
  "session": {
    "new": true,
    "sessionId": "session1234",
    "application": {
      "applicationId": "amzn1.echo-sdk-ams.app.1234"
    },               
    "attributes": {},
    "user": {
      "userId": null
    }
  },          
  "request": {
    "type": "LaunchRequest",
    "requestId": "request5678",
    "timestamp": "2015-05-13T12:34:56Z"
  }
}'

{
  "version": "1.0",
  "response": {
    "outputSpeech": {
      "type": "PlainText",
      "text": "Hello world"
    },
    "card": {
      "type": "Simple",
      "title": "HelloWorld - Title",
      "content": "HelloWorld - Content"
    }
  }

So I decided to use flask as a simple web server.. That part was easy... I only had to really handle a single url for requests...

Download

As always my code is available on my GitHub https://github.com/zpriddy/ZP_EchoPy

Go Top
comments powered by Disqus