A working example for developing Alexa Skills Kit for your Amazon Echo with AWS Lambda. This example wraps a Go executable/process in an Node.js wrapper. Yes, Go works just fine on AWS.
- Golang v1.4+
- Linux compilation must be installed, as AWS Lambda is Linux based (OSX:
brew install go --cross-compile-common)
go get github.com/jasonmoo/lambda_proc- awscli
- On OSX:
brew install awscli
- Change the LAMBDA_PROC variable in the file 'build.sh' to the name of your Lambda function on AWS Lambda
- Setup an AWS Lambda function with the name set for LAMBDA_PROC in build.sh
- Setup an Alex Skill with the 'Alexa Skills Settings' and pointing to your AWS Lambda function, its recommended to use ARN
An overview of using AWS Lambda with Alexa may be found here:
After configuring your s3up and awscli credentials for S3/Lambda, then:
./build.sh
+ LAMBDA_FUNC=lambda-go
+ cp index.js.template index.js
+ sed s/LAMBDA_FUNC/lambda-go/g
+ GOOS=linux
+ go build -o lambda-go
+ zip -r lambda-go.zip lambda-go index.js
updating: lambda-go (deflated 70%)
updating: index.js (deflated 63%)
+ aws lambda update-function-code --function-name lambda-go --zip-file fileb://lambda-go.zip
{
"CodeSha256": "foo",
"FunctionName": "lambda-go",
"CodeSize": 905999,
"MemorySize": 128,
"FunctionArn": "bar",
"Version": "$LATEST",
"Role": "baz",
"Timeout": 3,
"LastModified": "2015-11-08T15:06:44.854+0000",
"Handler": "index.handler",
"Runtime": "nodejs",
"Description": "Lambda Go Example"
}{
"intents": [
{
"intent": "Command",
"slots": [
{
"name": "Action",
"type": "ACTION"
},
{
"name": "Name",
"type": "NAMES"
}
]
}
]
}ACTION walk | talk | bike | run
NAMES fred | thelma | shaggy
Command {Name} go {Action}
shaggy go run
{
"session": {
"sessionId": "SessionId.cb4e8a06-58ff-4d6a-befd-1e7a16be0a32",
"application": {
"applicationId": "foo"
},
"attributes": null,
"user": {
"userId": "amzn1.account.bar",
"accessToken": null
},
"new": true
},
"request": {
"type": "IntentRequest",
"requestId": "EdwRequestId.58a4d6d4-f656-4e7e-8ea0-81ad6e66aa82",
"timestamp": 1446994642447,
"intent": {
"name": "Command",
"slots": {
"Action": {
"name": "Action",
"value": "run"
},
"Name": {
"name": "Name",
"value": "shaggy"
}
}
},
"reason": null
}
}{
"version": "1.0",
"response": {
"outputSpeech": {
"type": "PlainText",
"text": "You told shaggy to run"
},
"reprompt": null,
"shouldEndSession": true
},
"sessionAttributes": {}
}