V4 - pauseUserTool¶
A utility workflow that pauses users in the SIFA system by updating their emotional pause status and logging the event. This workflow is designed to be called by other workflows when a user needs to be temporarily paused from receiving communications or services.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
This workflow serves as a centralized tool for pausing users in the SIFA V4 system. It updates user records to mark them as emotionally paused and creates an audit trail by logging the pause event with the reason provided.
How It Works¶
- Receives Input: The workflow is triggered by another workflow with a phone number and reason for pausing
- Updates Database: Executes a SQL query that marks the user as emotionally paused and records the timestamp and reason
- Logs Event: Simultaneously inserts an emotional event record for audit purposes
- Returns Confirmation: Sends back a success response with the event ID for tracking
Workflow Diagram¶
graph TD
A[When Executed by Another Workflow] --> B[Pause User SQL]
B --> C[Return Result]
A -.->|phoneNumber, reason| B
B -.->|event_id| C
C -.->|success: true, event_id| D[Calling Workflow]
Trigger¶
Execute Workflow Trigger: This workflow is designed to be called by other workflows, not triggered directly by external events.
Required Inputs:
- phoneNumber: The phone number of the user to pause
- reason: The reason for pausing the user
Nodes Used¶
| Node Name | Type | Purpose |
|---|---|---|
| When Executed by Another Workflow | Execute Workflow Trigger | Receives input parameters from calling workflows |
| Pause User SQL | PostgreSQL | Updates user pause status and creates event log |
| Return Result | Code | Formats and returns the success response |
External Services & Credentials Required¶
PostgreSQL Database¶
- Credential Name:
sifaV4Dev - Purpose: Access to the SIFA V4 database for user and event management
- Required Permissions:
- UPDATE on
v4_youthEntrepreneurstable - INSERT on
v4_emotionaleventstable
- UPDATE on
Environment Variables¶
No environment variables are used in this workflow. All configuration is handled through n8n credentials.
Data Flow¶
Input¶
1 2 3 4 | |
Output¶
1 2 3 4 | |
Database Operations¶
- User Update: Sets
is_emotionally_paused = true, records the reason and timestamp - Event Logging: Creates an emotional event record with type 'pause' and severity 'agent_assessed'
Error Handling¶
This workflow uses basic error handling through n8n's default mechanisms: - Database connection failures will stop execution - SQL errors will be propagated to the calling workflow - The Return Result node will only execute if the SQL operation succeeds
Known Limitations¶
- No validation of phone number format
- No check if user is already paused
- No rollback mechanism if event logging fails after user update
- Assumes the calling workflow handles error responses appropriately
Related Workflows¶
This is a utility workflow designed to be called by other workflows in the SIFA system. Look for workflows that handle user management or emotional support features.
Setup Instructions¶
-
Import Workflow: Import the JSON into your n8n instance
-
Configure Database Credential:
- Create a PostgreSQL credential named
sifaV4Dev - Configure connection to your SIFA V4 database
- Ensure the credential has UPDATE and INSERT permissions
- Create a PostgreSQL credential named
-
Verify Database Schema:
- Confirm
v4_youthEntrepreneurstable exists with required columns:phoneNumber,is_emotionally_paused,emotional_pause_reason,emotional_paused_at
- Confirm
v4_emotionaleventstable exists with required columns:phonenumber,event_type,severity,reason,created_at
- Confirm
-
Test the Workflow:
- Use n8n's "Execute Workflow" feature from another workflow
- Pass test data:
{"phoneNumber": "test123", "reason": "Testing"} - Verify database updates and returned event ID
-
Activate: Set the workflow to active status so other workflows can call it
Note: This workflow is designed as a utility and should not be triggered directly by external webhooks or schedules.