# QThrive

Web-based chatbot to facilitate journalling and self-care. Built for QHacks 2017 @ Queen's University.
## Inspiration

Toronto is famous because it is tied for the second longest average commute time of any city (96 minutes, both ways). People love to complain about the TTC and many people have legitimate reasons for avoiding public transit. With our app, we hope to change this. Our aim is to change the public's perspective of transit in Toronto by creating a more engaging and connected experience.

## What it does

We built an iOS app that transforms the subway experience. We display important information to subway riders, such as ETA, current/next station, as well as information about events and points of interest in Toronto. In addition, we allow people to connect by participating in a local chat and multiplayer games.

We have small web servers running on ESP8266 micro-controllers that will be implemented in TTC subway cars. These micro-controllers create a LAN (Local Area Network) Intranet and allow commuters to connect with each other on the local network using our app. The ESP8266 micro-controllers also connect to the internet when available and can send data to Microsoft Azure.

## How we built it

The front end of our app is built using Swift for iOS devices, however, all devices can connect to the network and an Android app is planned for the future. The live chat section was built with JavaScript. The back end is built using C++ on the ESP8266 micro-controller, while a Python script handles the interactions with Azure. The ESP8266 micro-controller runs in both access point (AP) and station (STA) modes, and is fitted with a button that can push data to Azure.

## Challenges we ran into

Getting the WebView to render properly on the iOS app was tricky. There was a good amount of tinkering with configuration due to the page being served over http on a local area network (LAN).

Our ESP8266 Micro-controller is a very nifty device, but such a low cost device comes with strict development rules. The RAM and flash size were puny and special care was needed to be taken to ensure a stable foundation. This meant only being able to use vanilla JS (no Jquery, too big) and keeping code as optimized as possible. We built the live chat room with XHR and Ajax, as opposed to using a websocket, which is more ideal.

## Accomplishments that we're proud of

We are proud of our UI design. We think that our app looks pretty dope!

We're also happy of being able to integrate many different features into our project. We had to learn about communication between many different tech layers.

We managed to design a live chat room that can handle multiple users at once and run it on a micro-controller with 80KiB of RAM. All the code on the micro-controller was designed to be as lightweight as possible, as we only had 500KB in total flash storage.

## What we learned

We learned how to code as lightly as possible with the tight restrictions of the chip. We also learned how to start and deploy on Azure, as well as how to interface between our micro-controller and the cloud.

## What's next for Commutr

There is a lot of additional functionality that we can add, things like: Presto integration, geolocation, and an emergency alert system.

In order to host and serve larger images, the ESP8266' measly 500KB of storage is planning on being upgraded with an SD card module that can increase storage into the gigabytes. Using this, we can plan to bring fully fledged WiFi connectivity to Toronto's underground railway.
## 💡**Inspiration**

The apparent rise of mental health crises in post-secondary institutions over the past few years has unveiled a small part of a long existing issue. University students have always seemed a bit sad, but in all of history, it’s never been this bad. With 1 in 5 seriously contemplating suicide in the last year and nearly half in Ontario reporting unmet mental health needs, we could all use a caring, conventional, and confidential friend who points you in the right direction and answers any questions you may have. In creating TextChecks, our hope is to connect students to a system they can depend on as they undertake the process of understanding their identity and place in the world.

## 🧠**What it does**

TextChecks is an Azure conversational AI that can find local supports for students and answer any mental health questions by pulling from our database of three hundred medical articles and two common therapy workbooks. It can be accessed through SMS or our web interface. Users simply begin sending START and follow the prompts accordingly. It follows a phased approach and guides the user through viewing resources on their mental health topic of interest, learning about available supports near them, and free-for-all Q&A for any other questions they may have.

## 💻**How we built it**

The front-end of our web interface was built with HTML, CSS, JavaScript, and BootStrap. We use a Twilio API to enable text messaging and use the Azure Bot Service’s provided elements for the web chatbox. To generate all of our responses, we used Azure Cognitive Search and Language Studio to extract question-answer pairs from three hundred medical articles and two common therapy workbooks to train the model. When there isn’t a direct match, it parses over the full contents of each article and book to pick the best match.

## ❓**Challenges we ran into**

Our primary challenge was implementing the phased approach through the chatbot. Deciding the user flow and how we wanted information to be accessed was a significant factor in our application. We spent the most time with flow diagrams and maps, determining how users may interact with the application and translating it into Azure. Another challenge was ensuring data quality and ensuring our question-answer pairs had high confidence levels. In the beginning, we started with importing self-help books, but found that our question-answer pairs were often inaccurate. Instead, we opted for peer-reviewed medical articles and therapy workbooks that provided better pairing. We also wanted our application to work on desktop as well as mobile, and spent time tinkering with our front-end to ensure responsive design.

## 💗**Accomplishments that we're proud of**

1. Although some of us have created chatbots in the past, TextChecks exceeds their capabilities and utilizes additional technologies to offer a more personalized experience.
2. It can be difficult to control the quality of responses from the bot, but we are satisfied with our approach in creating more accurate question-answer pairs.
3. Our user interface is clean, simple, and easy to use. Our animated homepage is a bonus!
4. It was our first time working with the Twilio API and we were able to get our chatbot working in SMS in under 30 minutes!

## 📚**What we learned**

We thoroughly explored Azure Bot Service, Language Studio and Azure Cognitive Search to create our application, by seeing how their capabilities best fit with our desired application features. We also learned how to train our bot with quality data, as well as connect it to SMS!

## 🚘**What's next for TextChecks**

In the future, we hope to have users calling into an automated phone system enabled by Natural Language Understanding and text-to-speech services. We can also partner with universities themselves, connecting with databases and exam schedules to pre-emptively reach out to stressed students. Finally, we can work together with Kids Help Phones and other textable lines to help lighten their basic question-and-answer load and potentially reroute in distress to their counselors.