예제 #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
}
예제 #2
0
파일: main.go 프로젝트: codykrieger/jeeves
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
}