Text-to-Invoice
← Back to Blog

How an AI Invoice Creator Works (And Why It's Not Magic)

·5 min read

"I text it, and it becomes an invoice." That sounds like magic. But under the hood, it's a pipeline of well-understood technologies — natural language processing, structured extraction, and document generation — working together in seconds.

The Pipeline: Text → Invoice

Here's what happens between you hitting send and the PDF appearing:

1. Message Ingestion

Your SMS arrives at a Twilio-managed phone number. Twilio forwards it via webhook to the Text-to-Invoice backend. The raw text is stored and queued for processing — typically taking under 200ms.

2. Entity Extraction (the AI part)

The text is sent to a large language model (LLM) with a carefully engineered prompt that instructs it to extract structured invoice data. The model identifies:

  • Client: Names, company, email — even partial references like "the Acme job"
  • Line items: Descriptions, quantities, rates, and computed totals
  • Payment terms: "Net 15", "Due on receipt", specific dates
  • Notes and references: PO numbers, project codes, custom messages

The LLM returns structured JSON, not free text. This is critical — it means the output is validated against a schema before it ever becomes an invoice.

3. Validation and Matching

The extracted client name is matched against your saved client list. If you've invoiced "Acme Corp" before, it reuses their email and address. If it's a new client, the system creates a draft client record you can fill in later.

Line items are checked for arithmetic consistency. If you wrote "5 hours at $85/hr = $400" but the math is wrong, the system flags it and uses the computed total.

4. PDF Generation

The structured invoice data is passed to a PDF templating engine (maroto/v2). Your business branding — logo, colors, address, payment details — is applied automatically. The result is a standards-compliant PDF/A document ready for email or download.

5. Delivery

The invoice is stored in your account. You get back a link you can share, or you can have it emailed directly to the client. The system tracks opens and views so you know when your client has seen it.

Why Structured Output Matters

The key engineering decision: the AI doesn't generate the invoice directly. It generates structured data — JSON with predefined fields — and the invoice is built from that. This means:

  • Invoices always match your branding (the AI never touches the template)
  • Calculations are verified by deterministic code, not the LLM
  • Invalid or hallucinated data is caught by schema validation before it reaches you
  • The same extraction model works for SMS, email, or any text input

What the AI Does Well (and What It Doesn't)

Strengths: Extracting entities from natural language, understanding varied phrasings ("charge John 3 hours" = "3 hours at your default rate for John"), spotting payment terms, handling international address formats.

Limitations: Very domain-specific jargon might confuse it. If you're invoicing for "3 widgets at $50" the system needs to know what a widget is to describe it well. The more context you give in your message, the better the output.

The Result: Invoices While You Walk to Your Car

The whole pipeline — from SMS delivery to PDF preview — runs in under 5 seconds. For freelancers who bill by the hour, that's not just convenient; it's revenue. Every minute saved on admin is a minute you could be billing. Over a year, the time savings add up to dozens of billable hours.

Ready to try it yourself?

Send your first invoice by text in under 60 seconds.

Start for Free