Documentation ¶
Index ¶
- Constants
- Variables
- func HTTPError(w http.ResponseWriter, logMsg string, err string, errCode int)
- func IsValidAlexaRequest(w http.ResponseWriter, r *http.Request) bool
- func New() supervisor.Pluggable
- func NewTrigger(eventBus bus.Bus) (tr triggers.ITrigger)
- type AlexaBind
- type AlexaPlugin
- type Config
- type ConfirmationStatus
- type Context
- type DialogType
- type Directive
- type EchoRespImage
- type EventAddedAlexaSkillModel
- type EventAlexaAction
- type EventDeletedAlexaSkill
- type EventUpdatedAlexaSkillModel
- type IServer
- type Intent
- type Reprompt
- type ReqBody
- type Request
- func (r *Request) AllSlots() map[string]Slot
- func (r *Request) GetIntentName() string
- func (r *Request) GetRequestType() string
- func (r *Request) GetSessionID() string
- func (r *Request) GetSlot(slotName string) (Slot, error)
- func (r *Request) GetSlotValue(slotName string) (string, error)
- func (r *Request) GetUserID() string
- func (r *Request) Locale() string
- func (r *Request) VerifyAppID(myAppID string) bool
- func (r *Request) VerifyTimestamp() bool
- type Resolution
- type ResolutionPerAuthority
- type RespBody
- type RespPayload
- type Response
- func (r *Response) Card(title string, content string) *Response
- func (r *Response) EndSession(flag bool) *Response
- func (r *Response) LinkAccountCard() *Response
- func (r *Response) OutputSpeech(text string) *Response
- func (r *Response) OutputSpeechSSML(text string) *Response
- func (r *Response) Reprompt(text string) *Response
- func (r *Response) RepromptSSML(text string) *Response
- func (r *Response) RespondToIntent(name DialogType, intent *Intent, slot *Slot) *Response
- func (r *Response) SimpleCard(title string, content string) *Response
- func (r *Response) StandardCard(title string, content string, smallImg string, largeImg string) *Response
- func (r *Response) String() ([]byte, error)
- type Server
- func (s *Server) AddSkill(skill *m.AlexaSkill)
- func (s Server) Auth(ctx *gin.Context)
- func (s *Server) DeleteSkill(skill *m.AlexaSkill)
- func (s *Server) OnAudioPlayerHandler(ctx *gin.Context, req *Request, resp *Response)
- func (s *Server) OnIntentHandle(ctx *gin.Context, req *Request, resp *Response)
- func (s *Server) OnLaunchHandler(ctx *gin.Context, req *Request, resp *Response)
- func (s *Server) OnSessionEndedHandler(ctx *gin.Context, req *Request, resp *Response)
- func (s *Server) Start()
- func (s *Server) Stop()
- func (s *Server) UpdateSkill(skill *m.AlexaSkill)
- type ServerLogger
- type Session
- type Skill
- func (h Skill) GetAppID() string
- func (h Skill) OnAudioPlayerState(ctx *gin.Context, req *Request, resp *Response)
- func (h *Skill) OnIntent(_ *gin.Context, req *Request, resp *Response)
- func (h *Skill) OnLaunch(_ *gin.Context, req *Request, resp *Response)
- func (h *Skill) OnSessionEnded(_ *gin.Context, req *Request, resp *Response)
- type Slot
- type Trigger
Constants ¶
const ( // TriggerName ... TriggerName = "alexa" // TriggerFunctionName ... TriggerFunctionName = "automationTriggerAlexa" )
const ( // Name ... Name = "alexa" // TopicPluginAlexa ... TopicPluginAlexa = "system/plugins/alexa" )
const ( // Started indicates that the dialog interaction has just begun. Started string = "STARTED" // InProgress indicates that the dialog interation is continuing. InProgress string = "IN_PROGRESS" // Completed indicates that the dialog interaction has finished. // The intent and slot confirmation status should be checked. Completed string = "COMPLETED" )
const (
// TriggerOptionSkillId ...
TriggerOptionSkillId = "skillId"
)
Variables ¶
var F embed.FS
Functions ¶
func HTTPError ¶
func HTTPError(w http.ResponseWriter, logMsg string, err string, errCode int)
HTTPError is a convenience method for logging a message and writing the provided error message and error code to the HTTP response.
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 Server 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: --insecure-skip-verify flag will disable all validations 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 AlexaBind ¶
type AlexaBind struct { Slots map[string]string `json:"slots"` // contains filtered or unexported fields }
AlexaBind ...
func NewAlexaBind ¶
NewAlexaBind ...
func (*AlexaBind) OutputSpeech ¶
OutputSpeech ...
type ConfirmationStatus ¶
type ConfirmationStatus string
ConfirmationStatus represents the status of either a dialog or slot confirmation.
const ( // ConfConfirmed indicates the intent or slot has been confirmed by the end user. ConfConfirmed ConfirmationStatus = "CONFIRMED" // ConfDenied means the end user indicated the intent or slot should NOT proceed. ConfDenied ConfirmationStatus = "DENIED" // ConfNone means there has been not acceptance or denial of the intent or slot. ConfNone ConfirmationStatus = "NONE" Version = "0.0.1" )
type Context ¶
type Context struct { System struct { Device struct { DeviceID string `json:"deviceId,omitempty"` } `json:"device,omitempty"` Application struct { ApplicationID string `json:"applicationId,omitempty"` } `json:"application,omitempty"` User struct { UserId string `json:"userId"` } `json:"user,omitempty"` ApiEndpoint string `json:"apiEndpoint"` ApiAccessToken string `json:"apiAccessToken"` } `json:"System,omitempty"` }
Context contains information about the context in which the request was sent. This could be information about the device from which the request was sent or about the invoked Server application.
type DialogType ¶
type DialogType string
Type will indicate type of dialog interaction to be sent to the user.
const ( // Delegate will indicate that the Server service should continue the dialog ineraction. Delegate DialogType = "Dialog.Delegate" // ElicitSlot will indicate to the Server service that the specific slot should be elicited from the user. ElicitSlot DialogType = "Dialog.ElicitSlot" // ConfirmSlot indicates to the Server service that the slot value should be confirmed by the user. ConfirmSlot DialogType = "Dialog.ConfirmSlot" // ConfirmIntent indicates to the Server service that the complete intent should be confimed by the user. ConfirmIntent DialogType = "Dialog.ConfirmIntent" )
type Directive ¶
type Directive struct { Type DialogType `json:"type"` UpdatedIntent *Intent `json:"updatedIntent,omitempty"` SlotToConfirm string `json:"slotToConfirm,omitempty"` SlotToElicit string `json:"slotToElicit,omitempty"` IntentToConfirm string `json:"intentToConfirm,omitempty"` }
Directive includes information about intents and slots that should be confirmed or elicted from the user. The type value can be used to delegate the action to the Server service. In this case, a pre-configured prompt will be used from the developer console.
type EchoRespImage ¶
type EchoRespImage struct { SmallImageURL string `json:"smallImageUrl,omitempty"` LargeImageURL string `json:"largeImageUrl,omitempty"` }
EchoRespImage represents a single image with two variants that should be returned as part of a response. Small and Large image sizes can be provided.
type EventAddedAlexaSkillModel ¶ added in v0.12.0
type EventAddedAlexaSkillModel struct {
Skill *m.AlexaSkill
}
EventAddedAlexaSkillModel ...
type EventAlexaAction ¶
type EventAlexaAction struct { SkillId int64 `json:"skill_id"` IntentName string `json:"intent_name"` Payload interface{} `json:"payload"` }
EventAlexaAction ...
type EventDeletedAlexaSkill ¶ added in v0.12.0
type EventDeletedAlexaSkill struct {
Skill *m.AlexaSkill
}
EventDeletedAlexaSkill ...
type EventUpdatedAlexaSkillModel ¶ added in v0.12.0
type EventUpdatedAlexaSkillModel struct {
Skill *m.AlexaSkill
}
EventUpdatedAlexaSkillModel ...
type IServer ¶
type IServer interface { Start() Stop() OnLaunchHandler(ctx *gin.Context, req *Request, resp *Response) OnIntentHandle(ctx *gin.Context, req *Request, resp *Response) OnSessionEndedHandler(ctx *gin.Context, req *Request, resp *Response) OnAudioPlayerHandler(ctx *gin.Context, req *Request, resp *Response) AddSkill(skill *m.AlexaSkill) UpdateSkill(skill *m.AlexaSkill) DeleteSkill(skill *m.AlexaSkill) }
IServer ...
type Intent ¶
type Intent struct { Name string `json:"name"` Slots map[string]Slot `json:"slots"` ConfirmationStatus ConfirmationStatus `json:"confirmationStatus"` }
Intent represents the intent that is sent as part of an Request. This includes the name of the intent configured in the Server developers dashboard as well as any slots and the optional confirmation status if one is needed to complete an intent.
type Reprompt ¶
type Reprompt struct {
OutputSpeech RespPayload `json:"outputSpeech,omitempty"`
}
Reprompt contains speech that should be spoken back to the end user to retrieve additional information or to confirm an action.
type ReqBody ¶
type ReqBody struct { Type string `json:"type"` RequestID string `json:"requestId"` Timestamp string `json:"timestamp"` Intent Intent `json:"intent,omitempty"` Reason string `json:"reason,omitempty"` Locale string `json:"locale,omitempty"` DialogState string `json:"dialogState,omitempty"` }
ReqBody contains all data related to the type of request sent.
type Request ¶
type Request struct { Version string `json:"version"` Session Session `json:"session"` Context Context `json:"context"` Request ReqBody `json:"request"` }
Request represents all fields sent from the Server service to the skillserver. Convenience methods are provided to pull commonly used properties out of the request.
func (*Request) AllSlots ¶
AllSlots will return a map of all the slots in the Request mapped by their name.
func (*Request) GetIntentName ¶
GetIntentName is a convenience method for getting the intent name out of an Request.
func (*Request) GetRequestType ¶
GetRequestType is a convenience method for getting the request type out of an Request.
func (*Request) GetSessionID ¶
GetSessionID is a convenience method for getting the session ID out of an Request.
func (*Request) GetSlotValue ¶
GetSlotValue is a convenience method for getting the value of the specified slot out of an Request as a string. An error is returned if a slot with that value is not found in the request.
func (*Request) GetUserID ¶
GetUserID is a convenience method for getting the user identifier out of an Request.
func (*Request) VerifyAppID ¶
VerifyAppID check that the incoming application ID matches the application ID provided when running the server. This is a step required for skill certification.
func (*Request) VerifyTimestamp ¶
VerifyTimestamp will parse the timestamp in the Request and verify that it is in the correct format and is not too old. True will be returned if the timestamp is valid; false otherwise.
type Resolution ¶
type Resolution struct {
ResolutionsPerAuthority []ResolutionPerAuthority `json:"resolutionsPerAuthority"`
}
Resolution contains the results of entity resolutions when it relates to slots and how the values are resolved. The resolutions will be organized by authority, for custom slots the authority will be the custom slot type that was defined. Find more information here: https://developer.amazon.com/docs/custom-skills/define-synonyms-and-ids-for-slot-type-values-entity-resolution.html#intentrequest-changes
type ResolutionPerAuthority ¶
type ResolutionPerAuthority struct { Authority string `json:"authority"` Status struct { Code string `json:"code"` } `json:"status"` Values []map[string]struct { Name string `json:"name"` ID string `json:"id"` } `json:"values"` }
ResolutionPerAuthority contains information about a single slot resolution from a single authority. The values silce will contain all possible matches for different slots. These resolutions are most interesting when working with synonyms.
type RespBody ¶
type RespBody struct { OutputSpeech *RespPayload `json:"outputSpeech,omitempty"` Card *RespPayload `json:"card,omitempty"` Reprompt *Reprompt `json:"reprompt,omitempty"` // Pointer so it's dropped if empty in JSON response. ShouldEndSession bool `json:"shouldEndSession"` Directives []*Directive `json:"directives,omitempty"` }
RespBody contains the body of the response to be sent back to the Server service. This includes things like the text that should be spoken or any cards that should be shown in the Server companion app.
type RespPayload ¶
type RespPayload struct { Type string `json:"type,omitempty"` Title string `json:"title,omitempty"` Text string `json:"text,omitempty"` SSML string `json:"ssml,omitempty"` Content string `json:"content,omitempty"` Image EchoRespImage `json:"image,omitempty"` }
RespPayload contains the interesting parts of the Echo response including text to be spoken, card attributes, and images.
type Response ¶
type Response struct { Version string `json:"version"` SessionAttributes map[string]interface{} `json:"sessionAttributes,omitempty"` Response RespBody `json:"response"` }
Response represents the information that should be sent back to the Server service from the skillserver.
func NewResponse ¶
func NewResponse() *Response
NewEchoResponse will construct a new response instance with the required metadata and an empty speech string. By default the response will indicate that the session should be ended. Use the `EndSession(bool)` method if the session should be left open.
func (*Response) Card ¶
Card will add a card to the Server app's response with the provided title and content strings.
func (*Response) EndSession ¶
EndSession is a convenience method for setting the flag in the response that will indicate if the session between the end user's device and the skillserver should be closed.
func (*Response) LinkAccountCard ¶
LinkAccountCard is used to indicate that account linking still needs to be completed to continue using the Server skill. This will force an account linking card to be shown in the user's companion app.
func (*Response) OutputSpeech ¶
OutputSpeech will replace any existing text that should be spoken with this new value. If the output needs to be constructed in steps or special speech tags need to be used, see the `SSMLTextBuilder`.
func (*Response) OutputSpeechSSML ¶
OutputSpeechSSML will add the text string provided and indicate the speech type is SSML in the response. This should only be used if the text to speech string includes special SSML tags.
func (*Response) Reprompt ¶
Reprompt will send a prompt back to the user, this could be used to request additional information from the user.
func (*Response) RepromptSSML ¶
RepromptSSML is similar to the `Reprompt` method but should be used when the prompt to the user should include special speech tags.
func (*Response) RespondToIntent ¶
func (r *Response) RespondToIntent(name DialogType, intent *Intent, slot *Slot) *Response
RespondToIntent is used to Delegate/Elicit/Confirm a dialog or an entire intent with user of server. The func takes in name of the dialog, updated intent/intent to confirm if any and optional slot value. It prepares a Echo Response to be returned. Multiple directives can be returned by calling the method in chain (eg. RespondToIntent(...).RespondToIntent(...), each RespondToIntent call appends the data to Directives array and will return the same at the end.
func (*Response) SimpleCard ¶
SimpleCard will indicate that a card should be included in the Server companion app as part of the response. The card will be shown with the provided title and content.
func (*Response) StandardCard ¶
func (r *Response) StandardCard(title string, content string, smallImg string, largeImg string) *Response
StandardCard will indicate that a card should be shown in the Server companion app as part of the response. The card shown will include the provided title and content as well as images loaded from the locations provided as remote locations.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server ...
func NewServer ¶
func NewServer(adaptors *adaptors.Adaptors, config Config, scriptService scripts.ScriptService, eventBus bus.Bus) *Server
NewServer ...
func (*Server) OnAudioPlayerHandler ¶
OnAudioPlayerHandler ...
func (*Server) OnIntentHandle ¶
OnIntentHandle ...
func (*Server) OnLaunchHandler ¶
OnLaunchHandler ...
func (*Server) OnSessionEndedHandler ¶
OnSessionEndedHandler ...
type ServerLogger ¶
type ServerLogger struct {
// contains filtered or unexported fields
}
ServerLogger ...
type Session ¶
type Session 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"` }
Session contains information about the ongoing session between the Server server and the skillserver. This session is stored as part of each request.
type Skill ¶
type Skill struct {
// contains filtered or unexported fields
}
Skill ...
func NewSkill ¶
func NewSkill(model *m.AlexaSkill, adaptors *adaptors.Adaptors, scriptService scripts.ScriptService, eventBus bus.Bus) (skill *Skill)
NewSkill ...
func (Skill) OnAudioPlayerState ¶
OnAudioPlayerState ...
type Slot ¶
type Slot struct { Name string `json:"name"` Value string `json:"value"` Resolutions Resolution `json:"resolutions"` ConfirmationStatus ConfirmationStatus `json:"confirmationStatus"` }
Slot represents variable values that can be sent that were specified by the end user when invoking the Server application.
type Trigger ¶
type Trigger struct {
// contains filtered or unexported fields
}
Trigger ...
func (Trigger) Subscribe ¶
func (t Trigger) Subscribe(options triggers.Subscriber) error
Subscribe ...
func (Trigger) Unsubscribe ¶
func (t Trigger) Unsubscribe(options triggers.Subscriber) error
Unsubscribe ...