This project is not covered by Drupal’s security advisory policy.

There is an open security issue: OpenAI API key stored in exportable Drupal config (security)

AI Webform Generator

CONTENTS

  • Introduction
  • Features
  • Requirements
  • Installation
  • Configuration
  • Usage
  • Security notes
  • Recommended modules/libraries
  • Similar projects
  • Supporting this module
  • Community documentation
  • Maintainers

INTRODUCTION

AI Webform Generator allows site builders and administrators to create and modify Drupal Webforms using plain English instructions.

Instead of manually building forms field-by-field, users can describe what they need (for example, “a customer feedback form with name, email, rating, and comments”), and the module uses the OpenAI API to generate a complete Webform structure automatically.

The module can also update existing Webforms using natural language instructions such as adding fields, removing fields, or modifying validation rules without recreating the form.


FEATURES

  • Generate complete Drupal Webforms from natural language prompts
  • Update existing Webforms using AI instructions
  • Automatic mapping of AI JSON to Drupal Webform elements
  • Validation of AI-generated responses before applying them
  • Support for common form elements (text, email, number, select, radios, checkboxes, etc.)
  • Optional CAPTCHA integration for spam protection
  • Configurable OpenAI model, temperature, and token limits
  • Structured prompt engineering for consistent output
  • Secure API key configuration via admin UI or Key module

Use cases:

  • Customer feedback forms
  • Event registration forms
  • Surveys and questionnaires
  • Job application forms
  • Support request forms

REQUIREMENTS

Optional:


INSTALLATION

  1. Install via Composer:
    composer require drupal/ai_webform_generator
  2. Enable the module:
    drush en ai_webform_generator -y
  3. Clear cache:
    drush cr

CONFIGURATION

  1. Enable the module
  2. Go to:
    /admin/config/services/ai-webform-generator
  3. Configure OpenAI API key and model settings
  4. Adjust temperature, max tokens, and timeout
  5. Assign permissions:
    • Generate AI Webforms
    • Administer AI Webform Generator

USAGE

Navigate to:

/admin/structure/webform/ai-generator

Creating a new Webform

  1. Select “Create new Webform”
  2. Enter a natural language description
  3. Submit
  4. The module generates and saves a Webform automatically

Updating an existing Webform

  1. Select an existing Webform
  2. Enter modification instructions (e.g. add/remove fields)
  3. Submit
  4. The Webform is updated in place without changing its ID

Supported field types:

  • textfield
  • textarea
  • email
  • tel
  • url
  • number
  • date
  • datetime
  • checkbox
  • checkboxes
  • radios
  • select
  • hidden
  • password
  • range
  • managed_file
  • CAPTCHA (if enabled)

SECURITY NOTES

  • API key is stored in Drupal configuration
  • Use Key module for secure storage in production
  • Only trusted roles should generate Webforms (cost control)
  • Flood protection limits excessive API usage
  • Webform edit permissions are still enforced
  • Secrets are never logged

RECOMMENDED MODULES / LIBRARIES


SIMILAR PROJECTS

  • Webform module (manual form builder)

This module is unique because it introduces AI-driven form generation and modification directly into Drupal Webform workflows.


SUPPORTING THIS MODULE

Contributions, issues, and feature requests are welcome via the project page.


COMMUNITY DOCUMENTATION


MAINTAINERS

Chaitanya R Dessai

Supporting organizations: 
AttachmentSize
ai_webform.png94.36 KB
config.png52.63 KB

Project information

Releases