Documentation ¶
Overview ¶
Package alexa enables parsing request and building responses.
Index ¶
- Constants
- Variables
- func CheckForLocaleError(loc l10n.LocaleInstance) error
- func HandleError(b *ResponseBuilder, loc l10n.LocaleInstance, err error) bool
- func HandleIntent(intent string, handler Handler)
- func HandleIntentFunc(intent string, handler HandlerFunc)
- func HandleRequestType(requestType RequestType, handler Handler)
- func HandleRequestTypeFunc(requestType RequestType, handler HandlerFunc)
- func Serve(h Handler) error
- type Application
- type AudioItem
- type AudioPlayerActivity
- type AuthorityValue
- type AuthorityValueValue
- type CanFulfillIntent
- type CanFulfillSlot
- type Card
- type ConfirmationStatus
- type Context
- type ContextApplication
- type ContextAudioPlayer
- type ContextSystem
- type ContextSystemPerson
- type ContextUser
- type ContextViewport
- type ContextViewportMode
- type ContextViewportShape
- type ContextViewportType
- type DialogStateType
- type Directive
- type DirectiveType
- type Handler
- type HandlerFunc
- type Image
- type Intent
- type NotFoundError
- type OutputSpeech
- type PerAuthority
- type Reprompt
- type Request
- type RequestEnvelope
- func (r *RequestEnvelope) ApplicationID() (string, error)
- func (r *RequestEnvelope) ContextPerson() (*ContextSystemPerson, error)
- func (r *RequestEnvelope) ContextUser() (*ContextUser, error)
- func (r *RequestEnvelope) Intent() (Intent, error)
- func (r *RequestEnvelope) IntentName() string
- func (r *RequestEnvelope) IsIntentConfirmed() bool
- func (r *RequestEnvelope) IsIntentRequest() bool
- func (r *RequestEnvelope) RequestDialogState() DialogStateType
- func (r *RequestEnvelope) RequestLocale() string
- func (r *RequestEnvelope) RequestType() RequestType
- func (r *RequestEnvelope) SessionID() string
- func (r *RequestEnvelope) Slot(name string) (Slot, error)
- func (r *RequestEnvelope) SlotValue(name string) string
- func (r *RequestEnvelope) Slots() map[string]*Slot
- func (r *RequestEnvelope) System() (*ContextSystem, error)
- type RequestLocale
- type RequestType
- type ResolutionStatus
- type Resolutions
- type Response
- type ResponseBuilder
- func (b *ResponseBuilder) AddDirective(directive *Directive) *ResponseBuilder
- func (b *ResponseBuilder) Build() *ResponseEnvelope
- func (b *ResponseBuilder) With(resp Response)
- func (b *ResponseBuilder) WithCanFulfillIntent(response *CanFulfillIntent) *ResponseBuilder
- func (b *ResponseBuilder) WithReprompt(text string) *ResponseBuilder
- func (b *ResponseBuilder) WithSessionAttributes(attr map[string]interface{}) *ResponseBuilder
- func (b *ResponseBuilder) WithShouldEndSession(end bool) *ResponseBuilder
- func (b *ResponseBuilder) WithSimpleCard(title, text string) *ResponseBuilder
- func (b *ResponseBuilder) WithSpeech(text string) *ResponseBuilder
- func (b *ResponseBuilder) WithStandardCard(title, text string, image *Image) *ResponseBuilder
- type ResponseEnvelope
- type ResponseError
- type ServeMux
- func (m *ServeMux) HandleIntent(intent string, handler Handler)
- func (m *ServeMux) HandleIntentFunc(intent string, handler HandlerFunc)
- func (m *ServeMux) HandleRequestType(requestType RequestType, handler Handler)
- func (m *ServeMux) HandleRequestTypeFunc(requestType RequestType, handler HandlerFunc)
- func (m *ServeMux) Handler(r *RequestEnvelope) (Handler, error)
- func (m *ServeMux) Logger() log.Logger
- func (m *ServeMux) Serve(b *ResponseBuilder, r *RequestEnvelope)
- type Server
- type Session
- type Slot
- type SlotValue
- type StatusCode
- type Stream
- type TextError
- type TranslationError
- type ViewportConfiguration
- type ViewportExperience
Constants ¶
const ( // ConfirmationStatusNone is constant `NONE`. ConfirmationStatusNone = "NONE" // ConfirmationStatusConfirmed is constant `CONFIRMED`. ConfirmationStatusConfirmed = "CONFIRMED" // ConfirmationStatusDenied is constant `DENIED`. ConfirmationStatusDenied = "DENIED" )
const ( // HelpIntent is the Alexa built-in Help Intent. HelpIntent = "AMAZON.HelpIntent" // CancelIntent is the Alexa built-in Cancel Intent. CancelIntent = "AMAZON.CancelIntent" // StopIntent is the Alexa built-in Stop Intent. StopIntent = "AMAZON.StopIntent" )
Built in intents.
Variables ¶
var ( ErrUnknown = errors.New("unknown error") ErrSlotNoResolutionWithMatch = errors.New("no resolution with match") )
Error constants.
var DefaultServerMux = NewServerMux(log.Null)
DefaultServerMux is the default mux.
Functions ¶
func CheckForLocaleError ¶
func CheckForLocaleError(loc l10n.LocaleInstance) error
CheckForLocaleError returns a ResponseError for the last locale error.
func HandleError ¶
func HandleError(b *ResponseBuilder, loc l10n.LocaleInstance, err error) bool
HandleError handles default and ResponseErrors. Returns true if the error was handled.
func HandleIntent ¶
HandleIntent registers the handler for the given intent on the DefaultServeMux.
func HandleIntentFunc ¶
func HandleIntentFunc(intent string, handler HandlerFunc)
HandleIntentFunc registers the handler function for the given intent on the DefaultServeMux.
func HandleRequestType ¶
func HandleRequestType(requestType RequestType, handler Handler)
HandleRequestType registers the handler for the given request type on the DefaultServeMux.
Any attempt to handle the IntentRequest type will be ignored, use Intent instead.
func HandleRequestTypeFunc ¶
func HandleRequestTypeFunc(requestType RequestType, handler HandlerFunc)
HandleRequestTypeFunc registers the handler function for the given request type on the DefaultServeMux.
Any attempt to handle the IntentRequest type will be ignored, use Intent instead.
Types ¶
type Application ¶
Application defines the interface used of the app.
type AudioItem ¶
type AudioItem struct {
Stream Stream `json:"stream,omitempty"`
}
AudioItem represents a response directive audio item.
type AudioPlayerActivity ¶
type AudioPlayerActivity string
AudioPlayerActivity defines the activities of an audio player.
const ( // AudioPlayerActivityIDLE Nothing was playing, no enqueued items. AudioPlayerActivityIDLE AudioPlayerActivity = "IDLE" // AudioPlayerActivityPAUSED Stream was paused. AudioPlayerActivityPAUSED AudioPlayerActivity = "PAUSED" // AudioPlayerActivityPLAYING Stream was playing. AudioPlayerActivityPLAYING AudioPlayerActivity = "PLAYING" // AudioPlayerActivityBufferUnderrun Buffer underrun. AudioPlayerActivityBufferUnderrun AudioPlayerActivity = "BUFFER_UNDERRUN" // AudioPlayerActivityFINISHED Stream was finished playing. AudioPlayerActivityFINISHED AudioPlayerActivity = "FINISHED" // AudioPlayerActivitySTOPPED Stream was interrupted. AudioPlayerActivitySTOPPED AudioPlayerActivity = "STOPPED" )
type AuthorityValue ¶
type AuthorityValue struct {
Value *AuthorityValueValue `json:"value,omitempty"`
}
AuthorityValue is an entry in the list of values.
type AuthorityValueValue ¶
AuthorityValueValue points to the unique ID and value.
type CanFulfillIntent ¶
type CanFulfillIntent struct { CanFulfill string `json:"canFulfill"` Slots map[string]CanFulfillSlot `json:"slots"` }
CanFulfillIntent represents a response indicating if an intent can be fulfilled.
type CanFulfillSlot ¶
type CanFulfillSlot struct { CanUnderstand string `json:"canUnderstand"` CanFulfill string `json:"canFulfill"` }
CanFulfillSlot represents a slots fulfillment.
type Card ¶
type Card struct { Type string `json:"type"` Title string `json:"title,omitempty"` Text string `json:"text,omitempty"` Content string `json:"content,omitempty"` Image *Image `json:"image,omitempty"` }
Card presents a card response.
type ConfirmationStatus ¶
type ConfirmationStatus string
ConfirmationStatus represents confirmationStatus in JSON.
type Context ¶
type Context struct { System *ContextSystem `json:"System,omitempty"` AudioPlayer *ContextAudioPlayer `json:"audioPlayer,omitempty"` Viewport *ContextViewport `json:"Viewport,omitempty"` Viewports []*ContextViewportType `json:"Viewports,omitempty"` }
Context represents the Alexa skill request context.
type ContextApplication ¶
type ContextApplication struct {
ApplicationID string `json:"applicationId"`
}
ContextApplication is used to verify that the request was intended for your service
The ID is the application ID for your skill.
type ContextAudioPlayer ¶
type ContextAudioPlayer struct { Token string `json:"token"` OffsetInMilliseconds int `json:"offsetInMilliseconds"` PlayerActivity AudioPlayerActivity `json:"playerActivity"` }
ContextAudioPlayer is available when the device has an audio player.
type ContextSystem ¶
type ContextSystem struct { // APIAccessToken a string containing a token that can be used to access Alexa-specific APIs APIAccessToken string `json:"apiAccessToken,omitempty"` // APIEndpoint a string that references the correct base URI to refer to by region, for use with APIs APIEndpoint string `json:"apiEndpoint,omitempty"` User *ContextUser `json:"user,omitempty"` // Device provides information about the device used to send the request Device struct { DeviceID string `json:"deviceId,omitempty"` SupportedInterfaces map[string]struct{} `json:"supportedInterfaces,omitempty"` } `json:"device,omitempty"` Application *ContextApplication `json:"application"` // Unit represents a logical construct organizing actors Unit struct { UnitID string `json:"unitId"` PersistentUnitID string `json:"persistentUnitId"` } `json:"unit,omitempty"` // Person describes the person who is making the request to Alexa (user recognized by voice, not account) Person *ContextSystemPerson `json:"person,omitempty"` }
ContextSystem provides information about the current state of the Alexa service and the interacting device.
type ContextSystemPerson ¶
type ContextSystemPerson struct { PersonID string `json:"personId"` AccessToken string `json:"accessToken,omitempty"` }
ContextSystemPerson describes the person who is making the request to Alexa
This is the user recognized by voice, not account from which the request came.
type ContextUser ¶
type ContextUser struct { UserID string `json:"userId"` AccessToken string `json:"accessToken,omitempty"` }
ContextUser a string that represents a unique identifier for the Amazon account for which the skill is enabled.
type ContextViewport ¶
type ContextViewport struct { Experiences []*ViewportExperience `json:"experiences,omitempty"` Mode ContextViewportMode `json:"mode"` Shape ContextViewportShape `json:"shape"` PixelWidth int `json:"pixelWidth"` PixelHeight int `json:"pixelHeight"` CurrentPixelWidth int `json:"currentPixelWidth"` CurrentPixelHeight int `json:"currentPixelHeight"` DPI int `json:"dpi"` Touch []string `json:"touch"` Keyboard []string `json:"keyboard"` Video struct { Codecs []string `json:"codecs"` } `json:"video"` }
ContextViewport provides information about the viewport if the device has a screen.
type ContextViewportMode ¶
type ContextViewportMode string
ContextViewportMode is the mode for the device.
const ( // ContextViewportModeHUB defines a HUB device. ContextViewportModeHUB ContextViewportMode = "HUB" // ContextViewportModeTV defines a TV device. ContextViewportModeTV ContextViewportMode = "TV" // ContextViewportModePC defines a PC device. ContextViewportModePC ContextViewportMode = "PC" // ContextViewportModeMobile defines a MOBILE device. ContextViewportModeMobile ContextViewportMode = "MOBILE" // ContextViewportModeAuto defines a AUTO device. ContextViewportModeAuto ContextViewportMode = "AUTO" )
type ContextViewportShape ¶
type ContextViewportShape string
ContextViewportShape is the shape of the device.
const ( // ContextViewportShapeRound defines a round shape. ContextViewportShapeRound ContextViewportShape = "ROUND" // ContextViewportShapeRectangle defines a rectangular shape. ContextViewportShapeRectangle ContextViewportShape = "RECTANGLE" )
type ContextViewportType ¶
type ContextViewportType struct { ID string `json:"id"` Type string `json:"type"` Shape string `json:"shape"` DPI int `json:"dpi"` PresentationType string `json:"presentationType"` CanRotate bool `json:"canRotate"` Configuration struct { Current ViewportConfiguration `json:"current"` } `json:"configuration"` }
ContextViewportType defines an available viewport of the device.
type DialogStateType ¶
type DialogStateType string
DialogStateType represents JSON request `request.dialogState`
see https://developer.amazon.com/docs/custom-skills/delegate-dialog-to-alexa.html
const ( // DialogStateStarted defines a started dialog. DialogStateStarted DialogStateType = "STARTED" // DialogStateInProgress defines a dialog in progress. DialogStateInProgress DialogStateType = "IN_PROGRESS" // DialogStateCompleted defines a completed dialog. DialogStateCompleted DialogStateType = "COMPLETED" )
type Directive ¶
type Directive struct { Type DirectiveType `json:"type,omitempty"` SlotToElicit string `json:"slotToElicit,omitempty"` UpdatedIntent *Intent `json:"updatedIntent,omitempty"` PlayBehavior string `json:"playBehavior,omitempty"` AudioItem *AudioItem `json:"audioItem,omitempty"` }
Directive represents a response directive.
type DirectiveType ¶
type DirectiveType string
DirectiveType represents various Directive Types.
const ( DirectiveTypeDialogDelegate DirectiveType = "Dialog.Delegate" DirectiveTypeDialogElicitSlot DirectiveType = "Dialog.ElicitSlot" DirectiveTypeDialogConfirmSlot DirectiveType = "Dialog.ConfirmSlot" DirectiveTypeDialogConfirmIntent DirectiveType = "Dialog.ConfirmIntent" )
Directive types.
type Handler ¶
type Handler interface {
Serve(*ResponseBuilder, *RequestEnvelope)
}
Handler represents an alexa request handler.
type HandlerFunc ¶
type HandlerFunc func(*ResponseBuilder, *RequestEnvelope)
HandlerFunc is an adapter allowing a function to be used as a handler.
func (HandlerFunc) Serve ¶
func (fn HandlerFunc) Serve(b *ResponseBuilder, r *RequestEnvelope)
Serve serves the request.
type Image ¶
type Image struct { SmallImageURL string `json:"smallImageUrl,omitempty"` LargeImageURL string `json:"largeImageUrl,omitempty"` }
Image represents a card image.
type Intent ¶
type Intent struct { Name string `json:"name"` Slots map[string]*Slot `json:"slots"` ConfirmationStatus ConfirmationStatus `json:"confirmationStatus"` }
Intent is the Alexa skill intent.
type NotFoundError ¶
type NotFoundError struct {
// contains filtered or unexported fields
}
NotFoundError defines a generic not found error.
func (NotFoundError) Error ¶
func (e NotFoundError) Error() string
Error returns a string representing the error including the element missing.
type OutputSpeech ¶
type OutputSpeech struct { Type string `json:"type"` Text string `json:"text,omitempty"` SSML string `json:"ssml,omitempty"` PlayBehavior string `json:"playBehavior,omitempty"` }
OutputSpeech represents a speech response.
type PerAuthority ¶
type PerAuthority struct { Authority string `json:"authority"` Status *ResolutionStatus `json:"status,omitempty"` Values []*AuthorityValue `json:"values,omitempty"` }
PerAuthority encapsulates an Authority which is the source of the data provided.
type Reprompt ¶
type Reprompt struct {
OutputSpeech *OutputSpeech `json:"outputSpeech,omitempty"`
}
Reprompt represents a reprompt response.
type Request ¶
type Request struct { Type RequestType `json:"type"` RequestID string `json:"requestId"` Timestamp string `json:"timestamp"` Locale RequestLocale `json:"locale"` Intent Intent `json:"intent,omitempty"` Reason string `json:"reason,omitempty"` DialogState DialogStateType `json:"dialogState,omitempty"` Context *Context `json:"-"` Session *Session `json:"-"` }
Request represents the information about the request.
type RequestEnvelope ¶
type RequestEnvelope struct { Version string `json:"version"` Session *Session `json:"session"` Context *Context `json:"context"` Request *Request `json:"request"` }
RequestEnvelope represents the alexa request envelope.
func (*RequestEnvelope) ApplicationID ¶
func (r *RequestEnvelope) ApplicationID() (string, error)
ApplicationID returns the application ID from the session first, then system or returns an error
Use it to verify the request is meant for your Skill.
func (*RequestEnvelope) ContextPerson ¶
func (r *RequestEnvelope) ContextPerson() (*ContextSystemPerson, error)
ContextPerson returns the person in the context or returns an error if no person exists.
func (*RequestEnvelope) ContextUser ¶
func (r *RequestEnvelope) ContextUser() (*ContextUser, error)
ContextUser returns the user in the context or returns an error if no user exists.
func (*RequestEnvelope) Intent ¶
func (r *RequestEnvelope) Intent() (Intent, error)
Intent returns the intent or an empty intent.
func (*RequestEnvelope) IntentName ¶
func (r *RequestEnvelope) IntentName() string
IntentName returns the name of the intent or "" if it's no intent request.
func (*RequestEnvelope) IsIntentConfirmed ¶
func (r *RequestEnvelope) IsIntentConfirmed() bool
IsIntentConfirmed returns true if the confirmation status is CONFIRMED.
func (*RequestEnvelope) IsIntentRequest ¶
func (r *RequestEnvelope) IsIntentRequest() bool
IsIntentRequest returns tru when the request is a TypeIntentRequest.
func (*RequestEnvelope) RequestDialogState ¶
func (r *RequestEnvelope) RequestDialogState() DialogStateType
RequestDialogState returns the dialog state of the request.
func (*RequestEnvelope) RequestLocale ¶
func (r *RequestEnvelope) RequestLocale() string
RequestLocale returns the locale of the request as string (e.g. "en-US").
func (*RequestEnvelope) RequestType ¶
func (r *RequestEnvelope) RequestType() RequestType
RequestType returns the type of the request.
func (*RequestEnvelope) SessionID ¶
func (r *RequestEnvelope) SessionID() string
SessionID returns the sessionID or an empty string.
func (*RequestEnvelope) Slot ¶
func (r *RequestEnvelope) Slot(name string) (Slot, error)
Slot returns the named slot or an error.
func (*RequestEnvelope) SlotValue ¶
func (r *RequestEnvelope) SlotValue(name string) string
SlotValue returns the value of the slot if it exists.
func (*RequestEnvelope) Slots ¶
func (r *RequestEnvelope) Slots() map[string]*Slot
Slots returns the list of slots, an empty list if no intent was found.
func (*RequestEnvelope) System ¶
func (r *RequestEnvelope) System() (*ContextSystem, error)
System returns the system object if it exists in the context.
type RequestLocale ¶
type RequestLocale string
RequestLocale represents the locale of the request.
const ( // LocaleAmericanEnglish is the locale for American English. LocaleAmericanEnglish RequestLocale = "en-US" // LocaleAustralianEnglish is the locale for Australian English. LocaleAustralianEnglish RequestLocale = "en-AU" // LocaleBritishEnglish is the locale for UK English. LocaleBritishEnglish RequestLocale = "en-GB" // LocaleCanadianEnglish is the locale for Canadian English. LocaleCanadianEnglish RequestLocale = "en-CA" // LocaleCanadianFrench is the locale for Canadian French. LocaleCanadianFrench RequestLocale = "fr-CA" // LocaleFrench is the locale for French (France). LocaleFrench RequestLocale = "fr-FR" // LocaleGerman is the locale for standard dialect German (Germany). LocaleGerman RequestLocale = "de-DE" // LocaleIndianEnglish is the locale for Indian English. LocaleIndianEnglish RequestLocale = "en-IN" // LocaleItalian is the locale for Italian (Italy). LocaleItalian RequestLocale = "it-IT" // LocaleJapanese is the locale for Japanese (Japan). LocaleJapanese RequestLocale = "ja-JP" // LocaleMexicanSpanish is the locale for Mexican Spanish. LocaleMexicanSpanish RequestLocale = "es-MX" // LocaleSpanish is the for Spanish (Spain). LocaleSpanish RequestLocale = "es-ES" )
Locale constants.
type RequestType ¶
type RequestType string
RequestType represents JSON request `request.type`
see https://developer.amazon.com/docs/custom-skills/request-types-reference.html
const ( // TypeLaunchRequest defines a launch request type. TypeLaunchRequest RequestType = "LaunchRequest" // TypeIntentRequest defines a intent request type. TypeIntentRequest RequestType = "IntentRequest" // TypeSessionEndedRequest defines a session end request type. TypeSessionEndedRequest RequestType = "SessionEndedRequest" // TypeCanFulfillIntentRequest defines a can fulfill intent request type. TypeCanFulfillIntentRequest RequestType = "CanFulfillIntentRequest" )
Request type constants.
type ResolutionStatus ¶
type ResolutionStatus struct {
Code StatusCode `json:"code"`
}
ResolutionStatus indicates the results of attempting to resolve the user utterance against the defined slot types.
type Resolutions ¶
type Resolutions struct {
ResolutionsPerAuthority []*PerAuthority `json:"resolutionsPerAuthority"`
}
Resolutions is an Alexa skill resolution.
type Response ¶
Response wraps the data needed for a skill response.
func GetLocaleWithFallback ¶
func GetLocaleWithFallback(registry l10n.LocaleRegistry, locale string) (l10n.LocaleInstance, Response)
GetLocaleWithFallback falls back to default locale which must be considered carefully.
type ResponseBuilder ¶
type ResponseBuilder struct {
// contains filtered or unexported fields
}
ResponseBuilder builds a response.
func (*ResponseBuilder) AddDirective ¶
func (b *ResponseBuilder) AddDirective(directive *Directive) *ResponseBuilder
AddDirective adds a directive tp the response.
func (*ResponseBuilder) Build ¶
func (b *ResponseBuilder) Build() *ResponseEnvelope
Build builds the response from the given information.
func (*ResponseBuilder) With ¶
func (b *ResponseBuilder) With(resp Response)
With applies an Response.
func (*ResponseBuilder) WithCanFulfillIntent ¶
func (b *ResponseBuilder) WithCanFulfillIntent(response *CanFulfillIntent) *ResponseBuilder
WithCanFulfillIntent sets the can fulfill intent response on the response.
func (*ResponseBuilder) WithReprompt ¶
func (b *ResponseBuilder) WithReprompt(text string) *ResponseBuilder
WithReprompt sets the reprompt output speech on the response.
func (*ResponseBuilder) WithSessionAttributes ¶
func (b *ResponseBuilder) WithSessionAttributes(attr map[string]interface{}) *ResponseBuilder
WithSessionAttributes sets the session attributes on the response.
func (*ResponseBuilder) WithShouldEndSession ¶
func (b *ResponseBuilder) WithShouldEndSession(end bool) *ResponseBuilder
WithShouldEndSession determines if the session should end after the current response.
func (*ResponseBuilder) WithSimpleCard ¶
func (b *ResponseBuilder) WithSimpleCard(title, text string) *ResponseBuilder
WithSimpleCard sets a simple card on the response.
func (*ResponseBuilder) WithSpeech ¶
func (b *ResponseBuilder) WithSpeech(text string) *ResponseBuilder
WithSpeech sets the output speech on the response.
If the text contains SSML speak tags, it will be set as SSML speech, otherwise it will be set as plain text speech.
func (*ResponseBuilder) WithStandardCard ¶
func (b *ResponseBuilder) WithStandardCard(title, text string, image *Image) *ResponseBuilder
WithStandardCard sets a standard card on the response.
type ResponseEnvelope ¶
type ResponseEnvelope struct { Version string `json:"version"` SessionAttributes map[string]interface{} `json:"sessionAttributes,omitempty"` Response response `json:"response"` }
ResponseEnvelope represents the wrapper for a response.
type ResponseError ¶
type ResponseError interface { error Response(loc l10n.LocaleInstance) Response }
ResponseError defines a response error.
type ServeMux ¶
type ServeMux struct {
// contains filtered or unexported fields
}
ServeMux is an Alexa request multiplexer.
func NewServerMux ¶
NewServerMux creates a new server mux.
func (*ServeMux) HandleIntent ¶
HandleIntent registers the handler for the given intent.
func (*ServeMux) HandleIntentFunc ¶
func (m *ServeMux) HandleIntentFunc(intent string, handler HandlerFunc)
HandleIntentFunc registers the handler function for the given intent.
func (*ServeMux) HandleRequestType ¶
func (m *ServeMux) HandleRequestType(requestType RequestType, handler Handler)
HandleRequestType registers the handler for the given request type.
Any attempt to handle the IntentRequest type will be ignored, use Intent instead.
func (*ServeMux) HandleRequestTypeFunc ¶
func (m *ServeMux) HandleRequestTypeFunc(requestType RequestType, handler HandlerFunc)
HandleRequestTypeFunc registers the handler function for the given request type.
Any attempt to handle the IntentRequest type will be ignored, use Intent instead.
func (*ServeMux) Handler ¶
func (m *ServeMux) Handler(r *RequestEnvelope) (Handler, error)
Handler returns the matched handler for a request, or an error.
func (*ServeMux) Serve ¶
func (m *ServeMux) Serve(b *ResponseBuilder, r *RequestEnvelope)
Serve serves the matched handler.
type Server ¶
type Server struct {
Handler Handler
}
A Server defines parameters for running an Alexa server.
type Session ¶
type Session struct { New bool `json:"new"` SessionID string `json:"sessionId"` Application *ContextApplication `json:"application"` Attributes map[string]interface{} `json:"attributes"` User *ContextUser `json:"user"` }
Session represents the Alexa skill session.
type Slot ¶
type Slot struct { Name string `json:"name"` Value string `json:"value"` Resolutions *Resolutions `json:"resolutions"` Source string `json:"source"` SlotValue *SlotValue `json:"slotValue"` }
Slot is an Alexa skill slot.
func (*Slot) FirstAuthorityWithMatch ¶
func (s *Slot) FirstAuthorityWithMatch() (*PerAuthority, error)
FirstAuthorityWithMatch returns the first authority with ResolutionStatusMatch.
func (*Slot) SlotResolutionsPerAuthority ¶
func (s *Slot) SlotResolutionsPerAuthority() ([]*PerAuthority, error)
SlotResolutionsPerAuthority returns the list of ResolutionsPerAuthority.
type SlotValue ¶
type SlotValue struct { Type string `json:"type"` Value string `json:"value"` Resolutions *Resolutions `json:"resolutions"` }
SlotValue defines the value or values captured by the slot.
type StatusCode ¶
type StatusCode string
StatusCode represents the status code of a slot resolution.
const ( // ResolutionStatusMatch is the status code for match. ResolutionStatusMatch StatusCode = "ER_SUCCESS_MATCH" // ResolutionStatusNoMatch is the status code for no match. ResolutionStatusNoMatch StatusCode = "ER_SUCCESS_NO_MATCH" // ResolutionStatusTimeout is the status code for an error due to timeout. ResolutionStatusTimeout StatusCode = "ER_ERROR_TIMEOUT" // ResolutionStatusException is the status code for an error in processing. ResolutionStatusException StatusCode = "ER_ERROR_EXCEPTION" )
type Stream ¶
type Stream struct { Token string `json:"token,omitempty"` URL string `json:"url,omitempty"` OffsetInMilliseconds int `json:"offsetInMilliseconds,omitempty"` }
Stream represents a response directive audio item stream.
type TranslationError ¶
TranslationError defines a missing translation error.
func (TranslationError) Error ¶
func (e TranslationError) Error() string
Error returns a string representing the error including the key missing.
func (TranslationError) Response ¶
func (e TranslationError) Response(loc l10n.LocaleInstance) Response
Response returns a Response for the user.
type ViewportConfiguration ¶
type ViewportConfiguration struct { Video struct { Codecs []string `json:"codecs"` } `json:"video,omitempty"` Size struct { Type string `json:"type"` PixelWidth int `json:"pixelWidth"` PixelHeight int `json:"pixelHeight"` } `json:"size,omitempty"` }
ViewportConfiguration contains the viewport configuration of the device in use.
Directories ¶
Path | Synopsis |
---|---|
Package l10n provides locale helpers (LocaleRegistry) and predefined standard keys for Alexa skills
|
Package l10n provides locale helpers (LocaleRegistry) and predefined standard keys for Alexa skills |
Package skill serves generating the skill and model.
|
Package skill serves generating the skill and model. |
Package ssml provides functions to simplify working with SSML speech.
|
Package ssml provides functions to simplify working with SSML speech. |