Documentation ¶
Index ¶
- Variables
- type Alexa
- type AudioItem
- type AudioPlayerDirective
- type Card
- type Context
- type DialogDirective
- type Image
- type Intent
- type IntentSlot
- type IntentSlotValue
- type OutputSpeech
- type Reprompt
- type Request
- type RequestEnvelope
- type RequestHandler
- type Resolutions
- type Response
- func (r *Response) AddAudioPlayer(playerType, playBehavior, streamToken, url string, offsetInMilliseconds int)
- func (r *Response) AddDialogDirective(dialogType, slotToElicit, slotToConfirm string, intent *Intent)
- 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 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 ¶
This section is empty.
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 AudioItem ¶
type AudioItem struct {
Stream Stream `json:"stream,omitempty"`
}
AudioItem contains an audio Stream definition for playback.
type AudioPlayerDirective ¶
type AudioPlayerDirective struct { Type string `json:"type"` PlayBehavior string `json:"playBehavior,omitempty"` AudioItem *AudioItem `json:"audioItem,omitempty"` }
AudioPlayerDirective contains device level instructions on how to handle the response.
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 Context ¶
type Context struct { System struct { Device struct { DeviceID string `json:"deviceId"` SupportedInterfaces struct { AudioPlayer struct { } `json:"AudioPlayer"` } `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"` // SlotValue is a BETA field and may be removed by Amazon without warning. // See https://developer.amazon.com/en-US/docs/alexa/custom-skills/collect-multiple-values-in-a-slot.html. SlotValue *IntentSlotValue `json:"slotValue,omitempty"` }
IntentSlot contains the data for one Slot
type IntentSlotValue ¶
type IntentSlotValue struct { Type string `json:"type"` Values []*IntentSlotValue `json:"values"` Value string `json:"value"` Resolutions *Resolutions `json:"resolutions,omitempty"` }
IntentSlotValue contains the value or values of a slot. When Type == "Simple", Value and Resolutions are populated. When Type == "List", Values is populated.
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 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 { Locale string `json:"locale"` Timestamp string `json:"timestamp"` Type string `json:"type"` RequestID string `json:"requestId"` 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) AddAudioPlayer ¶
func (r *Response) AddAudioPlayer(playerType, playBehavior, streamToken, url string, offsetInMilliseconds int)
AddAudioPlayer adds an AudioPlayer directive to the Response.
func (*Response) AddDialogDirective ¶
func (r *Response) AddDialogDirective(dialogType, slotToElicit, slotToConfirm string, intent *Intent)
AddDialogDirective adds a Dialog directive to the Response.
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]interface{} `json:"string"` } `json:"attributes"` User struct { UserID string `json:"userId"` AccessToken string `json:"accessToken"` } `json:"user"` Application struct { ApplicationID string `json:"applicationId"` } `json:"application"` }
Session contains the session data from the Alexa request.