Esempio n. 1
0
func (ctx *requestContext) validateRequestType(req *ask.Request) bool {
	if !req.IsLaunchRequest() && !req.IsIntentRequest() && !req.IsSessionEndedRequest() {
		ctx.err(400, fmt.Errorf("Request type '%v' invalid", req.Body.Type))
		return false
	}
	return true
}
Esempio n. 2
0
func helloHandler(skill *jeeves.Skill, req *ask.Request) *ask.Response {
	resp := ask.NewResponse(req)

	if req.IsLaunchRequest() {
		log.Println("Launch request")
		resp.Body.OutputSpeech = ask.NewOutputSpeech("Your friendly neighborhood hello service is ready for commands.")
	} else if req.IsIntentRequest() {
		intentName := req.Body.Intent.Name
		log.Printf("Intent request: %v", intentName)

		switch intentName {
		case "SayHello":
			resp.Body.OutputSpeech = ask.NewOutputSpeech("Hi there!")
			resp.Body.Card = ask.NewCard("Hi there", "You asked me to say hello.")
		default:
			resp.Body.OutputSpeech = ask.NewOutputSpeech("Unknown command.")
		}
	} else if req.IsSessionEndedRequest() {
		log.Println("Session Ended request!")
	}

	return resp
}