Let's Build: AI business card scanner with Transloadit
Turn a business card image or PDF into a local JSON file of contact details. This TypeScript example uploads one card to Transloadit, asks an AI model to extract the visible fields, and saves the result for you to compare with the original before adding a contact to your CRM.
What we’re building
- Accept a PNG/JPEG card image or a PDF.
- Optimize images with 🤖 /image/optimize, while PDFs go directly to the extraction Step.
- Extract contact fields with 🤖 /ai/chat and download the JSON result.
This is a local command-line example, not a camera app. You need a Transloadit Workspace Auth Key and Secret, an explicit AI credential choice, and permission to send the card to Transloadit and Anthropic. Processing is billed, including the AI test-credentials option. Start with a synthetic card without anyone’s personal data.
Schema first (zod)
The example script exports businessCardSchema so
you can reuse the same contract instead of maintaining a second field list. Its optional fields are
full_name, title, company, email, phones, address, website, socials, and notes.
Phone numbers stay strings so a leading + is preserved. Unknown fields should be omitted.
After the setup below, save this as schema.ts in your project directory and run node schema.ts
to inspect the schema sent to the model:
import { zodToJsonSchema } from 'zod-to-json-schema'
import { businessCardSchema } from './business-card-scanner/run.ts'
console.log(JSON.stringify(zodToJsonSchema(businessCardSchema), null, 2))
A schema checks field types; it cannot establish whether a name or email was read correctly. The runner rejects malformed JSON, schema-invalid output, and an object with no recognized fields. A nonempty, schema-valid result still needs review against the card.
Pipeline overview
| Input | Processing path |
|---|---|
| PDF card | /ai/chat |
| PNG/JPEG card | /image/optimize → /ai/chat |
The file filters route PDFs separately from images. Despite its pdf_verified name, the PDF filter
only selects the reported MIME type; it does not prove that a document is intact or readable.
Assembly snippet
The app’s exported recipe supplies the filters, prompt, schema, and
anthropic/claude-sonnet-4-6 model. To inspect its
Assembly Instructions, save this as
instructions.ts beside schema.ts and run node instructions.ts:
import { example } from './business-card-scanner/run.ts'
const steps = example.steps({ test_credentials: true })
console.log(JSON.stringify({ steps }, null, 2))
This only prints the recipe. The CLI below submits it, waits for completion, downloads the result, validates it, and saves the contact fields locally. The local file is what you keep; the processing result URL is temporary.
Try the example app
Use Node.js 26.12.1, separately installed
Corepack, cURL, and a new empty directory outside an existing
project. Follow the setup instructions to install
Yarn 4.12.0, @transloadit/node 4.14.0, Zod 3.25.76, and zod-to-json-schema 3.25.2, and download
both business-card-scanner/run.ts and shared/runtime.ts. Keep that directory layout: the app
imports the shared runtime. No private repository checkout is needed.
These are tested versions. The example retains Zod 3 and its converter;
zod-to-json-schema is deprecated, and Zod 4
has native JSON Schema support. Upgrading that contract is a separate change to the app.
In the shell where you will run the program, replace these placeholders with your Workspace values:
export TRANSLOADIT_AUTH_KEY='YOUR_AUTH_KEY'
export TRANSLOADIT_AUTH_SECRET='YOUR_AUTH_SECRET'
Keep secrets out of source control and browser code. The program reads the process environment; it does not load an environment file or create credentials.
Place your card at card.png in the project directory, or replace the input path. Choose an output
that does not exist, then explicitly authorize billed AI test credentials:
node business-card-scanner/run.ts --input ./card.png --output ./result.json --test-credentials
Alternatively, set TRANSLOADIT_AI_CREDENTIALS to the name of an existing Anthropic AI Credential
and omit --test-credentials. Select exactly one mode. See the setup instructions for configuring
your own provider credential before running the app.
On success, open result.json and compare the extracted name, email, and phone numbers with the
card. Missing optional fields are allowed. The app leaves the input unchanged and refuses an
existing output before submitting work, so use a new destination for another run. It limits input
and downloaded output to 20 MiB, waits up to five minutes for processing, and gives the result
download a separate 30-second deadline. These are example limits, not product limits.
If a run fails after printing an Assembly ID, inspect that Assembly in the Console before retrying. A timeout or interruption does not prove remote processing stopped, and the work can still be billed. The script does not automatically retry an Assembly.
Example inputs
Use a readable synthetic card with a name, company, email, and phone number you can check. Run a single card per file; for a PDF, start with one page. To exercise the PDF path, pass its filename to the same command and choose a second JSON output. A successful image extraction does not establish that a particular PDF is readable, and image optimization does not guarantee better recognition.
Next steps
Review every extraction before inserting contacts into your CRM. The schema returns no confidence scores, so it cannot select “low-confidence” contacts for you. After review, normalize phone numbers and addresses per locale and deduplicate contacts using your CRM’s rules.
