DEV Community

Cover image for Building "Journal Buddy": A Custom GPT for Personal Reflection
Nick
Nick

Posted on

Building "Journal Buddy": A Custom GPT for Personal Reflection

I've always wanted to be able to write a daily journal. The science is pretty clear about the benefits of journalling for mental health and wellbeing. The problem is, I'm not that good at writing and the thought of staring at a blank sheet of paper each day fills me with dread. There are other practical problems, I would need to remember to lug a notebook and pen around with me everywhere. It just seems impractical and a tricky habit to get to stick.

I recently read about GPT Actions available when you create a Custom GPT on OpenAI's platform. I've become increasingly reliant on GPT-4 as a useful pair programmer in my daily work as an engineer but had not explored making GPTs. I started thinking about creating a GPT that could help me specifically with journalling. I landed on a set of requirements for the MVP:

  • Provides useful prompts so that journalling is more of a conversation as opposed to a blank sheet of paper.
  • Has memory that so that it can prompt based on past events.
  • Can challenge you if you say things that contradict previous things.
  • Has appropriate privacy, I didn't want OpenAI using my journal.

This article delves into the technical intricacies of implementing "Journal Buddy" to meet the requirements above.

TLDR; It was super easy to implement and works surprisingly well.

How it works

Database

I spun up a simple MongoDB Atlas instance to store journal entries. These are simple objects containing a date and some markdown for the entry. The idea is that it isn't a full transcript of the conversation with Journal Buddy, but a summary that Journal Buddy creates.

HTTP API

I wrote a very minimal API in Go that has a GET route that currently just gets all the summary entries and a POST route that upserts a new summary on a specific date. At some point, this will probably be extended so I can get Journal Buddy to do either weekly or monthly summaries. The idea here is to provide more fine-grained data for more recent entries when getting context. For example, Journal Buddy could retrieve the daily summary for the past month, a monthly summary for 3 months preceding that, and then a yearly summary before that. I hosted this on Heroku and chucked some basic API key auth to keep things secure.

Custom GPT

The final piece of the puzzle was to create the custom GPT, this was as simple as describing what I wanted it to do and providing a bit of background about myself so each new instance would have the right context. Then I had to provide it with an OpenAPI schema so it knew how to interact with my API. It still blows my mind a little that all I have to do is give it this and it can parse it and understand how to use it. To be honest, this was the most difficult step since the default schema that Gorilla kicks out is version 2 as version 3 isn't supported, I ended up having to feed it through a converter and make some manual changes to get it to work.

Here's a screenshot of the final product:

Image description

You just have a chat to it and it prompts you with questions that help you reflect on your day and how you're feeling. It then summarises the conversation and stores it back in your private database.

You can even ask it to remind you of things that happened in the past, which is great for someone like me who is always forgetting things!

Image description

Overall, I'm super happy with Journal Buddy! I think someone even with fairly basic software experience could put something similar together. I'm interested in what other things I can do with GPT Actions, next on the list is to try and give a GPT eyes and a body by connecting one to a robot 🤖.

Top comments (0)