Turn vendor invoice emails into draft bills in Xero

Every 30 minutes, this agent reads new supplier invoice emails in Gmail, drafts the bill in Xero, and asks for approval in Slack.

Agentic Task
XeroGmailSlackFinanceOperationsDocument ProcessingEmail AutomationData Sync
PromptCreate

Build me an agent workflow that ingests vendor invoice emails from Gmail and turns them into draft bills in Xero with a Slack approval card. Run it on a cron schedule every 30 minutes.

On each run the agent should: (1) Call Gmail List Messages with a query that filters to a configurable label (default: vendor-invoices) and excludes any message that already carries the processed label (default: processed-to-xero). Make the label names configurable. (2) For each new message, call Gmail Get a Message with full detail level to retrieve the email body, headers, and any PDF attachments.

Use the model to extract the following fields from the email body and any PDF attachments: vendor name, vendor email or domain, invoice number, issue date, due date, currency, subtotal, tax amount, total amount, and line items (description, quantity, unit price, line total, and tax rate if present). Include a short confidence note describing how clean the extraction was and which field, if any, looked uncertain.

Then ensure the supplier exists in Xero. Look up the contact by vendor name (and email if available). If no match exists, call Xero Create Contacts to create the supplier with IsSupplier=true and the email/domain on file. Take the resulting ContactID.

Call Xero Create Invoices with Type=ACCPAY, Status=DRAFT, the supplier ContactID, the extracted invoice number as InvoiceNumber, the issue date as Date, the due date as DueDate, the currency code, and the extracted line items mapped to LineItems (Description, Quantity, UnitAmount, and TaxAmount or TaxType where possible). Put the Gmail message permalink (https://mail.google.com/mail/u/0/#inbox/<messageId>) in the Reference field so reviewers can jump back to the source email from Xero.

After the bill is created, call Gmail Modify Message Labels on the original message to add the processed label (default: processed-to-xero) and remove UNREAD so the next run skips it. If the processed label does not exist yet, create it first.

Finally, post an approval card in Slack via Slack Send a Message to a configurable channel. The message should include: vendor name, invoice number, issue date, due date, currency, total amount, tax amount, a one-line summary of line items, a link to the draft bill in Xero, a link to the source Gmail message, and the AI confidence note. Make it clear the bill is in DRAFT and needs a human to approve in Xero before payment.

Configurable inputs: Gmail watch label, processed label, Slack approval channel, Xero organization (tenant) if the user has multiple, and an optional sender allowlist (only ingest messages from these domains). Skip and log any message where extraction fails or the total is missing, and do NOT apply the processed label in that case so a human can re-run it after fixing the source.

What does this prompt do?

  • Watches a Gmail label for new vendor invoice emails and PDF attachments.
  • Reads each email and PDF to pull out the vendor, invoice number, dates, line items, tax, and total.
  • Finds or creates the matching supplier in Xero, then drafts a bill with the line items and a link back to the original email.
  • Marks the email as processed so it never gets billed twice, and posts a Slack approval card so a human signs off before payment.

What do I need to use this?

  • A Gmail account with a label set up for incoming vendor invoices, for example vendor-invoices.
  • A Xero organization where you can create supplier contacts and draft bills.
  • A Slack workspace and a channel where the finance approver wants the approval card posted.

How can I customize it?

  • Change which Gmail label the agent watches, or add filters like sender domain or subject keywords.
  • Pick the Slack channel that gets the approval card, and tweak which fields show up on the card.
  • Adjust the cadence. Every 30 minutes is the default, but hourly or twice a day works just as well for low-volume mailboxes.

FAQs

Will the bill be paid automatically?
No. Bills are always created in draft status in Xero, and the Slack card asks a human to review the extracted fields before anyone approves or pays the bill.
What happens if the same invoice email arrives twice?
After a bill is drafted, the agent puts a processed label on the email. The next run skips anything that already has that label, so duplicates do not get billed.
Does it read PDF attachments, or only the email body?
Both. The agent pulls the email body and any PDF attachments so it can find the invoice number, dates, line items, tax, and total wherever they live.
What if the supplier is not in Xero yet?
The agent checks for a matching supplier contact first. If none exists, it creates a new one using the vendor name from the invoice before drafting the bill.
Can I see which email a Xero bill came from?
Yes. The agent stores a link back to the original Gmail message on the bill, so anyone reviewing the draft in Xero can open the source email in one click.

Related templates

Partner tier review board for quarterly promotion calls

Work every partner tier decision from one board, with the revenue and commission numbers, clear promotion thresholds, and AI review briefs.

Introw
HubSpot
Slack
App
Reconcile partner commissions between HubSpot and Introw

Open one board at month end to find every closed deal missing a commission, every commission with no deal behind it, and every amount that does not add up.

Introw
HubSpot
Slack
App
One control room for every Instantly sending mailbox

See warmup status, daily send volume, and bounce risk for every sending account in one grid, with the riskiest mailboxes floating to the top.

Instantly
Slack
App
Partner payout approval queue with Xero bill handoff

Review Introw partner payouts line by line, approve them from one board, raise the matching bill in Xero, and post every approval to Slack.

Introw
Xero
Slack
App
Run your nutrition clients' weekly meal plans from one console

See who is due, build a week of dinners on demand, swap anything you do not like, then send the recipe and grocery links yourself.

Instacart
Airtable
Gmail
App
Replace the dispatch whiteboard with a live production board

See every install this week day by day, with the crew, the homeowner, whether materials were ordered, and the latest jobsite photos.

JobNimbus
CompanyCam
Gmail
App

Stop hand-keying supplier bills into Xero.

Connect Gmail, Xero, and Slack once, and Geni turns every new vendor invoice email into a draft bill waiting for approval.