github.com/arienmalec/alexa-go@v0.0.0-20181025212142-975687393e90/response.go (about) 1 package alexa 2 3 //NewSimpleResponse builds a session response 4 func NewSimpleResponse(title string, text string) Response { 5 r := Response{ 6 Version: "1.0", 7 Body: ResBody{ 8 OutputSpeech: &Payload{ 9 Type: "PlainText", 10 Text: text, 11 }, 12 Card: &Payload{ 13 Type: "Simple", 14 Title: title, 15 Content: text, 16 }, 17 ShouldEndSession: true, 18 }, 19 } 20 return r 21 } 22 23 // Response Types 24 25 // Response is the response back to the Alexa speech service 26 type Response struct { 27 Version string `json:"version"` 28 SessionAttributes map[string]interface{} `json:"sessionAttributes,omitempty"` 29 Body ResBody `json:"response"` 30 } 31 32 // ResBody is the actual body of the response 33 type ResBody struct { 34 OutputSpeech *Payload `json:"outputSpeech,omitempty"` 35 Card *Payload `json:"card,omitempty"` 36 Reprompt *Reprompt `json:"reprompt,omitempty"` 37 Directives []Directives `json:"directives,omitempty"` 38 ShouldEndSession bool `json:"shouldEndSession"` 39 } 40 41 // Reprompt is imformation 42 type Reprompt struct { 43 OutputSpeech Payload `json:"outputSpeech,omitempty"` 44 } 45 46 // Directives is imformation 47 type Directives struct { 48 Type string `json:"type,omitempty"` 49 SlotToElicit string `json:"slotToElicit,omitempty"` 50 UpdatedIntent *UpdatedIntent `json:"UpdatedIntent,omitempty"` 51 PlayBehavior string `json:"playBehavior,omitempty"` 52 AudioItem struct { 53 Stream struct { 54 Token string `json:"token,omitempty"` 55 URL string `json:"url,omitempty"` 56 OffsetInMilliseconds int `json:"offsetInMilliseconds,omitempty"` 57 } `json:"stream,omitempty"` 58 } `json:"audioItem,omitempty"` 59 } 60 61 // UpdatedIntent is to update the Intent 62 type UpdatedIntent struct { 63 Name string `json:"name,omitempty"` 64 ConfirmationStatus string `json:"confirmationStatus,omitempty"` 65 Slots map[string]interface{} `json:"slots,omitempty"` 66 } 67 68 // Image ... 69 type Image struct { 70 SmallImageURL string `json:"smallImageUrl,omitempty"` 71 LargeImageURL string `json:"largeImageUrl,omitempty"` 72 } 73 74 // Payload ... 75 type Payload struct { 76 Type string `json:"type,omitempty"` 77 Title string `json:"title,omitempty"` 78 Text string `json:"text,omitempty"` 79 SSML string `json:"ssml,omitempty"` 80 Content string `json:"content,omitempty"` 81 Image Image `json:"image,omitempty"` 82 }