1. Go to this page and download the library: Download pkc/laravel-ai-chatbot library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pkc / laravel-ai-chatbot example snippets
use Laradevsumon\AIChatbot\Services\AIChatService;
$result = app(AIChatService::class)->ask(
prompt: 'Where is my order?',
role: 'customer',
context: ['order_id' => 'ORD-1001', 'status' => 'shipped']
);
if ($result['success']) {
echo $result['message'];
} else {
logger()->warning($result['error']);
}
use Laradevsumon\AIChatbot\Facades\AIChat;
$result = AIChat::ask('How do I process a refund?', 'admin');
[
'success' => true,
'message' => 'Your order is on the way.',
'provider' => 'groq',
'model' => 'llama-3.3-70b-versatile',
// 'error' => '...' // only on failure
]