How to create AI Agents using NotebookLM and LarAgent Docs

Want to give your AI tools complete knowledge of the LarAgent framework? š
In this guide, you'll learn a powerful trick: how to download the entire LarAgent documentation as a single text file and feed it into an AI tool like Googleās NotebookLM.
This allows you to combine LarAgent docs with other APIs (like Slack) and have AI instantly generate functional, production-ready code for your agents.
If you prefer to watch the full walkthrough, hereās the video:
Using NotebookLM to create Slack agent
NotebookLM is Googleās Retrieval-Augmented Generation (RAG) tool.
It lets you upload or link multiple documents and then āchatā with an AI that knows your sources inside out.
- Open notebooklm.google.com.
- Create a New Notebook.
- Add the LarAgent docs as a source (paste the
/llms-full.txt
link). - Add a second source: Slack API ā Sending Messages
Now the AI knows both LarAgent and Slack API details.
AI-Powered Code Generation
With both sources connected, type:
Please write LarAgent AI Agent, which can send messages to the Slack channel. Create message sending as a tool.
It will respond with detailed instruction of creating slack app (to get API key) and Full code for SlackAgent.php class:
// ...
/**
* Tool to send a message to a specified Slack channel.
* [8]
*
* @param string $channelId The ID of the Slack channel (e.g., 'C12345') to send the message to.
* @param string $messageText The content of the message to send.
* @return string A confirmation message indicating if the Slack message was sent successfully.
* [27]
*/
#[Tool(
'Sends a message to a specified Slack channel.',
[
'channelId' => 'The ID of the Slack channel (e.g., "C12345") to send the message to.',
'messageText' => 'The content of the message to send.'
]
)]
public function sendSlackMessage(string $channelId, string $messageText): string
{
// Retrieve your Slack Bot Token securely, e.g., from your .env file
// Make sure to replace 'SLACK_BOT_TOKEN' with your actual environment variable name.
// [15, 16]
$slackBotToken = env('SLACK_BOT_TOKEN');
if (!$slackBotToken) {
return "Error: Slack Bot Token not configured.";
}
try {
// Make the HTTP POST request to the chat.postMessage API endpoint.
// [11, 16]
$response = Http::withHeaders([
'Content-Type' => 'application/json',
'Authorization' => 'Bearer ' . $slackBotToken,
])->post('https://slack.com/api/chat.postMessage', [
'channel' => $channelId,
'text' => $messageText,
]);
// Check if the API call was successful.
// The API returns a JSON object with 'ok: true' on success. [16]
if ($response->successful() && $response->json('ok')) {
return "Message successfully sent to Slack channel '{$channelId}'.";
} else {
// Log the error for debugging purposes
\Log::error('Slack API Error: ' . $response->body());
return "Failed to send message to Slack channel '{$channelId}'. Slack API error: " . ($response->json('error') ?? 'Unknown error');
}
} catch (\Exception $e) {
// Handle any exceptions during the HTTP request.
\Log::error('Error sending message to Slack: ' . $e->getMessage());
return "An error occurred while trying to send the message to Slack: " . $e->getMessage();
}
}
// ...
š You did it!
Now you can give AI the entire LarAgent framework in one go and instantly create agents that integrate with real-world APIs like Slack. This can save hours of manual reading and coding!
ā happy building! šŖ
Notes
It is a great tool to scaffold and/or see examples of implementation. It provides a really good starting point, but of course, you will need to review the code and clean it up and test it well š
Next Steps
- Use this method to combine any API docs with LarAgent for instant agent generation.
- Experiment with different AI tools beyond NotebookLM.
- Build multi-source AI helpers for complex workflows.