By Luc Gendrot
You’ve probably arrived here after looking into similar apps (like Woebot) and naturally wondering: “how do I go about building something similar?”
And it’s no wonder. The promise of mobile health is something we’ve mentioned before, and health and wellness apps are particularly well-suited for capitalizing on this promise. In fact, a 2017 study found that the health and wellness app usage grew 330% in just the three years prior, and it shows no signs of having slowed down since then.
But enough hype, you want to know how to build a wellness chatbot. And fear not, dear reader, that’s exactly what I’m here to help you do. Having helped to build a chatbot or two in my time (and in the healthcare space, no less) I should be well suited to the task.
As a data scientist for Brook.AI, I worked on a conversationally-focused UI to deliver customers with real time contextual insights, recommendations and care circle support to help them manage their blood glucose and stay ‘in the zone’. NLP for healthcare is an area of domain experience as well as passion for me.
So without further ado, let’s get started. I’ve broken up this article into 3 sections:
1. Must Have Features
If I’m going to help you “build an app like woebot” then we’re probably going to want to examine what it is Woebot does, exactly.
Before you skip to the next section, though, rest assured that we’re going to avoid surface level descriptions of Woebot’s features like “it helps with peoples’ mental health!” like the plague. Instead we’ll focus on the individual components that underlie Woebot’s capabilities, like tree-based conversations, basic NLP, goal tracking, and data collection / analysis.
First off: Woebot is a chatbot so let’s take a look at how they typically work.
Natural Language Processing in a Chatbot
Whether you think chatbots are the cat’s pyjamas, or you’re more skeptical of their oft-touted promise, there’s no denying that chatbots in general are growing more and more popular (and lucrative) as interaction models.
Woebot, being a chatbot at its core, is not immune to the hype surrounding these robotic assistants. With phrases like “AI”, “machine learning”, and “natural language processing” thrown around a lot, it’s hard to know what’s hype and what’s reality. Take it from someone who’s been there: they’re a lot less complicated under the hood than they might seem.
Luckily for us, and anybody else hoping to emulate their success, the creators of Woebot published a fairly extensive research article back in 2017 about Woebot that briefly explains the nuts and bolts of Woebot’s chatbot aspects:
The overarching methodology was a decision tree with suggested responses that also accepted natural language inputs with discrete sections of natural language processing techniques embedded at specific points in the tree to determine routing to subsequent conversational nodes.
For the regular folks out there, that basically means Woebot uses pre-written mini conversations that follow a standard structure, and intent classification to determine which of those conversations to present to the user in any given interaction.
[Throw in some a similar example, if applicable, from your experience?]
The mini-conversations usually take the form of questions from Woebot, and a set of options for the user to respond with (usually a single word or an emoji) that determine how the conversation progresses. A bit like a conversation you’d see in a video game. In fact much of how the best chatbots are built nowadays, from the software to the writing methodology, finds inspiration in the game dev best-practices for dialogue trees. That’s right, the gamers did it first.
Small dialogue trees can be glued together in various ways, depending on what the user wants to talk about. The trick, then, is to figure out what the user wants to talk about. That’s where the aforementioned “intent classification” (and sometimes the concept of “entity recognition”) comes in. The nitty gritty of how IC and ER work is way beyond the scope of this article, but stay tuned for some helpful ways you can avoid having to get a PhD to build your chatbot.
Let’s walk through a contrived example of what this process might look like with a Woebot-like app, step-by-step:
- Bot asks “How are you feeling?”
- User responds with: “I’m feeling nervous about work”
- Bot processes that phrase and calculates that the user is likely feeling anxious about work.
- Bot says: “It sounds like you’re feeling anxious, right?”
- User confirms by selecting a thumbs up emoji as a pre-coded response.
- Bot starts the “anxiety” dialogue tree, which proceeds in a similar manner to steps 1-5.
At step 3 is where the NLU magic happens, and by picking up on the user’s intent (in this case to communicate their anxiety) the bot is able to respond with an appropriate conversation.
Woebot’s conversations are meant to at least partially mimic a real Cognitive Behavioral Therapy (CBT) session. And one of the biggest ideas in CBT is that simply being aware of your mood is a fundamentally powerful tool for reducing stress and anxiety.
And so, to help users regularly check in with their mood, Woebot periodically asks users how they are feeling, as well as how much they enjoyed a conversation.
With this data Woebot powers the rest of its features:
- Presenting videos on CBT techniques and concepts to help with a user’s current mood
- Check in with the user every day, and reward (with recognition) multi-day streaks and milestones.
- Regularly provide the user with feedback on trends in their mood over time.
- Help the creators to develop better conversations that help users more effectively, and learn at what point to show them to users.
And…well…that’s kind of all there is to Woebot. The secret sauce lies in the CBT framework and the personality that the developers have given Woebot, but at its core Woebot tracks users’ moods, and then presents them with CBT concepts to address them.
But, regardless of this seeming simplicity, Woebot does seem to help people reduce their anxiety and depression symptoms. In their study for JMIR Woebot’s creators not only found a significant decrease in depressive symptoms as compared to their control group. They also found that Woebot’s users were surprisingly sticky, with 83% of participants sticking around to provide data. Not only is this an impressive retention rate for an app in this space, it’s also much higher than the control group, which lost 31% of its participants before the end of the study. Clearly there is something to be said about Woebot’s methods.
2. The Perfect Chatbot? Advanced Features and Improvements
If the JMIR study is to be believed, Woebot gets some pretty impressive results for its participants. That doesn’t mean, however, that Woebot is perfect and its users had no complaints. On the contrary, the JMIR paper even has a whole section dedicated to user feedback about the entire experience. Using this feedback, we can figure out a couple “advanced” features that other chatbots in this space might seek to develop.
More Believable Conversations: Generating Text
One of the primary complaints of users in the Woebot study was that there was no real way to converse naturally with Woebot. Said one user:
“If I wanted to say something when Woebot expected an automated response (like me choosing an answer option) it seemed to really confuse Woebot.”
Because most of the “correct” responses to Woebot are presented as buttons for the user to click on, natural language response to Woebot’s questions are rather limited. As we discussed before, Woebot can pick up on some natural language when it comes to mood tracking, but unique, fully context-driven responses from a chatbot turns out to be a tall order.
For truly unique dialogue, chatbots would need to be able to generate text on the fly based on the context of the conversation. We’ve written before about the difficulty in creating such capability for your bot, but one needs to look no further than IBM’s Watson beating Ken Jennings at Jeopardy, Microsoft’s (rather disastrous) “Tay” (and the less disastrous Zo), or the myriad recent papers on the subject to know that it’s at least possible, if not impractical in 2019.
Let’s Keep Talking: More and Deeper Conversations
It might be difficult to create a chat system that generates novel phrases on its own, but adding more conversations is eminently doable. In fact, repetitive, short interactions were another source of consternation for users of Woebot.
Because each conversation with a decision-tree based chatbot is (mostly) self-contained, it’s relatively easy to write new conversations as time goes on.
In fact one way that I’ve seen to solve the earlier believability problem is to simply write as many possible scenarios and variants of conversations, and write up tons of “small talk” conversations with clever responses. It’s not quite the real thing, but convincing enough for plenty of users.
Now, because of the sensitive nature of the problems Woebot addresses, its creators go out of their way to make sure that Woebot can never be confused for a true conversational partner. Everything from its name (having “bot” in it), to its short conversations, to the explicit disclaimer in the study stating as much confirms this.
The folks at Woebot have strong opinions about their place in the treatment hierarchy, so this “obviously a bot” paradigm makes total sense for them.
However, if the illusion of deeper conversation is your goal, then consider building in some longform conversations with many branching paths to them.
Collect Different Types of Data
Of course there’s also the possibility for advanced conversations that incorporate information about the user. Woebot, for example, eventually asks the user about their gender expression and their age, and it’s a little unclear what Woebot does with that information after collecting it.
Imagine if, in a more advanced system, a chatbot was able to ask you if you had any pets, what their names were, and then they were able to incorporate your pet’s name into activity suggestions (“Maybe taking Fido for a quick walk will help with your anxiety”) or just simply into conversations for flavor.
You might also consider collecting other types of information on a daily basis. Food, sleep or exercise related data points come to mind as the most common that I’ve seen used. Depending on the type of data, you may even be able to integrate with Apple’s Healthkit, Google Fit, or 3rd party apps like Fitbit to passively collect information you can use in conversations.
3. Get a Jumpstart on Building Your App
Speaking of using 3rd party apps, let’s talk about how to go about building your chatbot, starting with one of our most common pieces of advice for developers of all stripes: don’t reinvent the wheel.
Don’t Reinvent the Wheel
You might recognize this piece of advice from our Ultimate Guide to Building Apps in 2019, and the idea remains the same here: if you can find a library or a 3rd party service and it makes sense, then you should absolutely use off-the-shelf components to handle some of your app’s functionality.
Specifically for a chatbot that might mean using Wit.ai to handle the intent classification and NLU capabilities. Wit.ai, an open source project owned by Facebook, provides developers with an API that, with some setup, accepts strings of text and outputs intents and labeled data. Wit.ai is completely free to use, but the servers which process your text are owned and operated by Wit.ai themselves. Likewise for LUIS, Microsoft’s entry in this space, or Google’s Dialogueflow both of which are free as well, up to a point.
If, on the other hand, total control over your app’s chat data is your goal then Rasa should be your go-to solution (and it’s my favorite, if I’m honest).
And just like the chatbot features, health data integration is likewise a (relatively) solved problem for developers depending on what your needs are. For consumer wearable data (think: fitbit, runkeeper, etc.) then services like exist.io, or gethealth.io might be right up your alley.
On the other hand, if you need more clinically focused data then our article on building mhealth apps in 2019 might be the best place to go for more information.
Find your Advantage!
You probably don’t want to build a carbon copy of another chatbot, and with some of the more complex parts of your bot handled by 3rd party projects we just mentioned you might be left thinking “well then what is there to innovate on?”
And that’s an excellent question, and again one which we’ve stressed the importance of in other articles. Using off-the-shelf components should free you up to innovate on the important aspects of your app, but which aspects are those? The answer in this case could be anything from building cooler, more contextually aware conversations (like we discussed above), to having the best content (like Woebot’s CBT videos), to having the sleekest UI design. What matters is that your app has something that it does better than anybody else to differentiate it from the panoply of other chatbots entering the market.
Finally: Find your Users and Help Them
With the ubiquity of NLP/NLU services, it’s no wonder that it’s been “the year of the chatbot” since approximately 2015. We’re still finding tons of different ways to use Chatbots to help people interact with services in their everyday lives.
From ordering pizzas, to controlling home automation hardware, to helping people keep track of their moods, chatbots are enabling near-scifi levels of convenience when they’re built purposefully to solve problems.
That being said, it’s easy to jump on the hype-train and find yourself building a chatbot for no other reason than it feels flashy and new. But like with all apps if you can find your users, identify the problem they’re having, and build a chatbot that solves that problem seamlessly, then you’ve got a plan for a successful app, and we hope that we’ve provided you with the information you need to execute on that plan. Happy building!
Looking to get started today? At Topflight Apps, we are ready to help you elevate an existing machine-learning app, or even prototype a machine-learning idea that’s been floating in your head for a while. We’re an excellent team of developer-founders who love solving the hard problems, and we’re always looking for inspiration for new projects.
Request a proposal, and we can get the ball rolling before you encounter another chatbot that couldn’t quite get the job done.
Looking for help with your app?
in record time with a product that’s set to win.