84EM Gravity Forms Entry AI Analysis
WordPress plugin that integrates Claude AI with Gravity Forms to provide intelligent analysis of form submissions.
by 84EM · github.com/84emllc/84em-gravity-forms-ai · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/84emllc/84em-gravity-forms-ai/archive/refs/heads/main.zip84EM Gravity Forms AI Analysis
WordPress plugin that integrates Claude AI with Gravity Forms to provide intelligent analysis of form submissions.
Features
- AI-powered analysis of form submissions using Claude AI
- Clean markdown storage in entry meta (no duplicate entry notes)
- Customizable field selection per form
- Secure encrypted API key storage
- Comprehensive logging system
- Custom prompts per form or globally
- View analysis report in new browser tab with client-side markdown rendering
- Manual analysis/re-analysis from entry detail page
- Delete analysis with confirmation prompt and audit trail
- Uses Marked.js for consistent markdown-to-HTML conversion
Requirements
- WordPress 6.8+
- PHP 8.0+
- Gravity Forms plugin (active)
- Claude API key from Anthropic
Installation
From ZIP File
- Download the latest release
- Go to WordPress Admin → Plugins → Add New
- Click "Upload Plugin"
- Select the ZIP file and click "Install Now"
- Activate the plugin
For Development
- Clone this repository to
wp-content/plugins/ - Run
npm installto install build dependencies - Run
./build.shto create production build
Development
Build Process
The plugin includes a build system for creating production-ready distributions:
Install Dependencies
npm install
Build Commands
# Build everything (CSS + JS)
npm run build
# Build CSS only
npm run build:css
# Build JavaScript only
npm run build:js
# Clean build artifacts
npm run clean
# Watch for changes (development)
npm run watch
Create Distribution Package
./build.sh
This will:
- Install npm dependencies (if needed)
- Minify CSS and JavaScript files
- Create source maps for debugging
- Generate a versioned ZIP file (e.g.,
84em-gravity-forms-ai-1.0.0.zip) - Create a latest ZIP file (
84em-gravity-forms-ai.zip)
Development Workflow
-
Make changes to source files:
- CSS:
assets/css/admin.css - JS:
assets/js/admin.js - PHP: Files in
includes/directory
- CSS:
-
Test locally with source files (plugin automatically uses non-minified versions if available)
-
Build for production:
./build.sh -
Deploy the generated ZIP file
Code Standards
- PHP: Follow WordPress Coding Standards
- JavaScript: Use jQuery patterns consistent with WordPress admin
- CSS: Use BEM-like naming with
eightyfourem-gf-ai-prefix - Security: Always escape output, sanitize input, use nonces
Testing
Manual Testing
-
Enable WP_DEBUG in
wp-config.php:define('WP_DEBUG', true); define('WP_DEBUG_LOG', true); define('WP_DEBUG_DISPLAY', false); -
Test with various Gravity Forms field types
-
Verify API key encryption/decryption
-
Check markdown storage in entry meta
-
Test HTML export with Marked.js conversion
-
Verify client-side markdown rendering
Automated Testing
The plugin includes a comprehensive PHPUnit test suite with 135+ tests:
-
Install dependencies:
composer install -
Set up WordPress test environment:
./bin/install-wp-tests.sh local root root localhost latest true -
Run tests:
export WP_TESTS_DIR=/tmp/wordpress-tests-lib ./vendor/bin/phpunit # Or run with readable output ./vendor/bin/phpunit --testdox -
Generate coverage report (requires Xdebug):
XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-html coverage-report
See tests/README.md for detailed testing documentation.
Configuration
Initial Setup
- Navigate to GF AI Analysis in WordPress admin
- Enter your Claude API key in the API Key Management section
- Configure global settings:
- Enable/disable AI analysis
- Select Claude model
- Set max tokens and temperature
- Configure rate limiting
That's it! The plugin will now automatically analyze all text fields in your form submissions.
Advanced Settings (Optional)
The plugin works out of the box with smart defaults. If you need to customize specific forms:
- Go to GF AI Analysis → Advanced Settings
- For each form, you can optionally:
- Override the global enable/disable setting
- Select specific fields to analyze (defaults to all text fields)
- Set a custom AI prompt for that form
Available Claude Models
Models are fetched dynamically from the Claude API and cached for 15 minutes. The settings page displays all currently available models with their display names.
Default Model: Claude 3.5 Haiku (claude-3-5-haiku-20241022) - Fast and cost-effective for most use cases.
API Integration
The plugin uses the Claude API with the following features:
- Encryption: API keys are encrypted using AES-256-CBC before storage in WordPress options
- Storage: Encrypted keys stored securely in WordPress options table
- Rate Limiting: Configurable delay between requests
- Error Handling: Comprehensive error logging and retry logic
- Timeout: 30-second timeout for API requests
- Markdown Storage: Raw markdown stored in entry meta for flexible rendering
- Client-Side Rendering: Marked.js v12.0.0 converts markdown to HTML in the browser
Hooks & Filters
Filters
// Modify the prompt before sending to API
add_filter('84em_gf_ai_analysis_prompt', function($prompt, $context) {
// $context contains: form_id, entry_id, form_title, form_data, submitter info
// Customize prompt based on context
return $prompt;
}, 10, 2);
// Filter the AI response before saving
add_filter('84em_gf_ai_analysis_result', function($result, $entry_id, $form_id) {
// Process or modify the AI analysis result
return $result;
}, 10, 3);
Actions
// After successful analysis
add_action('84em_gf_ai_after_analysis', function($entry_id, $result, $form_id) {
// Custom processing after successful analysis
// For example, send notification, update other systems, etc.
}, 10, 3);
// When analysis fails
add_action('84em_gf_ai_analysis_failed', function($entry_id, $error, $form_id) {
// Handle analysis failures
// For example, log to external service, send alert, etc.
}, 10, 3);
// After analysis is deleted
add_action('84em_gf_ai_analysis_deleted', function($entry_id) {
// Handle post-deletion tasks
// For example, clean up related data, notify systems, etc.
}, 10, 1);
Troubleshooting
API Key Issues
- Verify key starts with
sk-ant- - Check if key has proper permissions
- Use "Test Connection" button to verify
Analysis Not Working
- Check if AI analysis is enabled globally
- Verify form has AI analysis enabled
- Ensure fields are selected for analysis
- Check logs for error messages
Performance Issues
- Adjust rate limiting in settings
- Reduce max tokens for faster responses
- Consider using Claude 3.5 Haiku for speed and cost efficiency
Support
For issues or questions:
- Check the Logs page in admin for error details
- Enable WP_DEBUG for additional information
- Contact 84EM support with log details
License
GPL v2 or later
Credits
Developed by 84EM
This plugin requires an active Gravity Forms license and Claude API key from Anthropic.