1 /++ 2 + Authors: Stephan Dilly, lastname dot firstname at gmail dot com 3 + Copyright: MIT 4 +/ 5 module ask.types; 6 7 import vibe.data.serialization : name, optional, byName; 8 import vibe.data.json : Json; 9 import std.typecons : Nullable; 10 11 /// 12 struct AlexaUser 13 { 14 /// 15 string userId; 16 /// 17 @optional string accessToken; 18 } 19 20 /// 21 struct AlexaApplication 22 { 23 /// 24 string applicationId; 25 } 26 27 /// 28 struct AlexaOutputSpeech 29 { 30 /// 31 enum Type 32 { 33 PlainText, 34 SSML, 35 } 36 37 /// 38 @byName Type type = Type.PlainText; 39 /// 40 string text; 41 /// 42 string ssml; 43 } 44 45 /// see https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interface-reference#card-object 46 struct AlexaCard 47 { 48 49 /// 50 enum Type 51 { 52 Simple, 53 Standard, 54 LinkAccount 55 } 56 57 /// 58 @byName Type type = Type.Simple; 59 /// 60 string title; 61 /// 62 string text; 63 /// 64 string content; 65 66 /// 67 struct Image 68 { 69 /// 70 string smallImageUrl; 71 /// 72 string largeImageUrl; 73 } 74 75 /// 76 Image image; 77 } 78 79 /// 80 struct AlexaResponse 81 { 82 83 /// 84 struct Reprompt 85 { 86 /// 87 AlexaOutputSpeech outputSpeech; 88 } 89 90 /// 91 AlexaOutputSpeech outputSpeech; 92 /// 93 AlexaCard card; 94 /// 95 Nullable!Reprompt reprompt; 96 /// 97 bool shouldEndSession = true; 98 } 99 100 /// 101 struct AlexaResult 102 { 103 /// 104 @name("version") 105 string _version = "1.0"; 106 107 /// 108 Json[string] sessionAttributes; 109 110 /// 111 AlexaResponse response; 112 } 113 114 //TODO: 115 /// 116 /+struct AlexaDevice 117 { 118 supportedInterfaces 119 }+/ 120 121 /// see https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interface-reference#context-object 122 struct AlexaRequestContext 123 { 124 125 /// see https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interface-reference#system-object 126 struct AlexaSystem 127 { 128 /// 129 AlexaApplication application; 130 /// 131 AlexaUser user; 132 //TODO: 133 //AlexaDevice device; 134 } 135 136 /// 137 struct AlexaAudioPlayer 138 { 139 /// 140 @optional string token; 141 /// 142 @optional int offsetInMilliseconds; 143 /// 144 string playerActivity; 145 } 146 147 /// 148 @name("System") 149 AlexaSystem system; 150 /// 151 @name("AudioPlayer") 152 AlexaAudioPlayer audioPlayer; 153 } 154 155 /// 156 struct AlexaIntent 157 { 158 /// 159 struct AlexaSlot 160 { 161 /// 162 string name; 163 /// 164 @optional string value; 165 } 166 167 /// 168 string name; 169 /// 170 @optional AlexaSlot[string] slots; 171 } 172 173 /// 174 struct AlexaRequest 175 { 176 /// 177 struct Error 178 { 179 /// 180 string type; 181 /// 182 string message; 183 } 184 185 /// 186 enum Type 187 { 188 /// 189 LaunchRequest, 190 /// 191 IntentRequest, 192 /// 193 SessionEndedRequest 194 } 195 196 /// 197 @byName Type type; 198 /// 199 string requestId; 200 /// 201 string timestamp; 202 /// 203 string locale; 204 205 /// 206 @optional string reason; 207 208 /// 209 @optional Error error; 210 211 /// 212 @optional AlexaIntent intent; 213 } 214 215 /// see https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interface-reference#request-format 216 struct AlexaEvent 217 { 218 /// 219 struct Session 220 { 221 222 /// 223 @name("new") 224 bool _new; 225 /// 226 string sessionId; 227 /// 228 AlexaApplication application; 229 /// 230 @optional Json[string] attributes; 231 /// 232 AlexaUser user; 233 } 234 235 /// 236 @name("version") 237 string _version; 238 239 /// 240 Session session; 241 242 /// 243 AlexaRequest request; 244 } 245 246 /// 247 struct AlexaContext 248 { 249 /// 250 string functionName; 251 /// 252 string invokedFunctionArn; 253 /// 254 string awsRequestId; 255 /// 256 string logStreamName; 257 /// 258 string invokeid; 259 /// 260 bool callbackWaitsForEmptyEventLoop; 261 /// 262 string logGroupName; 263 /// 264 string functionVersion; 265 /// 266 string memoryLimitInMB; 267 }