Schedule icon
Request icon
Return icon
Switch icon
Log icon
SlackIncomingWebhook icon

Zoho Books Overdue Receivables Sentinel

Read overdue Zoho Books invoices every morning, change nothing, and alert Slack when customers are late or the overdue total crosses a limit.

Categories
Business

For a small business, cash flow depends on customers paying on time, and Zoho Books marks an invoice overdue the day after its due date. Nobody gets paged, though: the overdue list only matters when someone opens it, and by then an invoice can be two months late. This blueprint turns a scheduled, read-only call to the Zoho Books API into a receivables gate: two io.kestra.plugin.core.http.Request tasks refresh an OAuth token and read overdue invoices, one jq query adds up the overdue balance, counts invoices past your warning and critical limits and finds the customer owing the most, and the result routes to a quiet log or a Slack alert.

How it works

  1. refresh_access_token (io.kestra.plugin.core.http.Request) exchanges the long-lived refresh token for a short-lived access token at the Zoho Accounts server (/oauth/v2/token, grant_type=refresh_token). Defaults use the India data centre; change accounts_domain and api_domain for .com, .eu and others.
  2. list_overdue_invoices (io.kestra.plugin.core.http.Request) calls GET /books/v3/invoices with status=overdue, per_page=200 and sort_column=due_date, sending Authorization: Zoho-oauthtoken <token>. It needs only the ZohoBooks.invoices.READ scope and changes nothing. allowFailed plus allowFailure on both calls keep an API error from aborting the flow so it can be reported instead.
  3. summarize_receivables (io.kestra.plugin.core.debug.Return) first guards for a missing or non-200 response, then for a non-zero Zoho code (UNREACHABLE). Otherwise one jq query adds up balance, counts invoices whose due_date is at least warning_days and critical_days in the past, and finds the customer with the largest overdue balance. Any invoice past critical_days, or a total at or above critical_overdue_balance, is CRITICAL; any invoice past warning_days is WARNING; otherwise HEALTHY.
  4. route_by_receivables_state (io.kestra.plugin.core.flow.Switch) branches on that classification: HEALTHY logs quietly, WARNING posts a Slack note, CRITICAL and UNREACHABLE page Slack. A defaults fallback logs anything unexpected.
  5. log_audit_result (io.kestra.plugin.core.log.Log) writes one audit line per run with the HTTP status and the full summary.
  6. The flow-level errors block pages Slack if the flow itself fails, and the morning_check trigger runs at 09:30 IST on weekdays, shipped disabled: true.

What you get

  • A daily, read-only receivables check with no custom scripting and no extra plugin to install.
  • A status output (HEALTHY / WARNING / CRITICAL / UNREACHABLE) and an overdue_balance output other flows can use.
  • Slack messages with the number of late invoices, the total owed and the customer owing the most, so the accounts team knows who to call first.
  • An audit line on every run, separate from Slack.

Who it's for

  • Small and mid-size businesses in India and elsewhere that invoice customers from Zoho Books.
  • Accounts and finance teams who chase payments and want a morning signal instead of a monthly ageing report.
  • Founders who want to see cash stuck with customers before it becomes a problem.

Why orchestrate this with Kestra

Zoho Books can email payment reminders to customers, but it does not tell your own team when receivables are getting out of hand. Kestra handles the OAuth refresh, the read-only API call, the classification, retries, a failure path and an execution history in one flow, and the status output can hold back other spending flows while too much cash is overdue.

Prerequisites

  • A Zoho Books organization (the free plan for small businesses includes API access) and its organization ID from Settings > Organization Profile.
  • A self client in the Zoho API Console for your data centre, with a refresh token generated for the ZohoBooks.invoices.READ scope.
  • A Slack incoming webhook for the WARNING, CRITICAL, UNREACHABLE and flow-failure alerts.

Secrets

  • ZOHO_CLIENT_ID and ZOHO_CLIENT_SECRET: the self client's credentials.
  • ZOHO_REFRESH_TOKEN: refresh token for ZohoBooks.invoices.READ.
  • ZOHO_BOOKS_ORGANIZATION_ID: the Zoho Books organization ID.
  • SLACK_WEBHOOK: Slack incoming webhook used for every alert branch and the flow-failure alert.

In Kestra OSS, secrets are supplied as environment variables prefixed SECRET_ and base64-encoded, for example SECRET_ZOHO_BOOKS_ORGANIZATION_ID=$(echo -n '60012345678' | base64), and read back with {{ secret('ZOHO_BOOKS_ORGANIZATION_ID') }}. Use the Enterprise secrets backend for encryption at rest and access control.

Quick start

  1. In the Zoho API Console for your data centre (api-console.zoho.in for India), create a Self Client and generate a grant code with scope ZohoBooks.invoices.READ.
  2. Exchange the grant code for a refresh token once (POST /oauth/v2/token with grant_type=authorization_code) and store it with the client ID, client secret and organization ID as secrets.
  3. In Zoho Books, create a test invoice with a due date a few weeks in the past, then run the flow manually: status should be WARNING, or CRITICAL if it is older than critical_days.
  4. Enable morning_check.

How to extend

  • Page through more than 200 overdue invoices with page while page_context.has_more_page is true.
  • Read status=unpaid as well to forecast what falls due this week.
  • Send a polite reminder through Zoho Books' own reminder endpoint for invoices past warning_days, behind an approval step.
  • Store the overdue balance in a KV store and chart it over time.

Inputs

  • warning_days: type INT, default 15.
  • critical_days: type INT, default 60.
  • critical_overdue_balance: type FLOAT, default 500000.0.

Outputs

  • status: one of HEALTHY, WARNING, CRITICAL, UNREACHABLE.
  • overdue_balance: total unpaid balance of overdue invoices.
  • Example path: {{ fromJson(outputs.summarize_receivables.value).top_customer }} for the customer owing the most.

Links

Pitfalls

  • The API domain must match the organization's data centre (.in, .com, .eu, .com.au, ...); a mismatch shows up as UNREACHABLE.
  • Balances are added in each invoice's own currency; an organization that invoices in several currencies should compare critical_overdue_balance per currency or convert with exchange_rate.
  • due_date is compared with today's date in the Kestra server's time zone; run Kestra in IST or adjust the limits by a day if that matters.
  • This flow only reads; it never creates an invoice, a reminder or a payment.
See How

New to Kestra?

Use blueprints to kickstart your first workflows.