Portable WordPress plugin that lets logged-in customers search page-specific CSV content with OpenAI structured output to recommend notes. Designed for Motiveggies: auto-injects a search form on mapped pages, supports shortcode/block/widget, and enforces login/purchase restrictions before showing results.
- Page-scoped CSV lookup: each entry maps a WordPress page to a CSV file; the entire CSV is sent to the AI for selection.
- Multiple placements: auto-inject on mapped pages, shortcode
[csv_ai_lookup], Gutenberg block “CSV-AI Lookup,” classic widget, and Elementor widget. - Access control: require login and/or a past WooCommerce purchase (completed/processing); shows a friendly message if purchase is required.
- AI call: uses OpenAI chat completions with structured output; sends full CSV, returns ≥3 recommendations with note text and reasoning.
- UX: shows a loading overlay with customizable “searching” text while the AI runs, then renders recommended notes with reasoning.
- Admin UI: manage API key, model, temperature, searching text, purchase-required message, and any number of entries (label, page, slug, CSV upload).
- File handling: uploads CSVs via the media library; sanitizes entries and inputs.
- WordPress with WooCommerce active (for purchase checks).
- PHP 7.4+ recommended.
- OpenAI API key with access to the configured model (default
gpt-4o-mini).
- Copy the
csv-ai-lookupfolder intowp-content/plugins/. - Activate “CSV-AI Lookup” in WordPress Admin → Plugins.
- API Key: OpenAI secret key (stored via options).
- Model: OpenAI model name (default
gpt-4o-mini). - Temperature: model temperature (default 1.0).
- Searching Text: message shown during lookup.
- Purchase Required Message: shown when purchase is required but missing.
- Require Login / Require Purchase: toggles for access control.
- Entries (repeatable):
- Label (for admin clarity)
- Page selection (which page to auto-inject and map)
- Optional slug fallback
- CSV upload (full file sent to AI)
- Auto-injection: the form appears on mapped pages.
- Shortcode: add
[csv_ai_lookup]to any page. - Gutenberg block: “CSV-AI Lookup” under Widgets.
- Classic widget: available in widget areas.
- Elementor widget: registered via
elementor/widgets/register.
- Protected pages: if Require Login is on, anonymous users redirect to
/my-account/. If Require Purchase is on, logged-in users without a completed/processing order see the purchase-required message; rendering stops before content. - AI request: sends full CSV for the current entry; expects ≥3 recommendations with reasoning; does not log AI calls.
- Rendering: highlights recommended notes and shows “Why” reasoning beneath each.
- Loading state: overlay with pulsing magnifier and configurable text while awaiting AI response.
- Main plugin file:
csv-ai-lookup.php - Assets:
assets/enqueued for front-end UI/JS. - Options key:
csv_ai_lookup_settings. - Nonce action:
csv_ai_lookup_nonce.
- Form not showing: ensure page is mapped in Entries or use the shortcode/block/widget.
- Access denied message/redirect: disable Require Login/Purchase in settings or ensure test user has a completed/processing order.
- AI errors: verify API key/model, check server can reach OpenAI, and inspect browser console/network for AJAX responses.