We built DEV3 AI Entry Insights for Gravity Forms & WPForms as a WordPress plugin in PHP with a React admin. It has no front-end output: forms render exactly as before, and the plugin listens to each form plugin's own after-submit hooks.
Key design decisions
- One field model for three plugins. Adapters for Gravity Forms (
gform_after_submission), WPForms Lite and Pro (wpforms_process_complete) and Contact Form 7 (wpcf7_mail_sent and wpcf7_mail_failed) turn each submission into [{key, label, type, value}] rows with a shared type vocabulary. Compound fields such as names and addresses are flattened, and spam-marked submissions are skipped.
- Rules first, always. The capture runs a deterministic rules engine in the same request: configurable points for a phone number, a company email, a budget field, buying words and tight deadlines, a lexicon sentiment, urgency words and keyword categories. Every entry has a score and a reason before any AI runs, and with no API key the plugin stays fully usable.
- AI off the submit path. Entries are marked
pending and a WP-Cron queue analyses them in 20-second slices under a transient lock. When cron is not running, the admin screens run a short catch-up slice once the oldest pending entry has waited 30 seconds.
- Enrich, never erase. A failed AI call keeps the rule values and records the error. Score mode can be AI, rules or a blend of both. Rule tags that stop matching are removed, tags people added stay, and AI tags wait as suggestions until someone accepts them.
- Privacy by field type. Phone, password, hidden, file, signature, consent and card fields never reach the prompt, emails become their domain and names become the first name. A PHPUnit test checks the composed text.
- Drafts, not auto-replies. Reply drafts in the sender's language and the trend digest are drafts until a person sends or pins them. The only automatic email is the optional hot-lead and urgent alert, sent once per entry and only after the AI has finished.
Architecture
Entries live in the plugin's own table with the answers, the rule score, the AI fields, tags, suggested tags, an AI state and a short history. A versioned prompt with a JSON response schema (every string with a maxLength, enums for sentiment, urgency and 11 categories) returns the insight, which is clamped again in PHP. The inbox, dashboard, rules, replies and forms screens talk to an admin-only REST API. Gravity Forms and WPForms Pro entries can be imported in background jobs, and a Gravity Forms entry gets a meta box and an "add as note" action. The API client, encryption, usage caps, jobs and settings screens come from a shared core used across DEV3's plugins.