-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
114 lines (103 loc) · 4.1 KB
/
main.go
File metadata and controls
114 lines (103 loc) · 4.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package main
import (
"github.com/aws/aws-lambda-go/lambda"
"github.com/nraboy/alexa-slick-dealer/alexa"
)
// type FeedResponse struct {
// Channel struct {
// Item []struct {
// Title string `xml:"title"`
// Link string `xml:"link"`
// } `xml:"item"`
// } `xml:"channel"`
// }
// func RequestFeed(mode string) (FeedResponse, error) {
// endpoint, _ := url.Parse("https://slickdeals.net/newsearch.php")
// queryParams := endpoint.Query()
// queryParams.Set("mode", mode)
// queryParams.Set("searcharea", "deals")
// queryParams.Set("searchin", "first")
// queryParams.Set("rss", "1")
// endpoint.RawQuery = queryParams.Encode()
// response, err := http.Get(endpoint.String())
// if err != nil {
// return FeedResponse{}, err
// } else {
// data, _ := ioutil.ReadAll(response.Body)
// var feedResponse FeedResponse
// xml.Unmarshal(data, &feedResponse)
// return feedResponse, nil
// }
// }
func IntentDispatcher(request alexa.Request) alexa.Response {
var response alexa.Response
if request.Body.Type == "LaunchRequest" {
response = alexa.NewRepromptResponse("Hello, Welcome to the unnofficial app for provisioning the Nokia Fabric Service System. How can I help you today?", "For instructions on what you can ask, please say help me.")
}
switch request.Body.Intent.Name {
case "CreateFabricIntent":
response = HandleCreateFabricIntent(request)
// case "PopularDealIntent":
// response = HandlePopularDealIntent(request)
case alexa.HelpIntent:
response = HandleHelpIntent(request)
case alexa.StopIntent:
response = HandleStopIntent(request)
case alexa.CancelIntent:
response = HandleStopIntent(request)
case "AboutIntent":
response = HandleAboutIntent(request)
case alexa.FallbackIntent:
response = HandleHelpIntent(request)
}
return response
}
func HandleCreateFabricIntent(request alexa.Request) alexa.Response {
var response alexa.Response
if request.Body.Intent.Slots["fab_type"].Value == "sandbox" {
response = alexa.NewRepromptResponse("I will create sandbox fabric with "+request.Body.Intent.Slots["settings_type"].Value+"settings", "a sandbox fabric I said")
} else if request.Body.Intent.Slots["fab_type"].Value == "real" {
response = alexa.NewRepromptResponse("I will create real fabric with"+request.Body.Intent.Slots["settings_type"].Value+"settings", "a real fabric I said")
} else if request.Body.Intent.Slots["fab_type"].Value == "demo" {
response = alexa.NewRepromptResponse("I will create a demo sandbox fabric with default settings", "a sandbox fabric I said")
} else {
response = alexa.NewRepromptResponse("Sorry, I don't know how to configure that yet", "I said that I don't know")
}
return response
}
// func HandlePopularDealIntent(request alexa.Request) alexa.Response {
// feedResponse, _ := RequestFeed("popdeals")
// var builder alexa.SSMLBuilder
// builder.Say("Here are the current popular deals:")
// builder.Pause("1000")
// for _, item := range feedResponse.Channel.Item {
// builder.Say(item.Title)
// builder.Pause("1000")
// }
// return alexa.NewSSMLResponse("Popular Deals", builder.Build())
// }
func HandleHelpIntent(request alexa.Request) alexa.Response {
var builder alexa.SSMLBuilder
builder.Say("Here are some of the things you can ask:")
builder.Pause("1000")
builder.Say("Create a sandbox fabric with default settings.")
builder.Pause("1000")
builder.Say("Create a real fabric with default settings.")
builder.Pause("1000")
builder.Say("Create a sandobox fabric with customize settings.")
builder.Pause("1000")
builder.Say("Create a real fabric with customize settings.")
return alexa.NewSSMLResponse("Slick Dealer Help", builder.Build())
}
func HandleAboutIntent(request alexa.Request) alexa.Response {
return alexa.NewSimpleResponseWithCard("About", "Fabric Builder was created by Guillermo Murguia in Antwerp, Belgium as an unofficial fabric builder application.")
}
func HandleStopIntent(request alexa.Request) alexa.Response {
return alexa.NewSimpleResponse("Cancel and Stop", "Goodbye")
}
func Handler(request alexa.Request) (alexa.Response, error) {
return IntentDispatcher(request), nil
}
func main() {
lambda.Start(Handler)
}