Skip to content

Instantly share code, notes, and snippets.

extern crate lambda_runtime as lambda;
extern crate alexa_sdk;
use lambda::{lambda, Context, error::HandlerError};
use alexa_sdk::{Request,Response};
use alexa_sdk::request::{IntentType, Locale};
use std::error::Error;
fn handle_help(_req: &Request) -> Result<Response,HandlerError> {
Ok(Response::new_simple("hello", "to say hello, tell me: say hello to someone"))
#/bin/sh
cargo build --release --target x86_64-unknown-linux-musl
zip -j rust.zip ./target/x86_64-unknown-linux-musl/release/bootstrap
[package]
name = "hello_alexa"
version = "0.1.0"
authors = ["Arien Malec <[email protected]>"]
[dependencies]
alexa_sdk = "^0.1"
lambda_runtime = "^0.1"
[[bin]]
@arienmalec
arienmalec / hello.go
Created March 4, 2018 23:11
Final hello Lambda
package main
import (
"github.com/arienmalec/alexa-go"
"github.com/aws/aws-lambda-go/lambda"
)
// DispatchIntents dispatches each intent to the right handler
func DispatchIntents(request alexa.Request) alexa.Response {
var response alexa.Response
@arienmalec
arienmalec / hello.go
Created March 4, 2018 06:46
AWS Lambda with Alexa skill response
package main
import (
"github.com/aws/aws-lambda-go/lambda"
)
// Response contains the message for the world
type Response struct {
Version string `json:"version"`
Body ResBody `json:"response"`
@arienmalec
arienmalec / deploy.sh
Created March 4, 2018 05:45
Deployment script
#!/bin/sh
rm -rf deploy
mkdir deploy
GOOS=linux go build -o ./deploy/hello
pushd deploy
zip hello.zip hello
popd
aws cloudformation package \
--template-file hello.yaml \
@arienmalec
arienmalec / hello.yaml
Created March 4, 2018 05:33
SAM template
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
HelloLambda:
Type: AWS::Serverless::Function
Properties:
Handler: hello
Runtime: go1.x
CodeUri: ./deploy/hello.zip
Environment:
@arienmalec
arienmalec / hello.go
Created March 3, 2018 21:39
Simple Go Lambda
package main
import (
"github.com/aws/aws-lambda-go/lambda"
)
// Response contains the message for the world
type Response struct {
Message string
}