Skip to content

Waiting Message

This workflow intelligently determines when to send "working on it" messages to teachers using a WhatsApp-based PBA (Project-Based Assessment) support system. It analyzes incoming teacher queries and automatically sends contextual waiting messages for complex requests that require time-intensive processing like voice transcription, project lookups, or detailed guidance retrieval.

Purpose

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

This workflow serves as a user experience enhancement for a teacher support system, ensuring teachers receive immediate feedback when their queries will take time to process. It prevents the frustration of waiting without acknowledgment and sets appropriate expectations for response times.

How It Works

  1. Input Processing: The workflow receives a teacher's message and phone number information through the Execute Workflow Trigger
  2. Initial Delay: A 2-second wait ensures the system has time to process the incoming request
  3. AI Analysis: An AI agent analyzes the teacher's query to determine if it requires time-intensive processing (voice transcription, project lookups, rubric searches, etc.)
  4. Decision Processing: JavaScript code parses the AI's decision and extracts phone numbers from the input data
  5. Conditional Response: If a waiting message is needed, it sends an appropriate contextual message via WhatsApp; otherwise, it takes no action

The AI agent is specifically trained to recognize patterns that indicate complex processing needs, such as voice inputs, project-specific queries, detailed guidance requests, CAMIS upload questions, and lesson planning inquiries.

Workflow Diagram

graph TD
    A[Start] --> B[Wait 2 seconds]
    B --> C[AI Agent]
    D[OpenRouter Chat Model] --> C
    E[Simple Memory] --> C
    C --> F[Code in JavaScript]
    F --> G{If shouldSend?}
    G -->|Yes| H[Send WhatsApp response]
    G -->|No| I[No Operation]

Trigger

Execute Workflow Trigger - This workflow is designed to be called by other workflows, not triggered directly by external events.

Required Inputs: - body_To_replace: The teacher's message content - body_WaId: Phone number information in format "senderNumber=receiverNumber"

Nodes Used

Node Type Purpose
Execute Workflow Trigger Receives input data from calling workflows
Wait Introduces 2-second delay for processing coordination
AI Agent Analyzes teacher queries to determine if waiting message needed
OpenRouter Chat Model Provides AI language model (Google Gemini 2.5 Flash Lite)
Simple Memory Maintains conversation context using session-based memory
Code (JavaScript) Parses AI decision and extracts phone numbers
If Routes execution based on whether waiting message should be sent
Twilio Sends WhatsApp messages to teachers
No Operation Placeholder for when no action is needed

External Services & Credentials Required

OpenRouter API

  • Purpose: AI language model access for query analysis
  • Credential Name: "OpenRouter Org"
  • Required: API key for OpenRouter service

Twilio API

  • Purpose: WhatsApp message delivery
  • Credential Name: "PBA Hitesh"
  • Required: Twilio Account SID, Auth Token, and WhatsApp-enabled phone number

Environment Variables

No environment variables are explicitly configured in this workflow. All configuration is handled through node parameters and credentials.

Data Flow

Input

1
2
3
4
{
  "body_To_replace": "Teacher's message content",
  "body_WaId": "254712287952=14177633451"
}

Processing

The AI agent receives the teacher's message and returns a decision in JSON format:

1
2
3
4
{
  "shouldSend": true,
  "message": "Looking up the rubric... 📝"
}

Output

  • If waiting message needed: WhatsApp message sent to teacher
  • If no waiting message needed: No action taken

Error Handling

The workflow includes basic error handling through: - JSON parsing protection: JavaScript code safely handles malformed AI responses - Conditional execution: If node prevents unnecessary operations when no message is needed - No Operation fallback: Ensures workflow completes successfully even when no action is required

No explicit error notification or retry mechanisms are implemented.

Known Limitations

  • Relies on AI agent accuracy for decision-making
  • No retry mechanism for failed WhatsApp deliveries
  • Phone number parsing assumes specific format ("sender=receiver")
  • 2-second delay is fixed and may not be optimal for all scenarios
  • No validation of phone number formats before sending messages

This workflow is designed to be called by other workflows in the PBA teacher support system, likely including: - Main teacher query processing workflows - Voice message handling workflows - Project lookup workflows

Setup Instructions

  1. Import the workflow into your n8n instance

  2. Configure OpenRouter credentials:

    • Create OpenRouter API account
    • Add credential named "OpenRouter Org"
    • Enter your OpenRouter API key
  3. Configure Twilio credentials:

    • Set up Twilio account with WhatsApp Business API
    • Add credential named "PBA Hitesh"
    • Enter Account SID, Auth Token, and WhatsApp phone number
  4. Test the workflow:

    • Use the pinned test data or create your own
    • Verify AI agent responses are properly formatted
    • Confirm WhatsApp messages are delivered correctly
  5. Integration:

    • Call this workflow from your main teacher support workflows
    • Pass required parameters: body_To_replace and body_WaId
    • Ensure phone number format matches expected pattern
  6. Monitoring:

    • Monitor execution logs for AI decision accuracy
    • Track WhatsApp delivery success rates
    • Adjust AI agent prompts if decision quality needs improvement