Skip to content

V4 - unpauseUserTool

This workflow provides a service to resume users who have been emotionally paused in the system. It updates the user's pause status in the database and logs the resume event for audit purposes.

Purpose

No business context provided yet — add a context.md to enrich this documentation.

This workflow serves as a utility tool that can be called by other workflows to unpause users who were previously emotionally paused. It handles the database operations needed to restore a user's active status and maintains an audit trail of emotional state changes.

How It Works

  1. Receives Input: The workflow is triggered by another workflow with a phone number and reason for unpausing
  2. Updates Database: Executes SQL to clear the emotional pause flags and timestamps for the specified user
  3. Logs Event: Inserts a resume event into the emotional events audit table
  4. Returns Result: Provides confirmation of success along with the event ID for tracking

Workflow Diagram

graph TD
    A[When Executed by Another Workflow] --> B[Unpause User SQL]
    B --> C[Return Result]

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 unpause - reason: The reason for unpausing the user

Nodes Used

Node Name Type Purpose
When Executed by Another Workflow Execute Workflow Trigger Receives input parameters from calling workflow
Unpause User SQL PostgreSQL Updates user pause status and logs resume event
Return Result Code Formats the response with success status and event ID

External Services & Credentials Required

PostgreSQL Database: - Credential: sifaV4Dev - Used for: Updating user emotional pause status and logging events - Tables accessed: v4_youthEntrepreneurs, v4_emotionalevents

Environment Variables

No environment variables are used in this workflow. All configuration is handled through n8n credentials.

Data Flow

Input:

1
2
3
4
{
  "phoneNumber": "string",
  "reason": "string"
}

Output:

1
2
3
4
{
  "success": true,
  "event_id": "number|null"
}

Database Operations: 1. Updates v4_youthEntrepreneurs table to clear pause flags 2. Inserts resume event into v4_emotionalevents table with severity "agent_assessed"

Error Handling

This workflow does not implement explicit error handling. Database errors or connection issues will cause the workflow to fail and return an error to the calling workflow.

Known Limitations

  • No input validation on phone number format
  • No verification that the user exists before attempting to unpause
  • Database errors are not caught or handled gracefully
  • No rollback mechanism if the event logging fails after user update

This workflow is designed to be called by other workflows that need to unpause users. Look for workflows that handle user management or emotional state changes.

Setup Instructions

  1. Import the Workflow:

    • Copy the workflow JSON
    • Import into your n8n instance
  2. Configure Database Credentials:

    • Set up PostgreSQL credentials named sifaV4Dev
    • Ensure connection to database with v4_youthEntrepreneurs and v4_emotionalevents tables
  3. Database Schema Requirements:

    • v4_youthEntrepreneurs table must have columns: phoneNumber, is_emotionally_paused, emotional_pause_reason, emotional_paused_at
    • v4_emotionalevents table must have columns: phonenumber, event_type, severity, reason, created_at, id
  4. Test the Workflow:

    • Call from another workflow with test phone number and reason
    • Verify database updates occur correctly
    • Check that event ID is returned in response
  5. Integration:

    • Use the "Execute Workflow" node in other workflows to call this service
    • Pass required phoneNumber and reason parameters