Documentation ¶
Index ¶
- Variables
- func HTTPError(w http.ResponseWriter, logMsg string, err string, errCode int)
- func Init(apps map[string]interface{}, router *mux.Router)
- func IsValidAlexaRequest(w http.ResponseWriter, r *http.Request) bool
- func Run(apps map[string]interface{}, port string)
- func RunSSL(apps map[string]interface{}, port, cert, key string)
- func SetEchoPrefix(prefix string)
- func SetRootPrefix(prefix string)
- type ConfirmationStatus
- type DialogDirective
- type DialogState
- type DialogType
- type EchoApplication
- type EchoContext
- type EchoIntent
- type EchoReprompt
- type EchoReqBody
- type EchoRequest
- func (this *EchoRequest) AllSlots() map[string]EchoSlot
- func (this *EchoRequest) GetDialogState() DialogState
- func (this *EchoRequest) GetIntentConfirmationStatus() ConfirmationStatus
- func (this *EchoRequest) GetIntentName() string
- func (this *EchoRequest) GetRequestType() string
- func (this *EchoRequest) GetSessionID() string
- func (this *EchoRequest) GetSlot(slotName string) (EchoSlot, error)
- func (this *EchoRequest) GetSlotValue(slotName string) (string, error)
- func (this *EchoRequest) GetUserID() string
- func (this *EchoRequest) Locale() string
- func (this *EchoRequest) VerifyAppID(myAppID string) bool
- func (this *EchoRequest) VerifyTimestamp() bool
- type EchoResolution
- type EchoResolutionPerAuthority
- type EchoRespBody
- type EchoRespImage
- type EchoRespPayload
- type EchoResponse
- func (this *EchoResponse) Card(title string, content string) *EchoResponse
- func (this *EchoResponse) ConfirmIntent(intentToConfirm string, updatedIntent *EchoIntent) *EchoResponse
- func (this *EchoResponse) ConfirmSlot(slotToConfirm string, updatedIntent *EchoIntent) *EchoResponse
- func (this *EchoResponse) DialogDelegate(updatedIntent *EchoIntent) *EchoResponse
- func (this *EchoResponse) ElicitSlot(slotToElicit string, updatedIntent *EchoIntent) *EchoResponse
- func (this *EchoResponse) EndSession(flag bool) *EchoResponse
- func (this *EchoResponse) LinkAccountCard() *EchoResponse
- func (this *EchoResponse) OutputSpeech(text string) *EchoResponse
- func (this *EchoResponse) OutputSpeechSSML(text string) *EchoResponse
- func (this *EchoResponse) Reprompt(text string) *EchoResponse
- func (this *EchoResponse) RepromptSSML(text string) *EchoResponse
- func (this *EchoResponse) SimpleCard(title string, content string) *EchoResponse
- func (this *EchoResponse) StandardCard(title string, content string, smallImg string, largeImg string) *EchoResponse
- func (this *EchoResponse) String() ([]byte, error)
- type EchoSession
- type EchoSlot
- type SSMLTextBuilder
- func (builder *SSMLTextBuilder) AppendAmazonEffect(text, name string) *SSMLTextBuilder
- func (builder *SSMLTextBuilder) AppendAudio(src string) *SSMLTextBuilder
- func (builder *SSMLTextBuilder) AppendBreak(strength, time string) *SSMLTextBuilder
- func (builder *SSMLTextBuilder) AppendEmphasis(text, level string) *SSMLTextBuilder
- func (builder *SSMLTextBuilder) AppendParagraph(text string) *SSMLTextBuilder
- func (builder *SSMLTextBuilder) AppendPlainSpeech(text string) *SSMLTextBuilder
- func (builder *SSMLTextBuilder) AppendProsody(text, rate, pitch, volume string) *SSMLTextBuilder
- func (builder *SSMLTextBuilder) AppendSentence(text string) *SSMLTextBuilder
- func (builder *SSMLTextBuilder) AppendSubstitution(text, alias string) *SSMLTextBuilder
- func (builder *SSMLTextBuilder) Build() string
- type StdApplication
Constants ¶
This section is empty.
Variables ¶
var Applications = map[string]interface{}{}
var EchoPrefix = "/echo/"
var RootPrefix = "/"
Functions ¶
func IsValidAlexaRequest ¶
func IsValidAlexaRequest(w http.ResponseWriter, r *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
func RunSSL ¶
RunSSL takes in a map of application, server port, certificate and key files, and tries to start a TLS server which alexa can directly pass commands to. It panics out with the error if the server couldn't be started. Or else the method blocks at ListenAndServeTLS line. If the server starts succcessfully and there are connection errors afterwards, they are logged to the stdout and no error is returned. For generating a testing cert and key, read the following: https://developer.amazon.com/docs/custom-skills/configure-web-service-self-signed-certificate.html
func SetEchoPrefix ¶
func SetEchoPrefix(prefix string)
func SetRootPrefix ¶
func SetRootPrefix(prefix string)
Types ¶
type ConfirmationStatus ¶
type ConfirmationStatus string
const ( ConfirmationConfirmed ConfirmationStatus = "CONFIRMED" ConfirmationDenied ConfirmationStatus = "DENIED" )
type DialogDirective ¶
type DialogDirective struct { Type DialogType `json:"type,omitempty"` SlotToConfirm string `json:"slotToConfirm,omitempty"` SlotToElicit string `json:"slotToElicit,omitempty"` IntentToConfirm string `json:"intentToConfirm,omitempty"` UpdatedIntent *EchoIntent `json:"updatedIntent,omitempty"` }
type DialogState ¶
type DialogState string
const ( DialogStarted DialogState = "STARTED" DialogInProgress DialogState = "IN_PROGRESS" DialogCompleted DialogState = "COMPLETED" )
type DialogType ¶
type DialogType string
const ( DialogDelegate DialogType = "Dialog.Delegate" DialogElicitSlot DialogType = "Dialog.ElicitSlot" DialogConfirmSlot DialogType = "Dialog.ConfirmSlot" DialogConfirmIntent DialogType = "Dialog.ConfirmIntent" )
type EchoApplication ¶
type EchoApplication struct { AppID string Handler func(http.ResponseWriter, *http.Request) OnLaunch func(*EchoRequest, *EchoResponse) OnIntent func(*EchoRequest, *EchoResponse) OnSessionEnded func(*EchoRequest, *EchoResponse) OnAudioPlayerState func(*EchoRequest, *EchoResponse) }
type EchoContext ¶
type EchoIntent ¶
type EchoIntent struct { Name string `json:"name"` ConfirmationStatus ConfirmationStatus `json:"confirmationStatus,omitempty"` Slots map[string]EchoSlot `json:"slots"` }
type EchoReprompt ¶
type EchoReprompt struct {
OutputSpeech EchoRespPayload `json:"outputSpeech,omitempty"`
}
type EchoReqBody ¶
type EchoReqBody struct { Type string `json:"type"` RequestID string `json:"requestId"` Timestamp string `json:"timestamp"` Intent EchoIntent `json:"intent,omitempty"` Reason string `json:"reason,omitempty"` Locale string `json:"locale,omitempty"` DialogState DialogState `json:"dialogState,omitempty"` }
type EchoRequest ¶
type EchoRequest struct { Version string `json:"version"` Session EchoSession `json:"session"` Request EchoReqBody `json:"request"` Context EchoContext `json:"context"` }
func GetEchoRequest ¶
func GetEchoRequest(r *http.Request) *EchoRequest
func (*EchoRequest) AllSlots ¶
func (this *EchoRequest) AllSlots() map[string]EchoSlot
func (*EchoRequest) GetDialogState ¶
func (this *EchoRequest) GetDialogState() DialogState
func (*EchoRequest) GetIntentConfirmationStatus ¶
func (this *EchoRequest) GetIntentConfirmationStatus() ConfirmationStatus
func (*EchoRequest) GetIntentName ¶
func (this *EchoRequest) GetIntentName() string
func (*EchoRequest) GetRequestType ¶
func (this *EchoRequest) GetRequestType() string
func (*EchoRequest) GetSessionID ¶
func (this *EchoRequest) GetSessionID() string
func (*EchoRequest) GetSlotValue ¶
func (this *EchoRequest) GetSlotValue(slotName string) (string, error)
func (*EchoRequest) GetUserID ¶
func (this *EchoRequest) GetUserID() string
func (*EchoRequest) Locale ¶
func (this *EchoRequest) Locale() string
Locale returns the locale specified in the request.
func (*EchoRequest) VerifyAppID ¶
func (this *EchoRequest) VerifyAppID(myAppID string) bool
func (*EchoRequest) VerifyTimestamp ¶
func (this *EchoRequest) VerifyTimestamp() bool
Request Functions
type EchoResolution ¶
type EchoResolution struct {
ResolutionsPerAuthority []EchoResolutionPerAuthority `json:"resolutionsPerAuthority"`
}
type EchoRespBody ¶
type EchoRespBody struct { OutputSpeech *EchoRespPayload `json:"outputSpeech,omitempty"` Card *EchoRespPayload `json:"card,omitempty"` Reprompt *EchoReprompt `json:"reprompt,omitempty"` // Pointer so it's dropped ifempty in JSON response. Directives []*DialogDirective `json:"directives,omitempty"` ShouldEndSession bool `json:"shouldEndSession"` }
type EchoRespImage ¶
type EchoRespPayload ¶
type EchoResponse ¶
type EchoResponse struct { Version string `json:"version"` SessionAttributes map[string]interface{} `json:"sessionAttributes,omitempty"` Response EchoRespBody `json:"response"` }
func (*EchoResponse) Card ¶
func (this *EchoResponse) Card(title string, content string) *EchoResponse
func (*EchoResponse) ConfirmIntent ¶
func (this *EchoResponse) ConfirmIntent(intentToConfirm string, updatedIntent *EchoIntent) *EchoResponse
func (*EchoResponse) ConfirmSlot ¶
func (this *EchoResponse) ConfirmSlot(slotToConfirm string, updatedIntent *EchoIntent) *EchoResponse
func (*EchoResponse) DialogDelegate ¶
func (this *EchoResponse) DialogDelegate(updatedIntent *EchoIntent) *EchoResponse
func (*EchoResponse) ElicitSlot ¶
func (this *EchoResponse) ElicitSlot(slotToElicit string, updatedIntent *EchoIntent) *EchoResponse
func (*EchoResponse) EndSession ¶
func (this *EchoResponse) EndSession(flag bool) *EchoResponse
func (*EchoResponse) LinkAccountCard ¶
func (this *EchoResponse) LinkAccountCard() *EchoResponse
func (*EchoResponse) OutputSpeech ¶
func (this *EchoResponse) OutputSpeech(text string) *EchoResponse
func (*EchoResponse) OutputSpeechSSML ¶
func (this *EchoResponse) OutputSpeechSSML(text string) *EchoResponse
func (*EchoResponse) Reprompt ¶
func (this *EchoResponse) Reprompt(text string) *EchoResponse
func (*EchoResponse) RepromptSSML ¶
func (this *EchoResponse) RepromptSSML(text string) *EchoResponse
func (*EchoResponse) SimpleCard ¶
func (this *EchoResponse) SimpleCard(title string, content string) *EchoResponse
func (*EchoResponse) StandardCard ¶
func (this *EchoResponse) StandardCard(title string, content string, smallImg string, largeImg string) *EchoResponse
func (*EchoResponse) String ¶
func (this *EchoResponse) String() ([]byte, error)
type EchoSession ¶
type EchoSession struct { New bool `json:"new"` SessionID string `json:"sessionId"` Application struct { ApplicationID string `json:"applicationId"` } `json:"application"` Attributes map[string]interface{} `json:"attributes"` User struct { UserID string `json:"userId"` AccessToken string `json:"accessToken,omitempty"` } `json:"user"` }
type EchoSlot ¶
type EchoSlot struct { Name string `json:"name"` ConfirmationStatus ConfirmationStatus `json:"confirmationStatus,omitempty"` Value string `json:"value"` Resolutions EchoResolution `json:"resolutions"` }
type SSMLTextBuilder ¶
type SSMLTextBuilder struct {
// contains filtered or unexported fields
}
func NewSSMLTextBuilder ¶
func NewSSMLTextBuilder() *SSMLTextBuilder
func (*SSMLTextBuilder) AppendAmazonEffect ¶
func (builder *SSMLTextBuilder) AppendAmazonEffect(text, name string) *SSMLTextBuilder
func (*SSMLTextBuilder) AppendAudio ¶
func (builder *SSMLTextBuilder) AppendAudio(src string) *SSMLTextBuilder
func (*SSMLTextBuilder) AppendBreak ¶
func (builder *SSMLTextBuilder) AppendBreak(strength, time string) *SSMLTextBuilder
func (*SSMLTextBuilder) AppendEmphasis ¶
func (builder *SSMLTextBuilder) AppendEmphasis(text, level string) *SSMLTextBuilder
func (*SSMLTextBuilder) AppendParagraph ¶
func (builder *SSMLTextBuilder) AppendParagraph(text string) *SSMLTextBuilder
func (*SSMLTextBuilder) AppendPlainSpeech ¶
func (builder *SSMLTextBuilder) AppendPlainSpeech(text string) *SSMLTextBuilder
func (*SSMLTextBuilder) AppendProsody ¶
func (builder *SSMLTextBuilder) AppendProsody(text, rate, pitch, volume string) *SSMLTextBuilder
func (*SSMLTextBuilder) AppendSentence ¶
func (builder *SSMLTextBuilder) AppendSentence(text string) *SSMLTextBuilder
func (*SSMLTextBuilder) AppendSubstitution ¶
func (builder *SSMLTextBuilder) AppendSubstitution(text, alias string) *SSMLTextBuilder
func (*SSMLTextBuilder) Build ¶
func (builder *SSMLTextBuilder) Build() string
type StdApplication ¶
type StdApplication struct { Methods string Handler func(http.ResponseWriter, *http.Request) }