Giter Club home page Giter Club logo

alexa-skills-kit-golang's Introduction

ericdaugherty/alexa-skills-kit-golang

alexa-skills-kit-golang is a lightweight port of the Amazon alexa-skills-kit-java SDK and Samples.

License

Usage

This explanation assumes familiarity with with AWS Documentation. Please review Developing an Alexa Skill as a Lambda Function before proceeding. This SDK addresses some of the steps documented here for you, but you should be familiar with the entire process.

This SDK was designed to be used as an AWS Lambda function via the eawsy lambda shim.

The samples directory provides example usage, including a Makefile.

The Alexa struct is the initial interface point with the SDK. Alexa must be initialized first. The struct is defined as:

type Alexa struct {
    ApplicationID   string
    RequestHandler  RequestHandler
    IgnoreTimestamp bool
}

The ApplicationID must match the ApplicationID defined in the Alexa Skills

The RequestHandler is an interface that must be implemented, and is called to handle requests.

IgnoreTimestamp should be used during debugging to test with hard-coded requests.

Requests from Alexa should be passed into the Alexa.ProcessRequest method.

func (alexa *Alexa) ProcessRequest(requestEnv *RequestEnvelope) (*ResponseEnvelope, error)

This method takes the incoming request and validates it, and the calls the appropriate callback methods on the RequestHandler interface implementation.

The ResponseEnvelope is returned and can be converted to JSON to be passed back to the Alexa skill.

RequestHandler interface is defined as:

type RequestHandler interface {
	OnSessionStarted(*Request, *Session, *Response) error
	OnLaunch(*Request, *Session, *Response) error
	OnIntent(*Request, *Session, *Response) error
	OnSessionEnded(*Request, *Session, *Response) error
}

For a summary of these methods, please see the Handling Reqeusts Sent By Alexa documentation.

You can directly manipulate the Response struct, but it is not initialized by default and use of the connivence methods is recommended.

These methods include:

func (r *Response) SetSimpleCard(title string, content string)
func (r *Response) SetStandardCard(title string, text string, smallImageURL string, largeImageURL string)
func (r *Response) SetLinkAccountCard()
func (r *Response) SetOutputText(text string)
func (r *Response) SetOutputSSML(ssml string)
func (r *Response) SetRepromptText(text string)
func (r *Response) SetRepromptSSML(ssml string)

And more. These methods handle initializing any required struts within the Response struct as well as setting all required fields.

samples

HelloWorld

Limitations

This version does not support use as a standalone web server as it does not implement any of the HTTPS validation. It was developed to be used as an AWS Lambda function using the eawsy lambda shim The samples utilize this library.

alexa-skills-kit-golang's People

Contributors

ericdaugherty avatar fsenart avatar

Watchers

Justin McCarthy avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.