WordPress plugin that integrates Claude AI with Gravity Forms to provide intelligent analysis of form submissions.
- 🤖 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
- WordPress 6.0+
- PHP 7.4+
- Gravity Forms plugin (active)
- Claude API key from Anthropic
- Download the latest release ZIP file
- Go to WordPress Admin → Plugins → Add New
- Click "Upload Plugin"
- Select the ZIP file and click "Install Now"
- Activate the plugin
- Clone this repository to
wp-content/plugins/
- Run
npm install
to install build dependencies - Run
./build.sh
to create production build
84em-gravity-forms-ai/
├── assets/
│ ├── css/
│ │ ├── admin.css # Admin styles (source)
│ │ └── admin.min.css # Minified admin styles
│ └── js/
│ ├── admin.js # Admin scripts (source)
│ └── admin.min.js # Minified admin scripts
├── bin/
│ └── install-wp-tests.sh # WordPress test suite installer
├── includes/
│ ├── Admin/
│ │ └── Settings.php # Admin settings interface
│ └── Core/
│ ├── APIHandler.php # Claude API integration
│ ├── Encryption.php # API key encryption
│ └── EntryProcessor.php # Form submission processing
├── tests/
│ ├── integration/
│ │ └── IntegrationTest.php # End-to-end tests
│ ├── unit/
│ │ ├── ApiHandlerTest.php # API handler tests
│ │ ├── EncryptionTest.php # Encryption tests
│ │ ├── EntryProcessorTest.php # Entry processor tests
│ │ ├── PluginTest.php # Main plugin tests
│ │ └── SettingsTest.php # Settings tests
│ ├── bootstrap.php # PHPUnit bootstrap
│ ├── class-test-case.php # Base test case class
│ ├── README.md # Testing documentation
│ ├── SimpleTest.php # Basic test verification
│ └── TEST-PLAN.md # Test coverage plan
├── 84em-gravity-forms-ai.php # Main plugin file
├── build.sh # Build script
├── CHANGELOG.md # Version history
├── CLAUDE.md # AI assistant instructions
├── composer.json # PHP dependencies
├── composer.lock # Dependency lock file
├── package.json # NPM dependencies
├── package-lock.json # NPM lock file
├── phpunit.xml.dist # PHPUnit configuration
├── README.md # This file
├── uninstall.php # Clean uninstall handler
└── .gitignore # Git ignore rules
The plugin includes a build system for creating production-ready distributions:
npm install
# 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
./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
)
-
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
- 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
-
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
The plugin includes a comprehensive PHPUnit test suite with 127+ 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.
- 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.
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
Current Models:
- Claude Opus 4.1 (
claude-opus-4-1-20250805
) - Latest, most capable model - Claude Opus 4 (
claude-opus-4-20250514
) - Advanced capabilities - Claude Sonnet 4 (
claude-sonnet-4-20250514
) - 1M token context (Beta) - Claude 3.7 Sonnet (
claude-3-7-sonnet-20250219
) - Hybrid reasoning - Claude 3.5 Haiku (
claude-3-5-haiku-20241022
) - Fast, recommended for most use cases - Claude 3 Haiku (
claude-3-haiku-20240307
) - Previous fast model
Deprecated Models (Still Functional):
- Claude 3.5 Sonnet (
claude-3-5-sonnet-20241022
) - Deprecated - Claude 3 Opus (
claude-3-opus-20240229
) - Deprecated
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
// 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);
// 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);
- Verify key starts with
sk-ant-
- Check if key has proper permissions
- Use "Test Connection" button to verify
- Check if AI analysis is enabled globally
- Verify form has AI analysis enabled
- Ensure fields are selected for analysis
- Check logs for error messages
- Adjust rate limiting in settings
- Reduce max tokens for faster responses
- Consider using Claude 3.5 Haiku for speed and cost efficiency
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
GPL v2 or later
Developed by 84EM
This plugin requires an active Gravity Forms license and Claude API key from Anthropic.