Manual invoicing and chasing overdue payments drain hours from operations teams every week. When you manage dozens or hundreds of recurring invoices, missing a single reminder can delay cash flow by weeks.
In this guide, I'll walk through how to build a robust automation pipeline inside Zoho Books using Deluge scripting and scheduled functions. This setup automatically triggers customized invoice emails upon creation and sends polite, escalating payment reminders for unpaid invoices based on due dates.
The Problem with Manual Invoicing
In a growing business, relying on manual clicks inside Zoho Books to send out invoices and track aging receivables leads to common friction points:
- Delayed Delivery: Invoices sit in draft status or generated offline, waiting for someone to hit send.
- Inconsistent Follow-ups: Chasing clients for overdue payments depends entirely on whether an accountant remembers to check the aging report on Friday afternoon.
- Context Switching: Staff waste valuable time switching between spreadsheets, banking portals, and accounting software.
By leveraging Zoho's built-in Deluge scripting engine and automated schedules, we can remove these manual steps entirely.
Architecture Overview
Here is how the automated workflow functions end-to-end:
[Invoice Created / Approved] │ ▼ [Deluge Workflow Rule Triggered] │ ├─► If status == "sent": Send welcome / invoice email with PDF attachment │ └─► If status == "overdue": Enqueue payment reminder based on aging brackets (1, 7, 14 days) We will use two main components:
- Workflow Rules & Custom Functions: Triggered instantly when an invoice is created or updated.
- Scheduled Functions: A daily cron script that checks for unpaid or overdue invoices and triggers automated reminder emails.
Step 1: Automated Invoice Email on Creation
When an invoice is marked as sent or approved, we want Zoho Books to immediately dispatch the invoice with customized branding and a direct payment link.
While Zoho has native email templates, a custom Deluge function gives us complete control over recipient logic, dynamic CCs, and custom logging.
Navigate to Settings > Automation > Workflow Rules in Zoho Books, create a rule for Invoices, and set the trigger to When an invoice is created.
Here is a Deluge snippet that fetches invoice details and triggers an email send:
void sendCustomInvoiceEmail(int invoiceId) { // Fetch invoice details from Zoho Books orgId = "60012345678"; response = invokeurl [ url: "https://books.zoho.com/api/v3/invoices/" + invoiceId + "?organization_id=" + orgId type: GET connection: "zohobooks_connection" ]; invoice = response.get("invoice"); customerName = invoice.get("customer_name"); customerEmail = invoice.get("email"); invoiceNumber = invoice.get("invoice_number"); balance = invoice.get("balance"); dueDate = invoice.get("due_date"); // Construct email content subject = "New Invoice: " + invoiceNumber + " from Your Company"; messageBody = "Hi " + customerName + ",<br><br>Your invoice " + invoiceNumber + " amounting to $" + balance + " is now due on " + dueDate + ".<br><br>Thank you for your business!"; // Send email via invokeurl or integrated email task sendmail [ from: "billing@example.com" to: customerEmail subject: subject message: messageBody ] } Note: Replace zohobooks_connection with your authorized OAuth connection name in Zoho Creator / Books.
Step 2: Scheduled Payment Reminders
For overdue invoices, relying on a real-time event isn't enough—we need a daily check. Zoho Books allows scheduled functions that run every 24 hours to evaluate open receivables.
Create a scheduled function in Zoho Deluge that queries invoices with status == "overdue":
void checkOverdueInvoices() { orgId = "60012345678"; // Fetch unpaid or overdue invoices response = invokeurl [ url: "https://books.zoho.com/api/v3/invoices?organization_id=" + orgId + "&status=overdue" type: GET connection: "zohobooks_connection" ]; invoices = response.get("invoices"); for each inv in invoices { invId = inv.get("invoice_id"); invNumber = inv.get("invoice_number"); email = inv.get("email"); balance = inv.get("balance"); dueDate = inv.get("due_date"); // Calculate days overdue daysOverdue = daysBetween(toDate(dueDate), zoho.currentdate); if(daysOverdue == 3) { // Send gentle reminder sendReminderEmail(email, invNumber, balance, "Gentle Reminder: Invoice " + invNumber + " is 3 days overdue"); } else if(daysOverdue == 10) { // Send firm reminder sendReminderEmail(email, invNumber, balance, "Action Required: Overdue Invoice " + invNumber); } } } Common Pitfalls & Best Practices
When building financial automation scripts in Zoho Books, keep these production lessons in mind:
- Rate Limits & API Quotas: Zoho imposes daily and per-minute API limits on
invokeurl. For bulk invoice checks, always paginate results rather than pulling thousands of records in a single request. - Error Handling on Missing Emails: Ensure your script verifies that
customerEmailis not null or empty before callingsendmail. A missing email field will cause the Deluge script execution to fail silently or throw exceptions. - Idempotency: Make sure reminder emails track a custom field or tag (e.g.,
Reminder_Sent_3_Days) so clients don't receive duplicate reminders if the scheduled function runs twice due to a timeout. - Sandbox Testing: Always test your Deluge scripts in a Zoho Books Sandbox or test organization before pushing code that touches live client accounts.
Implementation Checklist
- [ ] Authorized OAuth connection (
zohobooks_connection) established with proper scopes (ZohoBooks.fullaccess.all). - [ ] Workflow rule configured for invoice creation and status changes.
- [ ] Scheduled function created for daily overdue invoice scanning.
- [ ] Email templates tested for responsive rendering across mobile and desktop clients.
- [ ] Logging enabled to track successful dispatches and failed API calls.
I'm Nandan Singh — I build AI and automation systems (Odoo, Zoho, chatbots, voice agents) at NMT Solutions. Questions? Drop a comment or WhatsApp +91 92260 02903.
