Documentation
¶
Overview ¶
Package alexa provides a way to write typed handlers for requests made from the Alexa Skill service.
Index ¶
- type ApplicationMux
- type AudioPlaybackFailedHandler
- type AudioPlaybackFailedRequest
- type AudioPlaybackRequest
- type AudioPlaybackStoppedHandler
- type AudioPlayer
- type AudioPlayerStopperQueueClearer
- type AudioPlayerStopperQueueClearerHandler
- type AudioQueueClearer
- type AudioStopper
- type AudioStopperQueueClearer
- type AudioStopperQueueClearerHandler
- type Handler
- type IntentRequest
- type LaunchRequest
- type PlaybackControllerRequest
- type PlaybackControllerRequestHandler
- type Response
- type SessionEndedRequest
- type SessionEndedRequestHandler
- type SystemExceptionEncounteredHandler
- type SystemExceptionEncounteredRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApplicationMux ¶
An ApplicationMux allows many handlers to be added by applicationId.
func (*ApplicationMux) Handle ¶
func (m *ApplicationMux) Handle(applicationID string, h Handler)
Handle associates the given applicationID with a handler.
func (*ApplicationMux) ServeHTTP ¶
func (m *ApplicationMux) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP routes a request to the appropriate Handler registered for the applicationId provided in the request.
type AudioPlaybackFailedHandler ¶
type AudioPlaybackFailedHandler func(AudioPlayerStopperQueueClearer, *AudioPlaybackFailedRequest) error
An AudioPlaybackFailedHandler is a function that responds to a request for when the playback of an audio file fails.
type AudioPlaybackFailedRequest ¶
type AudioPlaybackFailedRequest struct {
Version string `json:"version"`
Context struct {
System struct {
APIEndpoint string `json:"apiEndpoint"`
Application struct {
ID string `json:"applicationId"`
} `json:"application"`
User struct {
AccessToken string `json:"accessToken"`
ID string `json:"userId"`
Permissions struct {
ConsentToken string `json:"consentToken"`
} `json:"permissions"`
} `json:"user"`
} `json:"system"`
} `json:"context"`
Request struct {
Type string `json:"type"`
RequestID string `json:"requestId"`
Timestamp string `json:"timestamp"`
Token string `json:"token"`
OffsetInMilliseconds int `json:"offsetInMilliseconds"`
Locale string `json:"locale"`
Error struct {
Type string `json:"type"`
Message string `json:"message"`
PlaybackState struct {
Token string `json:"token"`
OffsetInMilliseconds int `json:"offsetInMilliseconds"`
PlayerActivity string `json:"playerActivity"`
} `json:"currentPlaybackState"`
} `json:"error"`
} `json:"request"`
}
An AudioPlaybackFailedRequest represents the payload provided by Amazon when audio playback enters a failed state.
type AudioPlaybackRequest ¶
type AudioPlaybackRequest struct {
Version string `json:"version"`
Context struct {
System struct {
APIEndpoint string `json:"apiEndpoint"`
Application struct {
ID string `json:"applicationId"`
} `json:"application"`
User struct {
AccessToken string `json:"accessToken"`
ID string `json:"userId"`
Permissions struct {
ConsentToken string `json:"consentToken"`
} `json:"permissions"`
} `json:"user"`
} `json:"system"`
} `json:"context"`
Request struct {
Type string `json:"type"`
RequestID string `json:"requestId"`
Timestamp string `json:"timestamp"`
Token string `json:"token"`
OffsetInMilliseconds int `json:"offsetInMilliseconds"`
Locale string `json:"locale"`
} `json:"request"`
}
An AudioPlaybackRequest represents the payload provided by amazon when the audio playback changes state.
type AudioPlaybackStoppedHandler ¶
type AudioPlaybackStoppedHandler func(*AudioPlaybackRequest) error
An AudioPlaybackStoppedHandler is a function that responds to a request for when the playback of an audio file stops.
type AudioPlayer ¶
type AudioPlayer interface {
ReplaceAllAudio(token, url string, offsetInMilliseconds int)
EnqueueAudio(token, url, expectedPreviousToken string, offsetInMilliseconds int)
ReplacedEnqueuedAudio(token, url string, offsetInMilliseconds int)
}
An AudioPlayer allows a handler to enqueue or replace the audio playing on a device.
type AudioPlayerStopperQueueClearer ¶
type AudioPlayerStopperQueueClearer interface {
AudioPlayer
AudioStopper
AudioQueueClearer
}
An AudioPlayerStopperQueueClearer allows a handler to play or enqueue audio to be played, stop any currently playing audio, or clear any queued audio on a device.
type AudioPlayerStopperQueueClearerHandler ¶
type AudioPlayerStopperQueueClearerHandler func(AudioPlayerStopperQueueClearer, *AudioPlaybackRequest) error
An AudioPlayerStopperQueueClearerHandler is a function that responds to any request where playing, stopping, or queue changes are allowed.
type AudioQueueClearer ¶
type AudioQueueClearer interface {
ClearEnqueuedAudio()
ClearAllAudio()
}
An AudioQueueClearer allows a handler to clear the current audio queue for a device.
type AudioStopper ¶
type AudioStopper interface {
StopAudio()
}
An AudioStopper allows a handler to stop the playback of audio on a device.
type AudioStopperQueueClearer ¶
type AudioStopperQueueClearer interface {
AudioStopper
AudioQueueClearer
}
An AudioStopperQueueClearer allows a handler to stop the currently playing audio for a device and clear any queued audio.
type AudioStopperQueueClearerHandler ¶
type AudioStopperQueueClearerHandler func(AudioStopperQueueClearer, *AudioPlaybackRequest) error
An AudioStopperQueueClearerHandler is a function that responds to any audio request where stopping and queue changes are allowed.
type Handler ¶
type Handler struct {
IntentRequest func(Response, *IntentRequest) error
LaunchRequest func(Response, *LaunchRequest) error
SessionEndedRequest SessionEndedRequestHandler
AudioPlaybackFailedRequest AudioPlaybackFailedHandler
AudioPlaybackFinishedRequest AudioStopperQueueClearerHandler
AudioPlaybackNearlyFinishedRequest AudioPlayerStopperQueueClearerHandler
AudioPlaybackStartedRequest AudioStopperQueueClearerHandler
AudioPlaybackStoppedRequest AudioPlaybackStoppedHandler
PlaybackControllerNextCommandRequest PlaybackControllerRequestHandler
PlaybackControllerPausedCommandRequest PlaybackControllerRequestHandler
PlaybackControllerPlayCommandRequest PlaybackControllerRequestHandler
PlaybackControllerPreviousCommandRequest PlaybackControllerRequestHandler
SystemExceptionRequest SystemExceptionEncounteredHandler
}
Handler allows for custom behavior to be attributed to specific request types.
type IntentRequest ¶
type IntentRequest struct {
Version string `json:"version"`
Context struct {
System struct {
APIEndpoint string `json:"apiEndpoint"`
Application struct {
ID string `json:"applicationId"`
} `json:"application"`
User struct {
AccessToken string `json:"accessToken"`
ID string `json:"userId"`
Permissions struct {
ConsentToken string `json:"consentToken"`
} `json:"permissions"`
} `json:"user"`
} `json:"system"`
} `json:"context"`
Session struct {
Application struct {
ID string `json:"applicationId"`
} `json:"application"`
Attributes map[string]interface{} `json:"attributes"`
ID string `json:"sessionId"`
New bool `json:"new"`
User struct {
AccessToken string `json:"accessToken"`
ID string `json:"userId"`
Permissions struct {
ConsentToken string `json:"consentToken"`
} `json:"permissions"`
} `json:"user"`
} `json:"session"`
Request struct {
RequestID string `json:"requestId"`
Timestamp string `json:"timestamp"`
DialogState string `json:"dialogState"`
Locale string `json:"locale"`
Intent struct {
Name string `json:"name"`
ConfirmationStatus string `json:"confirmationStatus"`
Slots map[string]struct {
Name string `json:"name"`
Value string `json:"value"`
ConfirmationStatus string `json:"confirmationStatus"`
Resolutions struct {
ResolutionsPerAuthority []struct {
Authority string `json:"authority"`
Status struct {
Code string `json:"code"`
} `json:"status"`
Values []struct {
Value struct {
Name string `json:"name"`
ID string `json:"id"`
} `json:"value"`
} `json:"values"`
} `json:"resolutionsPerAuthority"`
} `json:"resolutions"`
} `json:"slots"`
} `json:"intent"`
} `json:"request"`
}
IntentRequest represents they payload provided by Amazon when an Alexa Intent request is made.
type LaunchRequest ¶
type LaunchRequest struct {
Version string `json:"version"`
Context struct {
System struct {
APIEndpoint string `json:"apiEndpoint"`
Application struct {
ID string `json:"applicationId"`
} `json:"application"`
User struct {
AccessToken string `json:"accessToken"`
ID string `json:"userId"`
Permissions struct {
ConsentToken string `json:"consentToken"`
} `json:"permissions"`
} `json:"user"`
} `json:"system"`
} `json:"context"`
Session struct {
Application struct {
ID string `json:"applicationId"`
} `json:"application"`
Attributes map[string]interface{} `json:"attributes"`
ID string `json:"sessionId"`
New bool `json:"new"`
User struct {
AccessToken string `json:"accessToken"`
ID string `json:"userId"`
Permissions struct {
ConsentToken string `json:"consentToken"`
} `json:"permissions"`
} `json:"user"`
} `json:"session"`
Request struct {
Timestamp string `json:"timestamp"`
RequestID string `json:"requestId"`
Locale string `json:"locale"`
} `json:"request"`
}
A LaunchRequest represents the payload provided by Amazon when a launch request is made.
type PlaybackControllerRequest ¶
type PlaybackControllerRequest struct {
Version string `json:"version"`
Context struct {
System struct {
APIEndpoint string `json:"apiEndpoint"`
Application struct {
ID string `json:"applicationId"`
} `json:"application"`
User struct {
AccessToken string `json:"accessToken"`
ID string `json:"userId"`
Permissions struct {
ConsentToken string `json:"consentToken"`
} `json:"permissions"`
} `json:"user"`
} `json:"system"`
} `json:"context"`
Request struct {
RequestID string `json:"requestId"`
Timestamp string `json:"timestamp"`
Locale string `json:"locale"`
} `json:"request"`
}
A PlaybackControllerRequest represents the payload provided by Amazon when a controller state updates.
type PlaybackControllerRequestHandler ¶
type PlaybackControllerRequestHandler func(AudioPlayerStopperQueueClearer, *PlaybackControllerRequest) error
A PlaybackControllerRequestHandler is a function that will receive a request payload when the controller state updates.
type Response ¶
type Response interface {
LinkAccountCard()
PlainText(text string)
SSML(ssml string)
RepromptPlainText(text string)
RepromptSSML(ssml string)
ShouldEndSession(value bool)
SimpleCard(title, content string)
StandardCard(title, text, smallImageURL, largeImageURL string)
AudioPlayerStopperQueueClearer
}
A Response allows a handler to construct a valid response to return to the Alexa service.
type SessionEndedRequest ¶
type SessionEndedRequest struct {
Version string `json:"version"`
Context struct {
System struct {
APIEndpoint string `json:"apiEndpoint"`
Application struct {
ID string `json:"applicationId"`
} `json:"application"`
User struct {
AccessToken string `json:"accessToken"`
ID string `json:"userId"`
Permissions struct {
ConsentToken string `json:"consentToken"`
} `json:"permissions"`
} `json:"user"`
} `json:"system"`
} `json:"context"`
Session struct {
Application struct {
ID string `json:"applicationId"`
} `json:"application"`
Attributes map[string]interface{} `json:"attributes"`
ID string `json:"sessionId"`
New bool `json:"new"`
User struct {
AccessToken string `json:"accessToken"`
ID string `json:"userId"`
Permissions struct {
ConsentToken string `json:"consentToken"`
} `json:"permissions"`
} `json:"user"`
} `json:"session"`
Request struct {
Timestamp string `json:"timestamp"`
RequestID string `json:"requestId"`
Reason string `json:"reason"`
Error struct {
Type string `json:"type"`
Message string `json:"message"`
} `json:"error"`
Locale string `json:"locale"`
} `json:"request"`
}
A SessionEndedRequest represents the payload provided by Amazon when a session ended request is made.
type SessionEndedRequestHandler ¶
type SessionEndedRequestHandler func(*SessionEndedRequest) error
A SessionEndedRequestHandler is a function that will receive a request payload when a session is ended.
type SystemExceptionEncounteredHandler ¶
type SystemExceptionEncounteredHandler func(*SystemExceptionEncounteredRequest) error
A SystemExceptionEncounteredHandler is a function that can receive a request payload when a hardware exception is encountered.
type SystemExceptionEncounteredRequest ¶
type SystemExceptionEncounteredRequest struct {
Version string `json:"version"`
Context struct {
System struct {
APIEndpoint string `json:"apiEndpoint"`
Application struct {
ID string `json:"applicationId"`
} `json:"application"`
User struct {
AccessToken string `json:"accessToken"`
ID string `json:"userId"`
Permissions struct {
ConsentToken string `json:"consentToken"`
} `json:"permissions"`
} `json:"user"`
} `json:"system"`
} `json:"context"`
Request struct {
Type string `json:"type"`
RequestID string `json:"requestId"`
Timestamp string `json:"timestamp"`
Locale string `json:"locale"`
Error struct {
Type string `json:"type"`
Message string `json:"message"`
} `json:"error"`
Cause struct {
RequestID string `json:"requestId"`
} `json:"cause"`
} `json:"request"`
}
A SystemExceptionEncounteredRequest represents the payload provided by Amazon when a system exception request is made.