1. Go to this page and download the library: Download emon/larabot-ai 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/ */
use Emon\LarabotAi\Services\HybridBotService;
class MyController
{
public function __construct(private HybridBotService $bot) {}
public function askQuestion(Request $request)
{
$result = $this->bot->ask(
query: $request->input('question'),
userId: auth()->id()
);
return response()->json($result);
}
}
''auth_guard' => 'sanctum', // or 'api', 'web', 'passport'