-
Notifications
You must be signed in to change notification settings - Fork 0
/
alexa_response.py
39 lines (34 loc) · 1.14 KB
/
alexa_response.py
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
class AlexaResponse:
def __init__(self, output_text="", card_title="", card_content=""):
self.output_text = output_text
self.card_title = card_title
self.card_content = card_content
self.end_session = True
def set_output_text(self, output_text):
self.output_text = output_text
return self
def set_card_title(self, card_title):
self.card_title = card_title
return self
def set_card_content(self, card_content):
self.card_content = card_content
return self
def set_end_session(self, end_session):
self.end_session = end_session
return self
def response(self):
return {
"version": "1.0",
"response": {
"outputSpeech": {
"type": "SSML",
"ssml": "<speak>" + self.output_text + "</speak>",
},
"card": {
"type": "Simple",
"title": self.card_title,
"content": self.card_content,
},
"shouldEndSession": self.end_session
}
}