Skip to content

Daily Nudge Response Check

This workflow generates daily summaries of user engagement with nudge messages, tracking who responded and who submitted business records. It runs every morning at 8 AM (except Sundays) to analyze the previous day's activity and posts a comprehensive report to Slack for team visibility.

Purpose

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

This workflow appears to be part of a youth entrepreneurship program that sends daily nudges to participants, encouraging them to submit business records. The system tracks two key metrics: whether users responded to nudges and whether they actually submitted their business data. This helps program administrators monitor engagement levels and identify participants who may need additional support or follow-up.

How It Works

  1. Schedule Check: The workflow triggers daily at 8 AM East Africa Time, but immediately skips execution on Sundays
  2. Date Calculation: Calculates yesterday's date in EAT timezone for data analysis
  3. User Status Query: Runs an optimized database query that fetches all active users and determines their response/submission status for yesterday
  4. Summary Computation: Processes the user data to calculate engagement metrics, response rates, and categorize users into responders/non-responders and submitters/non-submitters
  5. Database Storage: Saves the complete summary to the dailyNudgeSummary table for historical tracking
  6. Slack Formatting: Creates a formatted message showing key metrics and lists of non-responsive users
  7. Slack Notification: Posts the summary to a Slack channel for team visibility
  8. Status Update: Records whether the Slack notification was successful or failed

Workflow Diagram

graph TD
    A[Every Day 8AM] --> B[Check Not Sunday]
    C[Manual Test Trigger] --> B
    B --> D[Fetch Users With Status]
    D --> E[Compute Summary]
    E --> F[Save to DB]
    F --> G[Format Slack Message]
    G --> H[Post to Slack]
    H --> I[Update Slack Status]

Trigger

  • Primary: Schedule Trigger - runs daily at 8:00 AM East Africa Time
  • Secondary: Manual Trigger - for testing and manual execution
  • Skip Condition: Automatically skips execution on Sundays

Nodes Used

Node Type Node Name Purpose
Schedule Trigger Every Day 8AM Triggers workflow daily at 8 AM EAT
Manual Trigger Manual Test Trigger Allows manual testing of the workflow
Code Check Not Sunday Skips Sundays and calculates yesterday's date in EAT
Postgres Fetch Users With Status Optimized query to get all active users with response/submission flags
Code Compute Summary Processes user data to calculate engagement metrics and categorize users
Postgres Save to DB Stores the daily summary in the dailyNudgeSummary table
Code Format Slack Message Creates formatted Slack message with metrics and user lists
HTTP Request Post to Slack Sends the summary message to Slack webhook
Postgres Update Slack Status Records whether Slack notification succeeded or failed

External Services & Credentials Required

Slack Webhook

  • Service: Slack Incoming Webhook
  • URL: https://hooks.slack.com/services/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
  • Purpose: Posts daily summaries to team Slack channel

PostgreSQL Database

  • Credential Name: "Postgres account"
  • Tables Used:
    • youthEntrepreneursReal - Active user registry
    • dailyProfitTracking - Business record submissions
    • n8n_chat_histories - User message responses
    • dailyNudgeSummary - Summary storage

Environment Variables

No environment variables are used in this workflow. All configuration is handled through: - Hardcoded Slack webhook URL - Database credentials stored in n8n credential system - Timezone set to "Africa/Nairobi" in workflow settings

Data Flow

Input

  • Active Users: All users with onboardingStatus = 'active' from youthEntrepreneursReal
  • Business Records: Submissions from dailyProfitTracking for yesterday
  • Chat Messages: User responses from n8n_chat_histories for yesterday

Processing

  • Joins user data with response/submission status
  • Calculates response rates and submission rates
  • Categorizes users into engagement groups
  • Formats data for human-readable reporting

Output

  • Database Record: Complete summary stored in dailyNudgeSummary
  • Slack Message: Formatted report with:
    • Total active users
    • Response and submission rates
    • Lists of non-responders (up to 20 shown)
    • Lists of users who responded but didn't submit

Error Handling

  • Slack Posting: Uses continueOnFail: true to prevent workflow failure if Slack is unavailable
  • Status Tracking: Records Slack success/failure status in database for monitoring
  • Sunday Skip: Gracefully exits on Sundays without processing

Known Limitations

  • List Truncation: Only shows first 20 non-responders in Slack to avoid message overflow
  • Timezone Dependency: Hardcoded to East Africa Time (UTC+3)
  • Sunday Skip: No processing on Sundays, which may miss Saturday night submissions
  • Performance: Single optimized query replaced previous 3-query approach that caused stack overflow with large datasets

No related workflows specified in the current context.

Setup Instructions

  1. Import Workflow: Import the JSON into your n8n instance

  2. Configure Database Credentials:

    • Create PostgreSQL credential named "Postgres account"
    • Ensure access to required tables:
      • youthEntrepreneursReal
      • dailyProfitTracking
      • n8n_chat_histories
      • dailyNudgeSummary
  3. Set Up Slack Integration:

    • Create Slack incoming webhook
    • Update the webhook URL in the "Post to Slack" node
    • Test webhook connectivity
  4. Verify Timezone:

    • Confirm workflow timezone is set to "Africa/Nairobi"
    • Adjust schedule trigger if different timezone needed
  5. Test Execution:

    • Use "Manual Test Trigger" to verify workflow functionality
    • Check database records are created correctly
    • Verify Slack messages are formatted properly
  6. Activate Workflow:

    • Enable the workflow for daily execution
    • Monitor initial runs for any issues
  7. Database Schema:

    • Ensure dailyNudgeSummary table exists with required columns
    • Verify proper indexes for performance on large datasets