PHPackages                             neuron-core/ai-form - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. neuron-core/ai-form

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

neuron-core/ai-form
===================

Conversational Data Collection.

1.0.0(3mo ago)13101MITPHPPHP ^8.1CI passing

Since Apr 1Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/neuron-core/ai-form)[ Packagist](https://packagist.org/packages/neuron-core/ai-form)[ RSS](/packages/neuron-core-ai-form/feed)WikiDiscussions main Synced 4w ago

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

AIForm - Conversational Data Collection
=======================================

[](#aiform---conversational-data-collection)

AIForm is a component for collecting structured data through multi-turn natural language conversations. It uses an AI agent to progressively gather information defined by a structured output class, validating each piece of data along the way.

The form maintains conversation history, tracks collected fields, missing fields, and validation errors across multiple turns.

Read the full article here: ****

> Before moving on, support the Neuron AI community giving a GitHub star ⭐️. Thank you!

Creating a Data Class
---------------------

[](#creating-a-data-class)

You can provide the form structure you want to collect defining a data class using PHP attributes in the same way as you would with any other [structured output](https://docs.neuron-ai.dev/agent/structured-output) class in Neuron AI.

You can also attach validation rules like `#[NotBlank]` or `#[Email]` to fields, to enforce data requirements.

```
use NeuronAI\StructuredOutput\SchemaProperty;
use NeuronAI\StructuredOutput\Validation\Rules\Email;
use NeuronAI\StructuredOutput\Validation\Rules\NotBlank;

class RegistrationData
{
    #[SchemaProperty(description: 'User full name', required: true)]
    #[NotBlank]
    public string $name;

    #[SchemaProperty(description: 'Email address', required: true)]
    #[Email]
    public string $email;

    #[SchemaProperty(description: 'Phone number')]
    public ?string $phone = null;

    #[SchemaProperty(description: 'Company name')]
    public ?string $company = null;
}
```

Creating a Custom Form
----------------------

[](#creating-a-custom-form)

Extend the `AIForm` class to create your custom form:

```
