-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathutils.js
58 lines (51 loc) · 1.56 KB
/
utils.js
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
const rePromptText = "What do you want me to do";
class Utils {
/**
* Format a response to send to the Echo
*
* @param title The title for the UI Card
* @param output The speech output
* @param repromptText The prompt for more information
* @param shouldEndSession A flag to end the session
* @returns A formatted JSON object containing the response
*/
static buildSpeechResponse(title, output, textToSpeak, shouldEndSession) {
let repromptText = rePromptText;
if (textToSpeak !== null) {
repromptText = textToSpeak;
}
return {
outputSpeech: {
type: "PlainText",
text: output
},
card: {
type: "Simple",
title: "Squeezebox Server - " + title,
content: "Squeezebox Server - " + output
},
reprompt: {
outputSpeech: {
type: "PlainText",
text: repromptText
}
},
shouldEndSession: shouldEndSession
};
}
/**
* Return the response
*
* @param sessionAttributes The attributes for the current session
* @param speechResponse The response object
* @returns A formatted object for the response
*/
static buildResponse(sessionAttributes, speechResponse) {
return {
version: "1.0",
sessionAttributes: sessionAttributes,
response: speechResponse
};
}
}
module.exports = Utils;