=== Zaptic Autofill for WPForms ===
Contributors: letsgodev
Tags: forms, autofill, zaptic, pdf, document
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 8.2
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Autofill form fields from PDF and Word documents using the Zaptic service. Requires WPForms.

== Description ==

Zaptic Document Autofill adds a custom field to WPForms that lets visitors upload a PDF, DOC, or DOCX file. The plugin sends the document content to the Zaptic API and fills mapped form fields automatically, including repeater rows and optional scoring criteria.

= Features =

* Custom Zaptic field with API key, layout, and scoring options
* Autofill for text, number, name, select, textarea, and repeater fields
* Optional scoring criteria with total score and executive summary stored on entries
* Supports standard file input and drag-and-drop upload layouts
* Document types supported: PDF, DOC, and DOCX

= Requirements =

* WPForms (Lite or Pro)
* A valid Zaptic API license configured on the Zaptic field

== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/` or install it through the WordPress plugins screen.
2. Activate the plugin through the **Plugins** screen in WordPress.
3. Make sure WPForms is installed and active.
4. Edit a form, add the **Zaptic** field, and enter your API license.
5. Enable **Autofill from Zaptic** on the fields you want to populate.

== Frequently Asked Questions ==

= Which file types are supported? =

PDF, DOC, and DOCX. Image files are not supported.

= Does this plugin work without WPForms? =

No. WPForms must be installed and active.

= Where is the total score shown? =

When scoring is enabled, the total score and executive summary appear on the entry detail screen and in the entries list column.

== External services ==

This plugin connects to the Zaptic API to analyze uploaded documents and return structured field values for autofill. It does not contact Zaptic unless a visitor uploads a supported document on a form that has the Zaptic field configured with a valid license and at least one field marked for autofill.

= Zaptic Process API =

When a visitor uploads a PDF, DOC, or DOCX file in the Zaptic field, the plugin extracts the document text on your WordPress server and sends a JSON request to:

`https://api.zaptic.io/json-api/zaptic/v1/process`

**Data sent to Zaptic**

* `license` — the Zaptic API license configured in the Zaptic field settings (read server-side only; never taken from the browser).
* `domain` — your site domain, derived from the WordPress home URL.
* `origin` — fixed value `wpforms_plugin`, used to identify this integration.
* `lang` — the WordPress site locale.
* `version` — the plugin version.
* `requested_fields` — the schema of form fields enabled for autofill (field labels and types), not the visitor's submitted answers.
* `extracted_content` — plain text extracted locally from the uploaded document. The original file is not uploaded to Zaptic.
* `scoring_criteria` (optional) — when scoring is enabled on the Zaptic field, each criterion name, requirement description, and weight.

**Data received from Zaptic**

On success, the API returns JSON with:

* `extracted_fields` — suggested values keyed by field label, used to populate the form in the browser.
* `response_id` — an identifier for that processing run.
* `internal_analysis` (optional) — when scoring is enabled, may include `total_score` and `executive_summary`. This is stored temporarily in WordPress (transient, 30 minutes) and saved to the WPForms entry when the form is submitted.

If the request fails, the plugin shows an error message to the visitor and does not autofill the form.

**When the request is made**

* Trigger: visitor selects a file in the Zaptic upload field on the front end.
* Transport: browser → WordPress (`admin-ajax.php`) → Zaptic API (`wp_remote_post`).
* Frequency: once per uploaded document per autofill attempt.

**Privacy and terms**

Use of the Zaptic service is subject to Zaptic's policies. Document text and related metadata sent through this plugin are processed according to those policies.

This service is provided by Zaptic:

* [Privacy policy](https://www.zaptic.io/privacy-policy/)
* [Terms of service and refund policy](https://www.zaptic.io/refund_returns/)
* [API documentation](https://zaptic.io/developers)

== Changelog ==

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.0.0 =
Initial release.
