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
I Was Picking the Wrong SaaS Tools for Two Years. Here's the Mistake I Finally Figured Out. User Avatar 120 comments Drop your landing page URL. I'll use Ferguson to tell you why visitors might be leaving User Avatar 101 comments I sold $6,773 in 2 weeks, with almost no existing community. User Avatar 38 comments Ferguson is LIVE on ProductHunt today... so I audited their homepage first! User Avatar 35 comments Why Remote Teams Stop Talking (And Don't Even Notice It) User Avatar 26 comments Built a local-first Amazon profit-by-SKU + QuickBooks/Xero journal tool. Looking for founding users. User Avatar 23 comments