Documentation ¶
Index ¶
- func HTTPError(w http.ResponseWriter, logMsg string, err string, errCode int)
- func IsValidAlexaRequest(w http.ResponseWriter, req *http.Request) bool
- type APLRenderDocumentDirective
- type Application
- type AudioItem
- type AudioPlayerDirective
- type Card
- type ConnectionsResponsePayload
- type ConnectionsResponseStatus
- type ConnectionsSendRequestDirective
- type ConnectionsSendRequestPayload
- type Context
- type Device
- type DialogDirective
- type Handler
- type Image
- type InSkillProduct
- type Intent
- type IntentSlot
- type Interaction
- type InteractionHistory
- type InteractionLogger
- type LaunchRequestMetadata
- type LaunchRequestTarget
- type NameID
- type OutputSpeech
- type Reprompt
- type Request
- type RequestEnvelope
- type Resolution
- type ResolutionsPerAuthority
- type Response
- type ResponseEnvelope
- type Session
- type SessionEndedError
- type Skill
- type Stream
- type System
- type User
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsValidAlexaRequest ¶
func IsValidAlexaRequest(w http.ResponseWriter, req *http.Request) bool
IsValidAlexaRequest handles all the necessary steps to validate that an incoming http.Request has actually come from the Alexa service. If an error occurs during the validation process, an http.Error will be written to the provided http.ResponseWriter. The required steps for request validation can be found on this page: https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/developing-an-alexa-skill-as-a-web-service#hosting-a-custom-skill-as-a-web-service
Types ¶
type APLRenderDocumentDirective ¶
type APLRenderDocumentDirective struct { Type string `json:"type"` Token string `json:"token"` Document *json.RawMessage `json:"document"` }
type Application ¶
type Application struct {
ApplicationID string `json:"applicationId"`
}
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 ConnectionsSendRequestDirective ¶
type ConnectionsSendRequestDirective struct { Type string `json:"type"` Name string `json:"name"` Payload ConnectionsSendRequestPayload `json:"payload"` Token string `json:"token"` }
type ConnectionsSendRequestPayload ¶
type ConnectionsSendRequestPayload struct {
InSkillProduct InSkillProduct `json:"InSkillProduct"`
}
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 Handler ¶
type Handler struct { Skill Skill Log *zap.SugaredLogger ExpectedApplicationID string SkipRequestValidation bool }
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 InSkillProduct ¶
type InSkillProduct struct {
ProductID string `json:"productId"`
}
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 *ResolutionsPerAuthority `json:"resolutions,omitempty"` }
IntentSlot contains the data for one Slot
type Interaction ¶
type Interaction struct { RequestID string `dynamodbav:"RequestID" json:"request_id"` RequestType string `dynamodbav:"RequestType" json:"request_type"` UnixTimestamp int64 `dynamodbav:"UnixTimestamp" json:"unix_timestamp"` Timestamp time.Time `dynamodbav:"Timestamp" json:"timestamp"` Locale string `dynamodbav:"Locale" json:"locale"` UserID string `dynamodbav:"UserID" json:"user_id"` SessionID string `dynamodbav:"SessionID" json:"session_id"` Attributes map[string]interface{} `dynamodbav:"Attributes" json:"attributes"` }
func InteractionFrom ¶
func InteractionFrom(requestEnv *RequestEnvelope) *Interaction
func (Interaction) WithAttributes ¶
func (i Interaction) WithAttributes(a map[string]interface{}) *Interaction
type InteractionHistory ¶
type InteractionHistory interface {
GetInteractionsByUser(userID string, nwerThan time.Time) []*Interaction
}
type InteractionLogger ¶
type InteractionLogger interface {
Log(*Interaction)
}
type LaunchRequestMetadata ¶
type LaunchRequestMetadata struct {
Referrer string `json:"referrer"`
}
type LaunchRequestTarget ¶
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 { Type string `json:"type"` RequestID string `json:"requestId"` Locale string `json:"locale"` Timestamp string `json:"timestamp"` DialogState string `json:"dialogState"` // Only for LaunchRequest Target *LaunchRequestTarget `json:"target"` Meta *LaunchRequestMetadata `json:"metadata"` Body interface{} `json:"body"` Payload json.RawMessage `json:"payload"` TargetUri string `json:"targetURI"` LaunchRequestType string `json:"launchRequestType"` ShouldLinkResultBeReturned bool `json:"shouldLinkResultBeReturned"` // Only for IntentRequest Intent Intent `json:"intent"` // Only for SessionEndedRequest Reason string `json:"reason"` Error *SessionEndedError `json:"error"` // Only for Connections.Response Name string `json:"name"` Status *ConnectionsResponseStatus `json:"status"` // Payload already defined for LaunchRequest Token string `json:"token"` }
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"` }
func (*RequestEnvelope) String ¶
func (requestEnv *RequestEnvelope) String() string
type Resolution ¶
type ResolutionsPerAuthority ¶
type ResolutionsPerAuthority struct {
ResolutionsPerAuthority []Resolution `json:"resolutionsPerAuthority"`
}
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.
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 map[string]interface{} `json:"attributes"` User User `json:"user"` Application Application `json:"application"` }
Session containes the session data from the Alexa request.
type SessionEndedError ¶
type Skill ¶
type Skill interface {
ProcessRequest(requestEnv *RequestEnvelope) *ResponseEnvelope
}
type Stream ¶
type Stream struct { Token string `json:"token"` URL string `json:"url"` OffsetInMilliseconds int `json:"offsetInMilliseconds"` }
Stream contains instructions on playing an audio stream.
type System ¶
type System struct { APIEndpoint string `json:"apiEndpoint"` APIAccessToken string `json:"apiAccessToken"` Application *Application `json:"application"` Device *Device `json:"device"` User *User `json:"user"` }