saveCreditRecordTool - Francis¶
A utility workflow that saves and updates credit tracking records for business owners, maintaining real-time visibility into credit given to customers, recovery progress, and micro-actions taken to improve credit collection.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
Based on the workflow structure, this appears to be a credit management tool that helps business owners track: - Credit extended to customers - Daily credit recovery activities - Weekly recovery targets and progress - Micro-actions taken to improve credit collection - Overall credit module progression stages
How It Works¶
- Receive Credit Data: The workflow accepts comprehensive credit tracking information including customer counts, baseline amounts, recovery targets, and daily transactions
- Upsert Database Record: Performs a sophisticated database operation that either inserts a new credit record or updates an existing one, calculating running totals for locked credit and weekly recovery progress
- Return Summary: Provides a formatted response showing the current credit status including total locked amount, weekly recovery progress, and current module stage
Workflow Diagram¶
graph TD
A[When Executed by Another Workflow] --> B[upsertCreditRecord]
B --> C[setOutput]
Trigger¶
Execute Workflow Trigger: This workflow is designed to be called by other workflows, not triggered directly. It accepts 18 different input parameters related to credit tracking and management.
Nodes Used¶
| Node | Type | Purpose |
|---|---|---|
| When Executed by Another Workflow | Execute Workflow Trigger | Receives credit tracking data from calling workflows |
| upsertCreditRecord | PostgreSQL | Inserts or updates credit records with complex calculations |
| setOutput | Set | Formats a summary response with key credit metrics |
External Services & Credentials Required¶
- PostgreSQL Database: Requires "PostgresOnSupabase" credential for database operations
- Database must contain a
creditTrackingtable with appropriate schema - Connection details needed: host, port, database name, username, password
- Database must contain a
Environment Variables¶
No environment variables are used in this workflow. All configuration is handled through the PostgreSQL credential.
Data Flow¶
Input Parameters¶
phoneNumber(string): Unique identifier for the business ownercreditCustomersCount(number): Number of customers with credittotalCreditBaseline(number): Base credit amountcreditCustomerTypes(string): Types of credit customerscreditTypicalDays(number): Typical credit durationweeklyRecoveryTarget(number): Weekly recovery goaltargetCustomers(number): Target customer countcreditGivenToday(number): Credit extended todaycreditRecoveredToday(number): Credit recovered todaymicroActionType(string): Type of micro-action takenmicroActionScript(string): Script for micro-actionmicroActionAttempted(boolean): Whether micro-action was attemptedmicroActionOutcome(string): Result of micro-actionamountRecovered(number): Amount recovered from micro-actionnextAction(string): Next planned actioncreditModuleStage(string): Current stage in credit modulecreditSkipReason(string): Reason for skipping actionsweekNumber(number): Current week number
Output¶
output(string): Formatted summary including total credit locked, weekly recovery progress, and current stage
Error Handling¶
The workflow uses PostgreSQL's built-in error handling. If the database operation fails, the workflow will stop and return an error. The upsert operation includes:
- Conflict resolution using ON CONFLICT clause
- COALESCE functions to handle null values gracefully
- GREATEST function to ensure credit amounts don't go negative
Known Limitations¶
- Requires existing
creditTrackingtable with specific schema - No input validation - relies on calling workflow to provide correct data types
- Limited error reporting - database errors may not be user-friendly
- No rollback mechanism for failed operations
Related Workflows¶
This workflow is designed to be called by other credit management workflows but no specific related workflows are identified in the current documentation.
Setup Instructions¶
- Import Workflow: Import the JSON into your n8n instance
- Configure Database Credential:
- Create a PostgreSQL credential named "PostgresOnSupabase"
- Configure connection to your Supabase or PostgreSQL instance
- Create Database Table: Ensure your database has a
creditTrackingtable with columns matching the workflow's INSERT statement - Test Connection: Run a test execution to verify database connectivity
- Integration: Call this workflow from other workflows using the Execute Workflow node, passing the required 18 parameters
The workflow is ready to use once the database credential is configured and the target table exists.