alexa

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	ApplicationID  string
	SessionHandler SessionHandler
	AudioHandler   AudioHandler
}

App responds to Alexa requests by routing them to the correct handler

func (*App) Handle

func (a *App) Handle(ctx context.Context, r *RequestEnvelope) (*ResponseEnvelope, error)

Handle inspects the request type and forwards the request to the appropriate handler

type AppHandler

type AppHandler interface {
	Handle(ctx context.Context, r *RequestEnvelope) (*ResponseEnvelope, error)
}

AppHandler responds to requests from the alexa skill service

type AudioHandler

type AudioHandler interface {
	OnPlaybackStarted(context.Context, *Request, *Context) ([]Directive, error)
	OnPlaybackFinished(context.Context, *Request, *Context) ([]Directive, error)
	OnPlaybackStopped(context.Context, *Request, *Context) error
	OnPlaybackNearlyFinished(context.Context, *Request, *Context) ([]Directive, error)
	OnPlaybackFailed(context.Context, *Request, *Context) ([]Directive, error)
}

AudioHandler handles AudioPlayer requests

type AudioPlayer

type AudioPlayer struct {
	PlayerActivity string `json:"playerActivity"`
}

type Card

type Card struct {
	Type    string `json:"type"`
	Title   string `json:"title,omitempty"`
	Content string `json:"content,omitempty"`
	Text    string `json:"text,omitempty"`
	Image   *Image `json:"image,omitempty"`
}

type Context

type Context struct {
	AudioPlayer AudioPlayer `json:"AudioPlayer"`
	System      System      `json:"System"`
}

type Device

type Device struct {
	ID         string              `json:"deviceId"`
	Interfaces SupportedInterfaces `json:"supportedInterfaces"`
}

type Directive

type Directive struct {
	Type         string `json:"type"`
	PlayBehavior string `json:"playBehavior,omitempty"`
	AudioItem    *struct {
		Stream *Stream `json:"stream,omitempty"`
	} `json:"audioItem,omitempty"`
}

type Image

type Image struct {
	SmallImageURL string `json:"smallImageUrl,omitempty"`
	LargeImageURL string `json:"largeImageUrl,omitempty"`
}

type Intent

type Intent struct {
	Name  string                `json:"name"`
	Slots map[string]IntentSlot `json:"slots"`
}

type IntentSlot

type IntentSlot struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type OutputSpeech

type OutputSpeech struct {
	Type string `json:"type"`
	Text string `json:"text,omitempty"`
	SSML string `json:"ssml,omitempty"`
}

OutputSpeech contains the data the defines what Alexa should say to the user.

func PlainSpeech

func PlainSpeech(text string) *OutputSpeech

PlainSpeech returns OutputSpeech configured for basic text based output

func SSMLSpeech

func SSMLSpeech(ssml string) *OutputSpeech

SSMLSpeech returns OutputSpeech configured for SSML based output

type Permissions

type Permissions struct {
	ConsentToken string `json:"consentToken,omitempty"`
}

type Reprompt

type Reprompt struct {
	OutputSpeech *OutputSpeech `json:"outputSpeech,omitempty"`
}

type Request

type Request struct {
	Type                 string `json:"type"`
	RequestID            string `json:"requestId"`
	Timestamp            string `json:"timestamp"`
	Intent               Intent `json:"intent"`
	Locale               string `json:"locale"`
	Token                string `json:"token"`
	OffsetInMilliseconds int64  `json:"offsetInMilliseconds"`
}

type RequestApplication

type RequestApplication struct {
	ApplicationID string `json:"applicationId"`
}

type RequestEnvelope

type RequestEnvelope struct {
	Version string   `json:"version"`
	Session *Session `json:"session"`
	Request *Request `json:"request"`
	Context *Context `json:"context"`
}

RequestEnvelope is the data provided by the alexa skill service when initiating a request

type Response

type Response struct {
	OutputSpeech     *OutputSpeech `json:"outputSpeech,omitempty"`
	Card             *Card         `json:"card,omitempty"`
	Reprompt         *Reprompt     `json:"reprompt,omitempty"`
	Directives       *[]Directive  `json:"directives,omitempty"`
	ShouldSessionEnd bool          `json:"shouldEndSession"`
}

type ResponseEnvelope

type ResponseEnvelope struct {
	Version           string                 `json:"version"`
	SessionAttributes map[string]interface{} `json:"sessionAttributes,omitempty"`
	Response          *Response              `json:"response"`
}

ResponseEnvelope is data the alexa skill service expects in response to a request

type Session

type Session struct {
	New        bool   `json:"new"`
	SessionID  string `json:"sessionId"`
	Attributes struct {
		String map[string]interface{} `json:"string"`
	} `json:"attributes"`
	User        User               `json:"user"`
	Application RequestApplication `json:"application"`
}

type SessionHandler

type SessionHandler interface {
	OnLaunch(context.Context, *Request, *Session, *Context) (*Response, error)
	OnIntent(context.Context, *Request, *Session, *Context) (*Response, error)
	OnSessionEnded(context.Context, *Request, *Session, *Context) error
}

SessionHandler handles the main Launch, Intent and SessionEnded requests

type Stream

type Stream struct {
	Token                string `json:"token"`
	URL                  string `json:"url"`
	OffsetInMilliseconds int    `json:"offsetInMilliseconds"`
}

type StrictVerificationApp

type StrictVerificationApp struct {
	App App
}

StrictVerificationApp performs additional verification of the request as specified here: https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/developing-an-alexa-skill-as-a-web-service#timestamp

func (*StrictVerificationApp) Handle

Handle verifies the request before handing it off to the wrapped App

type SupportedInterfaces

type SupportedInterfaces struct {
	AudioPlayer AudioPlayer `json:"AudioPlayer"`
}

type System

type System struct {
	Application RequestApplication `json:"application"`
	User        User               `json:"user"`
	Device      Device             `json:"device"`
	APIEndpoint string             `json:"apiEndpoint"`
}

type User

type User struct {
	UserID      string      `json:"userId"`
	AccessToken string      `json:"accessToken"`
	Permissions Permissions `json:"permissions"`
}

type ValidationError

type ValidationError struct {
	Message string
}

ValidationError is an error indicating there was an issue with the request contents.

func (ValidationError) Error

func (v ValidationError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL