AI Chatbot for Your Website with ChatGPT
Add an AI assistant to your website in hours. The chatbot answers product questions and handles support 24/7.
PHP Backend
<?php
$systemPrompt = "You are a ZevsHost support assistant. Answer concisely and helpfully.";
$client = OpenAI::client($_ENV['OPENAI_API_KEY']);
$response = $client->chat()->create([
'model' => 'gpt-4o-mini',
'messages' => [
['role' => 'system', 'content' => $systemPrompt],
['role' => 'user', 'content' => $userMessage],
],
'max_tokens' => 400,
]);
echo json_encode(['reply' => $response->choices[0]->message->content]);Rate limiting: Protect your API: limit requests by IP (10/min), validate message length server-side.