| paris.us
............Views...23Home Page
........Comment(Login First)
|
Give me a sample of a simple inexpensive AI program that I can code and run on my website? Yes. One of the simplest and cheapest AI applications you can run on your own website is a rule-based chatbot. It is not as powerful as ChatGPT, but it looks like AI to visitors, requires no monthly fees, and can be expanded later. 🧱 Example: Simple Website AI Chatbot Save this as chatbot.html: HTML <!DOCTYPE html> <html> <head> <title>Simple AI Chatbot</title> <style> #chatbox { border: 1px solid #ccc; width: 400px; height: 300px; overflow-y: auto; padding: 10px; } #userInput { width: 300px; } </style> </head> <body>  <h2>AI Assistant</h2>  <div id="chatbox"></div> <br>  <input type="text" id="userInput" placeholder="Ask me something"> <button onclick="chat()">Send</button>  <script> function getResponse(input) {  input = input.toLowerCase();  if (input.includes("hello")) return "Hello! How can I help you today?";  if (input.includes("price")) return "Please visit our pricing page.";  if (input.includes("hours")) return "We are open from 9 AM to 5 PM.";  if (input.includes("contact")) return "Email us at support@example.com";  return "I am still learning. Please rephrase your question."; }  function chat() {  var input = document.getElementById("userInput").value; var response = getResponse(input);  var chatbox = document.getElementById("chatbox");  chatbox.innerHTML += "<p><b>You:</b> " + input + "</p>" + "<p><b>AI:</b> " + response + "</p>";  document.getElementById("userInput").value = ""; } </script>  </body> </html> 🧱 Slightly Smarter AI Using PHP If your website already uses PHP, you can make it learn from a text file. ✅ knowledge.txt shipping=We ship within 24 hours. refund=Refunds are accepted within 30 days. contact=Call us at 555-1234. ✅ ai.php PHP <?php  $question = strtolower($_POST['question']);  $lines = file('knowledge.txt');  foreach ($lines as $line) {  list($keyword, $answer) = explode('=', trim($line), 2);  if (strpos($question, $keyword) !== false) { echo $answer; exit; } }  echo "I don't know the answer to that yet.";  ?> 🧱 Real AI Using OpenAI If you want a true AI chatbot on your website, you can send questions to an AI API: PHP $question = $_POST['question']; // Send question to AI API // Receive answer // Display answer to visitor This typically costs only a few cents per hundred conversations, depending on model selection. 🧱 An AI Project That Visitors Actually Find Useful Since you know PHP, a practical project would be: ✅ Upload a text file ✅ AI summarizes it ✅ AI counts ASCII characters ✅ AI checks for prohibited words ✅ AI rewrites text ✅ AI generates HTML or PHP code Those can be built in a few hundred lines of PHP and provide real value to visitors. For a first project on your website, I'd recommend an AI FAQ bot that answers questions about your site and products. It's simple, inexpensive, and can run entirely on your web server without monthly AI costs. |
0 Comments |