Documentation
¶
Index ¶
- type App
- type AppHandler
- type AudioHandler
- type AudioPlayer
- type Card
- type Context
- type Device
- type Directive
- type Image
- type Intent
- type IntentSlot
- type OutputSpeech
- type Permissions
- type Reprompt
- type Request
- type RequestApplication
- type RequestEnvelope
- type Response
- type ResponseEnvelope
- type Session
- type SessionHandler
- type Stream
- type StrictVerificationApp
- type SupportedInterfaces
- type System
- type User
- type ValidationError
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 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 Intent ¶
type Intent struct {
Name string `json:"name"`
Slots map[string]IntentSlot `json:"slots"`
}
type IntentSlot ¶
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 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 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 ¶
func (s *StrictVerificationApp) Handle(ctx context.Context, r *RequestEnvelope) (*ResponseEnvelope, error)
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