-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
76 lines (57 loc) · 2.93 KB
/
main.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
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
import logging
import datetime
import string
from random import randint
from flask import Flask, render_template // importing working library
from flask_ask import Ask, statement, question, session // importing working library
app = Flask(__name__)
ask = Ask(app, "/")
log = logging.getLogger()
log.addHandler(logging.StreamHandler())
log.setLevel(logging.DEBUG)
logging.getLogger("flask_ask").setLevel(logging.DEBUG)
// Basic function which starts when skill is called. How to call skill -> see README
@ask.launch
def launch():
return question("Hello. My name is Alexa. I'm your new friend. What is your name?")
// Name gettin function. To call you have to answer previous function.
@ask.intent("whatIsYourName")
def nameIdentify(nickname):
with open("info.txt", "w") as myfile:
myfile.truncate()
myfile.write("Patient's name is {} \n".format(nickname))
return question("It's nice to meet you {}. How are you today? From 1 - 10. 1 is very sad. 10 is very happy".format(nickname)).reprompt("I didn't hear you")
// Mood getting function. To call you have to answer previous question.
@ask.intent("MyMoodIntent")
def what_is_my_mood(mood):
with open("info.txt", "a") as myfile:
myfile.write("Patient's mood at {} is {} \n".format(datetime.datetime.now().time(),mood))
if (mood >= 5):
return question("I like your mood today, are you hungry?").reprompt("I didn't hear you")
else:
return question("You're a sad kitty today, are you hungry? ").reprompt("I didn't hear you")
// ifHungry getting function. To call you have to answer previous question.
@ask.intent("ifHungry")
def hungry(hunger):
with open("info.txt", "a") as myfile:
myfile.write("Patient's answer on question if he is hungry was {} at {} \n".format(hunger,datetime.datetime.now().time()))
if (hunger == "yes"):
return question("Nurse is on her way already. Can I ask you one more question? What is your body temperature?").reprompt("I didn't hear you")
else:
return question("Seems good. Can I ask you one more question? What is your body temperature?").reprompt("I didn't hear you")
// Temperature getting function. To call you have to answer previous question
@ask.intent("MyTempIntent")
def my_temp_is(newTemp, convert={'newTemp' : int}):
#msg = "your temp is {}".format(newTemp)
with open("info.txt", "a") as myfile:
myfile.write("Patient's temperature at {} is {} \n \n".format(datetime.datetime.now().time(),newTemp))
if (newTemp >= 37):
return statement('Ohh, you seem to be sick, doctor is on his way. Data is collected. Thank you!').reprompt("I didn't hear you")
else:
return statement("You're healthy and ready for it! Data is collected. Thank you!").reprompt("I didn't hear you")
// Stopping function. To call you have to say: "Shut up!"
@ask.intent("AMAZON.StopIntent")
def stop():
return statement("I'm in tears!")
if __name__ == '__main__':
app.run(debug=True)