I have always been fascinated by AI and the potential it offers. As a developer, I have always wanted to explore how to integrate AI capabilities within my applications.

Initially, I was able to implement a proof of concept in PHP, but looking back I can say how it was an impractical if working system.

As of today, the vast majority of AI projects rely on Python (over 25 percent share of web pages, according to the TIOBE Index as of May 2025) and, for deployment on the web, JavaScript thanks to many specific libraries.

Looking for an alternative that was built in PHP, I discovered NeuronAI: an open source framework, written right in PHP, designed to simplify the creation of full-featured AI agents within PHP projects.

"This idea of the simple developer will probably expand into what is called a builder. I think everyone will become a builder."
 - Varun Mohan, CEO of Windsurf

Recently, on this very site, I created an AI Agent to help me manage my clients' requests, using NeuronAI and Anthropic's Claude LLM. In this article, we will see how I did it in detail.

Setting Neuron AI

Given that this site is developed in Laravel, the first step was to install within it NeuronAI, distributed as an open source PHP package. Because of this, it is super-easy to install via Composer:

composer require inspector-apm/neuron-ai

This is enough to set up the right dependencies and allowing us to create AI Agents right away.

Creating an AI Agent

My goal was to create an AI Agent capable of:

  1. Receive a potential customer's first contact
  2. Understand his or her needs
  3. Return a series of questions designed to explore the customer's requirements and see if my support could be responsive.

The first step in creating an Agent is to define a PHP class, which I called App\Agents\FirstContactAgent.php:

Code of FirstContactAgent.php class
Pretty simple, right?

How it works

After creating the FirstContactAgent class, which extends the Agent class, I implemented two methods - indicated by the documentation - :

  1. provider(): this method specifies which LLM provider the agent must use. Thanks to AIProviderInterface, you can very easily switch from Anthropic to OpenAI, Gemini, Ollama, and others without changing the agent code.
  2. instructions(): this method defines the “role” of the agent, giving it context, steps to follow, and output format via SystemPrompt.

Using the Agent

After defining the FirstContactAgent class, and then creating the Agent structure, I integrated it into the workflow within the Livewire component that receives messages from the contact form.

The code for using the agent in the algorithm
Basically, this method:

  1. Create an instance of FirstContactAgent.
  2. Send the customer's text to the LLM via the chat() method. This method is the entry point for initiating a conversation with our agent.
  3. Returns the content processed by the agent with getContent().

The framework then takes care of orchestrating the call to the LLM, handling the prompt and returning the result so that it can be used immediately in the application.

The processed content then can be used however you like: in my case, I use it directly in my backoffice.

The final output
Final Thoughts

With this very short example, we have seen together how to implement an AI Agent in real-world contexts.

It is important to emphasize that the code discussed in this article should be understood as a proof of concept: a starting point that, however, highlights the potential of the tool. To make it more suitable for a production environment, error handling mechanisms, a retry policy to mitigate traffic spikes, sanitization of user input, and the use of asynchronous queues were introduced to ensure a consistently smooth user experience.

Using NeuronAI turned out to be surprisingly simple, and the results obtained really impressed me. The ease of integrating different AI models into PHP projects opens up several interesting scenarios for content analysis (by the way, stay tuned!), automation and much more.

Of course, I would recommend a few tricks to get the most out of NeuronAI:

  1. Constant updates: always keep the components of your stack up to date, both to access the latest features but especially to ensure an adequate level of security.
  2. Monitoring responses: generative AI evolves over time and the output can be highly variable. So take time to periodically review results and optimize prompts to keep them effective.
  3. Error handling and logging: track every call to the agent and log any anomalies or failures, so that you always know what is going on “under the hood” each time.
  4. Input sanitization: never take the reliability of input data for granted. Always apply Zero Trust routines to prevent exploits and unexpected behavior.

My final advice, if you are a developer, is definitely experiment with NeuronAI. If, on the other hand, you were driven here by curiosity and the need to have something similar in your project, contact me without obligation for a free quote and let's get online now!