1
0 Comments

Building a chatbot with PHP / Laravel

I've been building a "chat with youtube video" bot on the side. Partly to play with the new versions of Laravel + Livewire (a PHP framework), but there's a bigger goal:

To show that AI/chatbot apps can be easily built with PHP (or any other language actually). It's not just a Python world out there :)

I've been mainly building in public on Twitter (see thread at https://twitter.com/farez/status/1684714891947765760) but here's a summary of the project.

The stack is Laravel, Livewire, Laravel Folio, Laravel Volt, AlpineJS, Tailwind, OpenAI's API, and PostgreSQL with the pgvector extension for storing vector embeddings. Most of the backend/AI code was taken from clarifypdf.com and repurposed for this project.

Most of the challenges around the AI I had already encountered while building clarifypdf.com, so in this project, most of the challenges I faced were with the new versions of the newer versions of Livewire, and a couple of newly released Livewire components: Folio and Volt. These are amazing tech but as they're still in beta, there are a few rough edges. But I think it's in a good place now for me to deploy it and get people to try it.

Some lessons learned:

  • Chat interface in general is such a versatile UI. Early-stage startups can benefit from a chat interface because it removes a lot of assumptions about how your users will want to interact with your product. And the chat transcript is a goldmine of feature requests! I wrote more about this in an earlier post.

  • Prompt engineering is a real skill. And this goes beyond just writing the prompt itself and includes at least a working knowledge of embeddings, conversation memory, and "meta-prompting" (writing prompts that create prompts). And you never stop tweaking your prompts - it's an ongoing process!

  • PHP is more than a capable language for building AI applications, and Laravel lets you do that with speed.

  • For video chatbots, YouTube's auto-transcription + LLMs is an amazing combo.

  • Be careful with LLM-associated costs. They can pile up quickly. You'll need to either price your services carefully or let users bring their own key.

  • OpenAI's API is an amazing prototyping platform. Yes, there are open source alternatives out there, but for startups or testing new AI features, building and supporting your own AI infrastructure is the wrong focus. It takes minutes to start using OpenAI's API (or any other 3rd party API). Get to product-market fit first and then you can migrate to your own infrastructure when you're scaling. And anyway, OpenAI's API is incredibly cheap.

I'll be releasing the source code for the 'chat with video' Laravel project this week. I'll share it here and on Twitter (https://twitter.com/farez) when I've put it on Github.

Meanwhile, here's a little demo: https://twitter.com/farez/status/1691452473624682496

on August 15, 2023
Trending on Indie Hackers
Build AI Agents & SaaS Apps Visually : Powered by Simplita ai User Avatar 31 comments You don't need to write the same thing again User Avatar 22 comments No Install, No Cost, Just Code User Avatar 20 comments Let’s Talk: What’s Missing in Today’s App Builders? User Avatar 17 comments 15 Years of Designmodo User Avatar 14 comments The Season of Creation Is Here — Textideo Is Giving Away Free Credits to Spark Your Ideas User Avatar 12 comments