Push approved Timesheet Portal invoices into Xero each evening
Every weekday evening, newly approved invoices move from Timesheet Portal into Xero on their own, so finance never rekeys another one.
Every weekday at 7pm, push newly approved Timesheet Portal invoices into Xero as sales invoices, so finance stops rekeying them. Use a cron trigger, because Timesheet Portal does not send outgoing webhooks and is not available as a poll source.
Start in Timesheet Portal with List Invoices, filtered to invoices that have not yet been marked as exported. If nothing comes back, end the run without posting anything so the Slack channel stays quiet on days with no new invoices.
Pull the line level detail with Get Invoice Report V2. Timesheet Portal caps its invoice report endpoints at 24 requests per hour, so make exactly one report call per run covering every invoice in the batch, rather than one call per invoice. Group the returned rows by invoice so each invoice has its own set of lines carrying the description, hours, rate and amount.
Before creating anything, call Xero List Invoices filtered to the Timesheet Portal invoice number and check whether an invoice with that number already exists. If it does, skip that invoice and count it as already synced. This check is what makes a rerun safe, so it must happen for every invoice before any write.
For each remaining invoice, call Xero Create Invoices to raise an accounts receivable sales invoice. Identify the contact by name using the Timesheet Portal client name, since there is no contact lookup operation in the catalog to resolve it first. Carry the Timesheet Portal invoice number into the Xero invoice number field, carry the invoice date and the due date, and create one Xero line item per Timesheet Portal line with the description, the hours as the quantity, the rate as the unit amount and the line amount. Create the invoice in draft status so finance can review before it goes out.
Only once Xero has confirmed the invoice, call Mark Invoices as Exported in Timesheet Portal for that invoice, so the same invoice is never picked up twice. Timesheet Portal upserts can return HTTP 200 with success set to false, so check the success flag in the response body rather than the status code before treating the mark as done. Never mark an invoice as exported when the Xero create failed.
Handle each invoice independently. If one invoice fails at any step, record its invoice number and the reason, leave it unmarked so the next run retries it, and carry on with the rest of the batch.
Finish by posting a run summary to a finance channel in Slack with Send a Message. Include the number of invoices synced, the total value synced, the number skipped because they were already in Xero, and one line for each invoice that failed showing its invoice number and the reason.
What does this prompt do?
- Checks Timesheet Portal every weekday evening for invoices that have been approved but not yet sent to your accounts.
- Pulls the full line by line detail for those invoices, including the hours, rate and amount on every line.
- Raises the matching sales invoice in Xero against the client, carrying the original invoice number, dates and every line across unchanged.
- Marks each invoice as exported once Xero confirms it, then posts a Slack summary with the count, the total value and anything that failed.
What do I need to use this?
- A Timesheet Portal account with administrator access
- A Xero organisation you can raise sales invoices in
- A Slack workspace and a channel for the evening summary
- Client names in Timesheet Portal that match the contact names you use in Xero
How can I customize it?
- Change the timing. Seven in the evening on weekdays suits most finance teams, but you can move it later, run it once a week, or include weekends.
- Choose where the summary lands, whether that is a finance channel, an ops channel or a direct message to whoever owns billing.
- Decide how invoices arrive in Xero. They are created as drafts by default so someone can review them, but you can have them created ready to send.
- Narrow which invoices are in scope, for example only certain clients, branches or invoices above a minimum value.
FAQs
Will this create duplicate invoices in Xero?
What happens if one invoice fails?
What if a client in Timesheet Portal does not exist in Xero yet?
Does this email the invoices to my clients?
Can I run it more often than once a day?
Related templates
When someone leaves, we check which shared passwords they used in their final months and post a ranked rotation list to your security channel.
Every Monday, check every S3 bucket for public exposure, missing encryption and weak backup settings, then get the risks ranked in Slack.
Twice every weekday, the conversations from your social inbox land on the right HubSpot contact timelines, with a Slack recap for sales.
Every morning, find the addresses that hard bounced or filed a spam complaint, update the matching HubSpot contacts, and post a short Slack recap.
Every weekday at 4pm, spot the threads that went quiet, stage a ready-to-send nudge in your mailbox, and get a ranked Slack recap.
When you merge a fix in GitHub, this agent checks the matching dead-letter queue, replays the failed messages, and reports back on the pull request and in Slack.
Stop rekeying invoices into Xero.
Let approved Timesheet Portal invoices flow into your accounts every evening, with a Slack summary so you always know it worked.