Documentation ¶
Index ¶
- Variables
- func SupportsDisplay(ctx *Context) bool
- func SupportsVideo(ctx *Context) bool
- type Alexa
- type AudioImage
- type AudioImageSource
- type AudioItem
- type AudioMetadata
- type Card
- type ClearBehavior
- type ClearQueueDirective
- type Context
- type DialogDirective
- type Image
- type Intent
- type IntentSlot
- type OutputSpeech
- type PlayAudioDirective
- type PlayBehavior
- type RenderDocumentDirective
- type Reprompt
- type Request
- type RequestEnvelope
- type RequestHandler
- type Resolutions
- type Response
- func (r *Response) AddClearQueueAudioPlayerDirective(clearBehavior ClearBehavior)
- func (r *Response) AddDialogDirective(dialogType, slotToElicit, slotToConfirm string, intent *Intent)
- func (r *Response) AddPlayAudioPlayerDirective(playBehavior PlayBehavior, streamToken, url string, offsetInMilliseconds int, ...)
- func (r *Response) AddRenderDocumentDirective(token string, document interface{}, datasources interface{}, ...)
- func (r *Response) AddStopAudioPlayerDirective()
- func (r *Response) SetLinkAccountCard()
- func (r *Response) SetOutputSSML(ssml string)
- func (r *Response) SetOutputText(text string)
- func (r *Response) SetRepromptSSML(ssml string)
- func (r *Response) SetRepromptText(text string)
- func (r *Response) SetSimpleCard(title string, content string)
- func (r *Response) SetStandardCard(title string, text string, smallImageURL string, largeImageURL string)
- type ResponseEnvelope
- type Session
- type StopAudioDirective
- type Stream
Constants ¶
This section is empty.
Variables ¶
var ErrRequestEnvelopeNil = errors.New("request envelope was nil")
ErrRequestEnvelopeNil reports that the request envelope was nil there might be edge case which causes panic if for whatever reason this object is empty
Functions ¶
func SupportsDisplay ¶
SupportsDisplay returns true if this skill was initiated from a device that supports video, false otherwise
func SupportsVideo ¶
SupportsVideo returns true if this skill was initiated from a device that supports video, false otherwise
Types ¶
type Alexa ¶
type Alexa struct { ApplicationID string RequestHandler RequestHandler IgnoreApplicationID bool IgnoreTimestamp bool }
Alexa defines the primary interface to use to create an Alexa request handler.
func (*Alexa) ProcessRequest ¶
func (alexa *Alexa) ProcessRequest(ctx context.Context, requestEnv *RequestEnvelope) (*ResponseEnvelope, error)
ProcessRequest handles a request passed from Alexa
func (*Alexa) SetTimestampTolerance ¶
SetTimestampTolerance sets the maximum number of seconds to allow between the current time and the request Timestamp. Default value is 150 seconds.
type AudioImage ¶
type AudioImage struct { ContentDescription string `json:"contentDescription,omitempty"` Sources []AudioImageSource `json:"sources"` }
AudioImage contains the data for images used within Audio Directives
type AudioImageSource ¶
type AudioImageSource struct { URL string `json:"url"` Size *string `json:"size,omitempty"` WidthPixels *int `json:"widthPixels,omitempty"` HeightPixels *int `json:"heightPixels,omitempty"` }
AudioImageSource contains the data for an image
type AudioItem ¶
type AudioItem struct { Stream Stream `json:"stream"` Metadata *AudioMetadata `json:"metadata,omitempty"` }
AudioItem contains an audio Stream definition for playback.
type AudioMetadata ¶
type AudioMetadata struct { Title string `json:"title,omitempty"` Subtitle string `json:"subtitle,omitempty"` Art *AudioImage `json:"art,omitempty"` BackgroundImage *AudioImage `json:"backgroundImage,omitempty"` }
AudioMetadata contains instructions for providing audio metadata
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"` }
Card contains the data displayed to the user by the Alexa app.
type ClearBehavior ¶
type ClearBehavior string
ClearBehavior Describes the clear behavior
const ( // ClearEnqueued ... ClearEnqueued ClearBehavior = "CLEAR_ENQUEUED" // ClearAll ... ClearAll ClearBehavior = "CLEAR_ALL" )
type ClearQueueDirective ¶
type ClearQueueDirective struct { Type string `json:"type"` ClearBehavior ClearBehavior `json:"clearBehavior"` }
ClearQueueDirective Clears the audio playback queue.
type Context ¶
type Context struct { System struct { Device struct { DeviceID string `json:"deviceId"` SupportedInterfaces struct { AudioPlayer struct{} `json:"AudioPlayer"` Display *struct{} `json:"Display"` VideoApp *struct{} `json:"VideoApp"` } `json:"supportedInterfaces"` } `json:"device"` Application struct { ApplicationID string `json:"applicationId"` } `json:"application"` User struct { UserID string `json:"userId"` AccessToken string `json:"accessToken"` Permissions struct { ConsentToken string `json:"consentToken"` } `json:"permissions"` } `json:"user"` APIEndpoint string `json:"apiEndpoint"` APIAccessToken string `json:"apiAccessToken"` } `json:"System"` AudioPlayer struct { PlayerActivity string `json:"playerActivity"` Token string `json:"token"` OffsetInMilliseconds int `json:"offsetInMilliseconds"` } `json:"AudioPlayer"` }
Context contains the context data from the Alexa Request.
type DialogDirective ¶
type DialogDirective struct { Type string `json:"type"` SlotToElicit string `json:"slotToElicit,omitempty"` SlotToConfirm string `json:"slotToConfirm,omitempty"` UpdatedIntent *Intent `json:"updatedIntent,omitempty"` }
DialogDirective contains directives for use in Dialog prompts.
type Image ¶
type Image struct { SmallImageURL string `json:"smallImageUrl,omitempty"` LargeImageURL string `json:"largeImageUrl,omitempty"` }
Image provides URL(s) to the image to display in resposne to the request.
type Intent ¶
type Intent struct { Name string `json:"name"` ConfirmationStatus string `json:"confirmationStatus,omitempty"` Slots map[string]IntentSlot `json:"slots"` }
Intent contains the data about the Alexa Intent requested.
type IntentSlot ¶
type IntentSlot struct { Name string `json:"name"` ConfirmationStatus string `json:"confirmationStatus,omitempty"` Value string `json:"value"` Resolutions *Resolutions `json:"resolutions,omitempty"` }
IntentSlot contains the data for one Slot
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.
type PlayAudioDirective ¶
type PlayAudioDirective struct { Type string `json:"type"` PlayBehavior PlayBehavior `json:"playBehavior"` AudioItem AudioItem `json:"audioItem"` }
PlayAudioDirective Sends Alexa a command to stream the audio file identified by the specified audioItem.
type PlayBehavior ¶
type PlayBehavior string
PlayBehavior Describes playback behavior
const ( // ReplaceAll ... ReplaceAll PlayBehavior = "REPLACE_ALL" // Enqueue ... Enqueue PlayBehavior = "ENQUEUE" // ReplaceEnqueued ... ReplaceEnqueued PlayBehavior = "REPLACE_ENQUEUED" )
type RenderDocumentDirective ¶
type RenderDocumentDirective struct { Type string `json:"type"` Token string `json:"token"` Document interface{} `json:"document"` DataSources interface{} `json:"datasources,omitempty"` Transformers []interface{} `json:"transformers,omitempty"` }
RenderDocumentDirective contain directives for use with Amazon APL documents
type Reprompt ¶
type Reprompt struct {
OutputSpeech *OutputSpeech `json:"outputSpeech,omitempty"`
}
Reprompt contains data about whether Alexa should prompt the user for more data.
type Request ¶
type Request struct { Type string `json:"type"` Timestamp string `json:"timestamp"` RequestID string `json:"requestId"` Locale string `json:"locale"` DialogState string `json:"dialogState"` Intent Intent `json:"intent"` Name string `json:"name"` }
Request contains the data in the request within the main request.
type RequestEnvelope ¶
type RequestEnvelope struct { Version string `json:"version"` Session *Session `json:"session"` Request *Request `json:"request"` Context *Context `json:"context"` }
RequestEnvelope contains the data passed from Alexa to the request handler.
type RequestHandler ¶
type RequestHandler interface { OnSessionStarted(context.Context, *Request, *Session, *Context, *Response) error OnLaunch(context.Context, *Request, *Session, *Context, *Response) error OnIntent(context.Context, *Request, *Session, *Context, *Response) error OnSessionEnded(context.Context, *Request, *Session, *Context, *Response) error }
RequestHandler defines the interface that must be implemented to handle Alexa Requests
type Resolutions ¶
type 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"` }
Resolutions contain the (optional) ID of a slot
type Response ¶
type Response struct { OutputSpeech *OutputSpeech `json:"outputSpeech,omitempty"` Card *Card `json:"card,omitempty"` Reprompt *Reprompt `json:"reprompt,omitempty"` Directives []interface{} `json:"directives,omitempty"` ShouldSessionEnd bool `json:"shouldEndSession"` }
Response contains the body of the response.
func (*Response) AddClearQueueAudioPlayerDirective ¶
func (r *Response) AddClearQueueAudioPlayerDirective(clearBehavior ClearBehavior)
AddClearQueueAudioPlayerDirective adds an AudioPlayer directive to clear the audio queue.
func (*Response) AddDialogDirective ¶
func (r *Response) AddDialogDirective(dialogType, slotToElicit, slotToConfirm string, intent *Intent)
AddDialogDirective adds a Dialog directive to the Response.
func (*Response) AddPlayAudioPlayerDirective ¶
func (r *Response) AddPlayAudioPlayerDirective(playBehavior PlayBehavior, streamToken, url string, offsetInMilliseconds int, metadata *AudioMetadata)
AddPlayAudioPlayerDirective adds an AudioPlayer directive to the Response.
func (*Response) AddRenderDocumentDirective ¶
func (r *Response) AddRenderDocumentDirective(token string, document interface{}, datasources interface{}, transforms []interface{})
AddRenderDocumentDirective adds a RenderDocument directive to the Response.
func (*Response) AddStopAudioPlayerDirective ¶
func (r *Response) AddStopAudioPlayerDirective()
AddStopAudioPlayerDirective adds an AudioPlayer directive to stop the Audio.
func (*Response) SetLinkAccountCard ¶
func (r *Response) SetLinkAccountCard()
SetLinkAccountCard creates a new LinkAccount card.
func (*Response) SetOutputSSML ¶
SetOutputSSML sets the OutputSpeech type to ssml and sets the value specified.
func (*Response) SetOutputText ¶
SetOutputText sets the OutputSpeech type to text and sets the value specified.
func (*Response) SetRepromptSSML ¶
SetRepromptSSML created a Reprompt if needed and sets the OutputSpeech type to ssml and sets the value specified.
func (*Response) SetRepromptText ¶
SetRepromptText created a Reprompt if needed and sets the OutputSpeech type to text and sets the value specified.
func (*Response) SetSimpleCard ¶
SetSimpleCard creates a new simple card with the specified content.
type ResponseEnvelope ¶
type ResponseEnvelope struct { Version string `json:"version"` SessionAttributes map[string]interface{} `json:"sessionAttributes,omitempty"` Response *Response `json:"response"` }
ResponseEnvelope contains the Response and additional attributes.
type Session ¶
type Session struct { New bool `json:"new"` SessionID string `json:"sessionId"` Attributes struct { String map[string]string `json:"string"` } `json:"attributes"` User struct { UserID string `json:"userId"` AccessToken string `json:"accessToken"` Permissions map[string]string `json:"permissions,omitempty"` } `json:"user"` Application struct { ApplicationID string `json:"applicationId"` } `json:"application"` }
Session contains the session data from the Alexa request.
type StopAudioDirective ¶
type StopAudioDirective struct {
Type string `json:"type"`
}
StopAudioDirective Stops the current audio playback.