-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathresponse.go
82 lines (73 loc) · 2.39 KB
/
response.go
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
package alexa
//NewSimpleResponse builds a session response
func NewSimpleResponse(title string, text string) Response {
r := Response{
Version: "1.0",
Body: ResBody{
OutputSpeech: &Payload{
Type: "PlainText",
Text: text,
},
Card: &Payload{
Type: "Simple",
Title: title,
Content: text,
},
ShouldEndSession: true,
},
}
return r
}
// Response Types
// Response is the response back to the Alexa speech service
type Response struct {
Version string `json:"version"`
SessionAttributes map[string]interface{} `json:"sessionAttributes,omitempty"`
Body ResBody `json:"response"`
}
// ResBody is the actual body of the response
type ResBody struct {
OutputSpeech *Payload `json:"outputSpeech,omitempty"`
Card *Payload `json:"card,omitempty"`
Reprompt *Reprompt `json:"reprompt,omitempty"`
Directives []Directives `json:"directives,omitempty"`
ShouldEndSession bool `json:"shouldEndSession"`
}
// Reprompt is imformation
type Reprompt struct {
OutputSpeech Payload `json:"outputSpeech,omitempty"`
}
// Directives is imformation
type Directives struct {
Type string `json:"type,omitempty"`
SlotToElicit string `json:"slotToElicit,omitempty"`
UpdatedIntent *UpdatedIntent `json:"UpdatedIntent,omitempty"`
PlayBehavior string `json:"playBehavior,omitempty"`
AudioItem struct {
Stream struct {
Token string `json:"token,omitempty"`
URL string `json:"url,omitempty"`
OffsetInMilliseconds int `json:"offsetInMilliseconds,omitempty"`
} `json:"stream,omitempty"`
} `json:"audioItem,omitempty"`
}
// UpdatedIntent is to update the Intent
type UpdatedIntent struct {
Name string `json:"name,omitempty"`
ConfirmationStatus string `json:"confirmationStatus,omitempty"`
Slots map[string]interface{} `json:"slots,omitempty"`
}
// Image ...
type Image struct {
SmallImageURL string `json:"smallImageUrl,omitempty"`
LargeImageURL string `json:"largeImageUrl,omitempty"`
}
// Payload ...
type Payload 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 Image `json:"image,omitempty"`
}