4 min read

Phil – The Philosophical Chatbot

Phil – The Philosophical Chatbot

As I always say: to understand technology, you have to play with it. Over the years, I have built several projects to learn about networking, IoT, programming, and more. There is nothing more gratifying than seeing a project of yours finally work after battling with it for some time. In fact, the more you battle, the deeper your understanding tends to be. Sure, it might also end up being a bit more costly, but who cares?

Coming up with the idea

I wanted to build a fun little project that mixed two of my biggest passions: philosophy and chatbots. That is how I came up with the idea for Phil, a philosophical chatbot. Before jumping straight into the code, I took a few days to map out my approach. I asked myself crucial foundational questions: What functionalities should the chatbot have? Where will I host it? How should I structure its knowledge base? How will I configure the development environment? What will the user interface look like? How will I handle backups, and how many users do I expect?

Designing the backbone solution

Throughout the planning process, I bounced ideas off Gemini and ChatGPT to determine the best tech stack. First, I decided to host the chatbot in a Docker container on my Raspberry Pi (which, in another container, is already hosting this very blog).

Next, I needed an LLM to act as the chatbot's brain. While you can host local LLMs on a Raspberry Pi using tools like Ollama, they tend to be limited in capability and quite slow on that hardware. Therefore, I opted for an external LLM. Since I already had an OpenAI API key, I chose their ecosystem; models like gpt-4o-mini are incredibly cheap and more than powerful enough for a project like this. Finally, for the user interface, I chose Telegram. It is completely free, incredibly easy to connect via an API, and serves as the perfect frontend for a chatbot.

Setting up the environment

I wanted a seamless workflow that would allow me to write code and deploy updates with the click of a button. I chose Visual Studio Code, connected via SSH directly to the Raspberry Pi. VS Code is incredibly versatile—allowing me to manage databases and Docker containers all in one place. It also makes it easy to "vibecode" using various AI extensions like Claude, Windsurf, or GPT.

Turning the gears

I built the solution incrementally, testing the setup at every single step to ensure nothing broke.

  1. The Core Connection: I first built a basic chatbot script using the OpenAI API and linked it to Telegram using my API keys. I tested it, and the basic connection worked flawlessly.
  2. The Knowledge Base: Next, I structured the chatbot's knowledge. I set up a standard SQL database to store a curated list of quotes and philosophical questions.
  3. Implementing RAG: To give Phil deep conversational context, I implemented a RAG (Retrieval-Augmented Generation) system. (If you are interested in chatbots, RAG is a concept you absolutely must look into!) To populate the vector database, I used a large, personal document I’ve been adding to for years, filled with the best philosophical thoughts, quotes, and references I've encountered. Now, this custom database is queried every time a user asks Phil a question.
  4. Analytics: Finally, I vibecoded an analytical dashboard using Grafana so I could monitor the chatbot's usage metrics in real time.

Evolving Features

Once the core was stable, I began adding features one by one, making sure to test and commit my changes to Git after each addition. Here is a non-exhaustive list of Phil's current capabilities, which will undoubtedly grow as the project evolves:

  • Onboarding: A custom greeting that explains all of the chatbot's features.
  • Subscription-Based Daily Questions: Users can subscribe to receive one thought-provoking philosophical question every morning.
  • Evening Reflections: Subscribed users receive a global, synthesized summary of all members' insights regarding the topic of the day.
  • Random Quotes & Questions: Quick commands to pull random philosophical quotes or dilemmas directly from the SQL database.
  • Contextual Philosophy Chat: Full conversational capabilities powered by the custom RAG architecture.

Reflecting on the project

1. Side projects never truly end

Phil has quickly become my new daily companion; he sends me an inspiring quote every morning on Telegram. The project has been a success—I learned a ton, and I have a fun new toy to play with. Moving forward, I want to further develop the KPI and analytics side of the chatbot, which is essential for optimization. Once I am completely satisfied with its performance, I hope to open it up to more users.

2. Vibecoding is revolutionary, but it has limitations

AI-assisted coding has improved drastically over the last few months, and it allowed me to build this entire project in just a few days—a feat that easily would have taken me months in the past. However, it comes with a trade-off. Because the AI generated vast amounts of interconnected code rapidly, my chatbot is somewhat of a "black box" to me. I don’t fully understand every underlying mechanism, making me dependent on AI even for minor adjustments. I didn’t learn the raw coding mechanics as deeply as I initially wanted to, so I definitely plan to carve out time to audit and fully digest the codebase.

3. The more planning, the better the architecture

While this is a universal truth for any project manager, vibecoding amplified it. If your structural ideas and requirements aren't crystal clear from the very beginning, AI-generated code can quickly become messy.

4. The more technical you are, the better your vibecoding results will be

Vibecoding feels like magic, but its success relies heavily on the operator. The more technically precise, specific, and structured you are with your prompts and architectural demands, the more robust, clean, and scalable the final AI-generated solution will be.

If you want to try Phil, go on Telegram and search @PhilYourPhilosophicalBot