This is the implementation of the virtual coach Kai that proposes preparatory activities for quitting smoking or vaping (e.g., envisioning one's desired future self after quitting, creating a motivational slogan, learning how to get better sleep) in up to five sessions. Between the sessions, a human coach might send feedback messages to participants on the crowdsourcing platform Prolific.
The code is based on this Github repository, the work by Tom Jacobs, the implementation of the virtual coach Sam, and the implementation of the virtual coach Mel.
Each user can have up to 5 conversational sessions with Kai. These sessions have this structure:
A demo video of the third conversational session can be found here.
The preparatory activities that are proposed can be found in actions/Activities.xlsx
.
This virtual coach consists of a backend based on Rasa Open Source 3.2.8 (backend), a custom action server (actions), a frontend (frontend), a database (db), an SQLTrackerStore, and Nginx.
To run this project on a Google Compute Engine, I followed these steps:
-
Create a Google Compute Engine instance:
- Use Ubuntu 20.04.
- Make sure that the location is in Europe.
- Enable http and https traffic.
- Choose a small instance for the start, since you have to pay more for larger instances. I started with an e2-medium machine type and 100GB for the boot disk.
- The first 3 months you have some free credit.
- Follow the instructions from here in the sense that you “allow full access to all cloud APIs” on the Google Compute Engine instance. This is shown in this video: https://www.youtube.com/watch?v=qOHszxJsuGs&ab_channel=JiteshGaikwad. Also see this screenshot:
-
Open port 5005 for tcp on the Compute Engine instance:
- Follow the instructions from here for installing Docker on the Google Compute Engine instance. You can do this via the command line that opens after you click on "SSH":
-
Install docker-compose on the instance:
- I followed the steps described here:
curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
- You might need to add
sudo
in front of the commands to make them work.
- I followed the steps described here:
-
I suggest getting a static IP address for your Google Compute Engine instance:
- Follow the instructions here.
- You have to pay for every month, but it is rather cheap.
-
Make sure you turn off your instance whenever you do not need it, as you are charged for the time that it is up.
-
If you are NOT using Nginx, set the IP address of your Google Compute Engine instance in the function
send(message)
in the file frontend/static/js/script.js:url: "http://<your_instance_IP>:5005/webhooks/rest/webhook"
.- When you run the project locally, use
url: "http://localhost:5005/webhooks/rest/webhook"
.
- When you run the project locally, use
-
Clone your project from Github on the Google Compute Engine instance.
-
Navigate to your project folder on the Compute Engine instance and start your project with
docker-compose up
. -
Check if all your containers are running on your Google Compute Engine instance via
docker container ls
. -
You can access the frontend from your browser via
http://<your_instance_IP>/?userid=<some_user_id>&n=1&s=1
.n
determines which session is started (1-5). Earlier sessions need to be completed by a user to be able to access later ones.s
determines whether the session is run as a smoker or vaper.- If you are not using Nginx, you also need to specify the port number:
http://<your_instance_IP>:3000/?userid=<some_user_id>&n=1&s=1
.
-
The chat should look something like this:
This project uses an SQLTrackerStore to store the conversation history in a database:
- The database is persistent because of the "volumes" we specified in docker-compose.yml for postgres. Read more about this here.
- So you can run
docker-compose down --volumes
anddocker-compose up --build
and the database content is still there. - To delete the database content, just remove the "data"-folder on your Google Compute Engine instance.
- So you can run
The project further uses an mysql database to store specific data from the conversations:
- The database is also persistent. The folder "data_mysql" is used for this, as set up in
docker-compose.yml
. - To delete the database content, just delete the folder "data_mysql" on your Google Compute Engine instance.
- There are two tables:
- sessiondata: stores data from the sessions that we want to save (e.g., mood, experience with previous activity).
- users: stores the username for each user (set in session 1).
Some errors I got during the setup:
-
"Couldn't connect to Docker daemon at http+docker://localhost - is it running? If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable“ when running
docker-compose up –-build
.-
I followed the steps suggested here.
-
These 2 steps fixed the issue for me:
- Run
sudo docker-compose up –-build
.
- Run
-
-
When running the project locally on Windows, I got an error for the SQLTrackerStore when running
docker-compose up –-build
. Just removing the information onvolumes
in docker-compose.yml helped. This removes the persistence though.
Copyright (C) 2024 Delft University of Technology.
Licensed under the Apache License, version 2.0. See LICENSE for details.