Log yesterday's Keap sales to a Sheet and Slack the total

By General Input

Every weekday morning, yesterday's Keap payments are added to a running spreadsheet and the daily sales total lands in Slack.

Integrations

  • Keap
  • Google Sheets
  • Slack Bot

Type

Deterministic Code

Categories

  • Finance
  • Operations

Every weekday at 7am, build a running revenue ledger from yesterday's Keap sales. Use a cron trigger, Monday through Friday at 7am in my timezone. The date window is the whole of the previous calendar day, midnight to midnight.

Start by pulling yesterday's sales from Keap. Use List orders to get every order dated the previous day, and List Payments to get every payment recorded that day. Where an order has more than one payment against it, call Retrieve Order Payments for that order to get the payment level detail, so a split payment or a payment plan installment appears as its own line instead of being collapsed into a single order total.

Paginate every Keap list call all the way to the end before moving on. Keap v1 list endpoints use offset pagination with a limit of up to 1000 plus an offset, and v2 uses cursor pagination with page_size and a next_page_token that you pass back until it comes back empty. A busy day will exceed a single page, and a partial fetch would silently truncate the ledger. Keap monetary amounts are already decimal values in the account currency, for example 12.50, so use them as they come back and do not divide by 100.

Write the results to Google Sheets using Append Values against my ledger tab, one row per payment, with these columns in this order: date, order id, contact name, product, amount, payment method. Use Append Values only. Do not use Update Values or anything else that writes to a fixed range, because that would overwrite history. Rows must always land after the last row already in the tab. This sheet is a permanent ledger my bookkeeper reconciles against, so nothing already written may be overwritten, cleared, or re-sorted. If a field is missing on a given payment, for example a product name on a manually recorded payment, write an empty cell rather than skipping the row.

Then send one Slack message using Send a Message on the Slack Bot integration to my finance channel. The message should state the number of orders for the day, the gross total, and the largest single order including the contact name on it. Keep it to one short readable message rather than a table.

If there were no payments at all yesterday, do not append anything to the sheet and post a single line saying no payments recorded for that date. Never post an empty or blank summary message.

Related prompts

Explore more prompts
Call overdue Xero customers with an AI collections agentLocal listing health board for every location you manageLet support send one-off Loops emails without an engineerA brand asset library your marketing team actually searchesTurn Mailjet email clicks into ranked HubSpot follow-upsClean out the Looker dashboards and Looks nobody opensStop cold emails to anyone with a live deal in PipedriveLiveKit live operations console for room moderationWake up dormant Keap leads with a researched reasoniMessage campaign console with pre-flight checks and delivery board