| 1 | = PerfectFit |
| 2 | |
| 3 | PerfectFit is a project under Willem Paul Brinkman and Nele Albers. This project is about treating smoking addiction. The application available here is about motivating people to increase their physical activity by leading them through a dialog to set a daily running or walking target. |
| 4 | |
| 5 | == Technical details |
| 6 | |
| 7 | |
| 8 | The system contains two parts: |
| 9 | |
| 10 | * [source:PerfectFit/Web Web Component]. This presents the user with web (html) pages that form the user interface to the dialog. This artifact has the name "chatserver". |
| 11 | * [source:PerfectFit/Dialog Dialog Component]. This is is the core of the application: it handles all the dialog. This artifact has the name "movingdialog". |
| 12 | |
| 13 | == The Web Component |
| 14 | The entire Web Component is standard technology based on Apache Tomcat. It consists of 2 html pages, each containing a bit of javascript: |
| 15 | |
| 16 | 1. A questionnaire page. This is a standard web form where the user can enter his characteristics (or use the default). |
| 17 | 2. The dialog page. This part shows the dialog on a web page, styled closely to the original chatbot, and looks like WhatsApp. It communicates with the server to communicate with the Dialog Component to determine the dialog flow. |
| 18 | |
| 19 | === questionnaire page. |
| 20 | The Questionnaire form is a webpage form to inquire the user's characteristics. |
| 21 | The entire form (including some javascript) is in [source:PerfectFit/Web/src/main/webapp/form.html form.html] in the [source:PerfectFit/Web Web] project. |
| 22 | This webpage presents the user with a standard web form with a number of questions that characterise him. He can answer by clicking buttons and dragging sliders. |
| 23 | |
| 24 | After the user presses the button to complete the form, the javascript code collects the form information into a query string which is sent to the dialog page. |
| 25 | |
| 26 | |
| 27 | ==== User Characteristics |
| 28 | The form determines the following parameters that define the user's characteristics: |
| 29 | |
| 30 | ||parameter name||contents|| |
| 31 | ||godin_activity||godin value, a single number 0, 1 or 2 where higher means the user does more and/or more strenuous exercise during a week. || |
| 32 | ||exercise_se||exercise_se value in [0,100] where larger means the user can walk/run longer per week. || |
| 33 | ||exercise_identity||exercise_identity a value in [0,4] where higher means the user describes sees/describes himself as more physically active || |
| 34 | ||extraversion||extraversion value in [0,6] where higher means users rank themselves higher on an extraverted and reserved scale || |
| 35 | ||ttm_pa||level of actual physical activity in the last months, or planned by the user || |
| 36 | ||openness||openness value in [0,6] where higher means user rank themselves higher on an openness and conservative scale || |
| 37 | ||sitting_weekend||the number of hours the user spends sitting during the weekend || |
| 38 | ||age||age in years|| |
| 39 | ||household_income||the household income in british points per year|| |
| 40 | ||household_size||household size in number of people|| |
| 41 | |
| 42 | All these values are non-normalized raw values from the form. E.g. age is the real age in years. |
| 43 | |
| 44 | === dialog page |
| 45 | The dialog page is on [source:PerfectFit/Web/src/main/webapp/chat.html chat.html] in the [source:PerfectFit/Web Web] project. This page presents the user with a whatsapp-like page that closely resembles the original dialog look and feel. |
| 46 | |
| 47 | The page shows the stimulus text from the dialog system as a chatbot that types text to the user. |
| 48 | |
| 49 | When it's the turn of the user, he can type text or click a button, depending on the question from the dialog system. |
| 50 | |
| 51 | == The Dialog Component |
| 52 | The dialog component contains a number of components: |
| 53 | * The dialog specification which is a json file describing all states that can occur in the dialog and the transitions between them. |
| 54 | * The dialog core system which takes the dialog specification to generate questions from the user. The answers are then used to transition to the next state. |
| 55 | * A few custom dialog actions (java code) for a few specific steps in the dialog, the most interesting one being {{{Example.java}}} which finds 2 examples that best fit the user's characteristics. |
| 56 | |
| 57 | The following sections describe these in more detail. |
| 58 | |
| 59 | === Dialog Core System |
| 60 | The dialog core system is built on the [https://tracinsy.ewi.tudelft.nl/pubtrac/Utilities/wiki/dialogmanager dialog manager system].. Click the link for the details. This library takes a single json file containing the entire dialog description, plus possibly a number of additional actions (java code) and then can handle the entire dialog flow. |
| 61 | |
| 62 | === dialog specification |
| 63 | As mentioned, the core controls the entire dialog from the [source:PerfectFit/Dialog/src/main/resources/dialog.json single dialog.json] file. |
| 64 | The code is in [source:PerfectFit/Dialog Dialog]. and the artifact has the name "movingdialog". |
| 65 | |
| 66 | === Extra Actions |
| 67 | There are a number of additional nonstandard actions used in our dialog: |
| 68 | ||CheckDeadline||get a response to a suggested deadline. Will be either a confirmation message or error message.|| |
| 69 | ||DateString||convert given time (epoch = time since 1970 in seconds) to human readable string.|| |
| 70 | ||StringLength||get length of a param containing a string|| |
| 71 | ||Example||fetches the intro and goalhow text from the database and stores it in given fields. Also stores current time. This function assumes that the 10 parameters godin_activity ..... household_size have all been been set properly to their non-normalized values.|| |
| 72 | ||Time||get current time in seconds (since 1970)|| |
| 73 | ||TimeDifference||get difference between two timestamps (in seconds since 1970).|| |
| 74 | |
| 75 | The parameters are only used to select two examples. The custom update function [source:Dialog/src/main/java/tudelft/mentalhealth/perfectfit/updatefuncs/Example.java Example.java] does this, by picking the best and second-best match between the parameter settings and the settings of the 66 available examples in [source:PerfectFit/Dialog/src/main/resources/examples_with_user_data.csv examples_with_user_data.csv] |
| 76 | |
| 77 | |
| 78 | The entire dialog is specified in the file [source:PerfectFit/Dialog/src/main/resources/dialog.json dialog.json]. This is a json file that follows the specifications of the [https://tracinsy.ewi.tudelft.nl/pubtrac/Utilities/wiki/dialogmanager dialogmanager]. |
| 79 | |
| 80 | |
| 81 | ==== Example from Characteristics |
| 82 | The user's characteristics as descibed previously are used in the dialog to present two examples to the user. |
| 83 | To do this, the characteristic parameters are normalized first. |
| 84 | Normalization turns every parameter into a number between 0 and 1. |
| 85 | Normalization is done by applying the formula V_norm_=clamp((V_raw_ - min)/(max-min)) where the following min and max are used, and clamp(v) = 0 if v<0, v if 0<=v<=1, or 1 if v>1. |
| 86 | |
| 87 | ||value||min||max|| |
| 88 | ||ttm_pa|| 0.0 || 4.0 || |
| 89 | ||sitting_weekend||0||22|| |
| 90 | ||extraversion||0||5.5|| |
| 91 | ||openness_to_experiences||0||5|| |
| 92 | ||exercise_identity||0||3.7|| |
| 93 | ||godin_activity||0||2|| |
| 94 | ||exercise_se||0||100|| |
| 95 | ||age||0||52|| |
| 96 | ||household_income||0||12|| |
| 97 | ||houshold_size||0||6|| |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | === Build, install |
| 104 | Both the chatserver and the movingdialog are maven projects. To built, do the following on the command line: |
| 105 | 1. Switch to the movingdialog project and execute {{{mvn install}}} |
| 106 | 2. Switch to the chatserver project and execute {{{mvn install}}} |
| 107 | |
| 108 | The maven build process will download additional software libraries from the web, so you need internet access to build the software. |
| 109 | |
| 110 | After a succesfull build, there will be a single chatserver-X.Y.Z.war file inside the chatserver/target directory. This file contains everything needed to run the form and the chat. |
| 111 | To deploy this, the war file must be copied in a tomcat 8 (or higher) webapps directory after which the webpages are available to the world. |
| 112 | |
| 113 | [https://tomcat.apache.org/ Apache Tomcat] is a standard webserver, It is assumed the reader knows how to install, configure and use it. |
| 114 | |
| 115 | When installed, there appear two webpages on your server: |
| 116 | |
| 117 | 1. http:<your server name>/chatserver/form.html that is the entry point for users. The application only stores the user data and state for the duration of the session. This normally will be in memory. |
| 118 | 2. http://<your server name>/chatserver/chat.html. It must include a query string with the user characteristics. |
| 119 | Normally this page is not accessed directly by the user, but reached from the form.html page. Typically this url looks like this |
| 120 | http://localhost:8080/chatserver/chat.html?godin_activity=2&exercise_se=60.5&exercise_identity=2.67&extraversion=4.0&ttm_pa=1&openness_to_experiences=2.00&sitting_weekend=10&age=25&household_income=13&household_size=3 |
| 121 | |
| 122 | As usual, any issues are logged to the catalina.out file, check the tomcat documentations for details. |
| 123 | |
| 124 | |
| 125 | |
| 126 | == General project info |
| 127 | This section gives more general info about the project. |
| 128 | |
| 129 | PerfectFit Project partners are: |
| 130 | |
| 131 | ||Name||University||task|| |
| 132 | ||WillemPaul||Delft|| manager|| |
| 133 | ||Wouter||TUDelft||dialog rasa translation|| |
| 134 | ||Walter ||escience center||manager <w.baccinelli@esciencecenter.nl>|| |
| 135 | ||Nele Albers||TUDelft||manager?|| |
| 136 | ||Alkis||TUDelft||VR app, chatbot with AI|| |
| 137 | ||Milon van Vliet m.h.m.van_vliet@lumc.nl||LUMC (Leiden)||psychology, what causes cravings|| |
| 138 | ||Milan Vliet||LUMC||Dialog writing. || |
| 139 | ||Kristel Penitornas||Leiden||PhD Leiden Psychologie - dialog writing - the smoking dialog|| |
| 140 | ||Tess||LUMC||Social Health research assistent - dialog writing|| |
| 141 | ||Robin Richardson||Escience center|| || |
| 142 | ||Bendik ||TUDelft||student 3 months now on perfectfit|| |
| 143 | ||Bouke Scheltinga||UTwente||activity profiles, sensor data eg stappenteller,create & analyse users|| |
| 144 | |
| 145 | |
| 146 | |
| 147 | There are several software systems built for this project |
| 148 | * A stand-alone system with VR [wiki:CravingCues]. |
| 149 | * An app with virtual coach [https://github.com/PerfectFit-project/virtual-coach-main VirtualCoach] with a [https://github.com/PerfectFit-project/virtual-coach-issues/projects/15 ticket system] |
| 150 | |
| 151 | |
| 152 | Some more links and general project setup of the app: |
| 153 | * [https://play.google.com/store/apps/details?id=nl.sense.goalie2&hl=nl&gl=US NiceDay Healthcare nederland ] is used to create the app. NiceDay is made by [https://sense-health.com/ SenseHealth]. The sense-health page is not informative however; Maybe [https://nicedaynederland.nl/en/home-en/ this page] says more? They also have [https://github.com/senseobservationsystems/ this project] on github |
| 154 | * Netherlands eScience Center seems to coordinate the project |
| 155 | * A separate Sensor Data app and Database is used to collect and push the data |
| 156 | * "Conversation" chatbot using [https://rasa.com/blog/dialogue-policies-rasa-2/ Rasa]. Rasa uses learning data to train a network which steers the dialog. See also https://www.nsfwyoutube.com/watch?v=j90NvurJI4I&t=1s |
| 157 | * PaaS who hosts the PerfectFit services |
| 158 | |