← All guides

Piwi field notes · 3 min read

How we automated a contact-import review

From a raw CSV to two accepted contacts, three flagged records, and a traceable source fingerprint in one MCP call.

Run this workflow & inspect the verified result →

The business task

Before a lead export enters a CRM, someone has to inspect its columns, spot missing values, and catch duplicate email addresses. Copying the file into a chat and asking for a general cleanup makes the rules hard to repeat. We built a local workflow that makes those checks explicit and returns a review package.

The verification input is an authored five-contact dataset with two valid records, a repeated email in different letter case, a missing email, and a malformed email. These are demonstration records, not data from a customer engagement. The workflow itself is executable: the linked record contains the actual result of running that input through MCP and Docker.

The tool chain

The first two tasks can run independently. file.metadata calculates the SHA-256 fingerprint and byte count of the original CSV; csv.clean parses the CSV with explicit whitespace trimming. The workflow waits for the parser, then sends its headers, rows, and structural errors to contacts.review.

The review tool checks caller-supplied required fields and a caller-selected email column. It applies a basic email syntax rule, compares trimmed email addresses case-insensitively for duplicate detection, and retains the first otherwise-valid record. Each task runs in its own network-isolated Capsule.

What the actual run returned

The verification run parsed five records, accepted Ada and Grace, and flagged three. The repeated address produced duplicate-email; the blank address produced missing:email and invalid-email; the malformed address produced invalid-email. The report returned readyForReview: false because issues remained.

The accepted records and source checksum are returned together. The workflow completing successfully means all its checks executed; it does not mean the file is approved for import. That distinction lets an agent finish preparation while leaving the correction decision visible.

Run it on your own export

Connect Piwi using the local MCP guide. Call piwi_workflow_crm_import_review with an input containing csv, emailField, and requiredFields. The workflow page provides the exact tested request and output. Use the resulting correction list to fix the original export, then run the same workflow again.

If a row has the wrong number of CSV fields, the review blocks the whole import package and reports structural errors. If quoting is malformed, parsing fails and the dependent review step is marked skipped. The verification suite covers both clean input and a failed parse.

Where human review remains

Email syntax does not prove ownership, deliverability, permission to contact someone, or compatibility with a particular CRM. Duplicate records may represent meaningful customer history; deciding whether to merge them remains a business decision. This workflow neither contacts people nor imports records.

The workflow accepts CSV text up to 50000 UTF-16 code units and reviews at most 1000 parsed records. It makes no paid provider calls; local compute and your agent's model usage still have a cost. We have verified the output, not measured customer time savings. A useful pilot should measure corrections caught and time spent reviewing the accepted package.