Menu

How to Add an AI Chatbot to Your Website (Grounded in Your Own Content)
📰

How to Add an AI Chatbot to Your Website (Grounded in Your Own Content)

DEV Community: php·Trevor H·13 days ago
#gh5drJZM
#devto#dev#heshbot#assistant#model
Reading 0:00
15s threshold

Most website chatbots fail the same way: they sound confident and get your hours, services or policies wrong. A chatbot is only useful if it answers from your content and admits when it doesn't know.

I built HeshBot , the assistant on my own site, to work exactly that way. Here's what a site assistant actually needs, using HeshBot as the worked example.

1. A small chat widget

The part visitors see is a chat button and a panel. HeshBot's widget is plain vanilla JavaScript with no framework and no third-party chat platform. It loads quickly, matches the site's look, and sends questions to one endpoint on your own hosting.

2. One server endpoint

Behind the widget is a single PHP 7.4 endpoint that runs on ordinary shared hosting. It receives a question, adds the right context from your content, calls the model, and returns the answer. Because it runs on your server, the API key stays on your server too, stored outside the web root where a browser can't reach it.

3.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.