WhatsApp Business Support Trigger¶
This workflow provides WhatsApp-based customer support by receiving messages via Twilio, validating users against a database, and routing queries to an AI sales tracking agent for intelligent responses.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
How It Works¶
- Incoming WhatsApp Message: A webhook receives WhatsApp messages sent via Twilio
- User Validation: The system checks if the sender's phone number exists in the youth entrepreneurs database
- Route Decision: If the user is not found, an error message is sent; if found, the query proceeds
- Data Preparation: The user's phone number and message are formatted for processing
- AI Agent Processing: The query is sent to a specialized sales tracking agent workflow
- Response Delivery: The AI-generated response is sent back to the user via WhatsApp
The workflow also includes a separate manual trigger path for exporting user data to Google Sheets.
Workflow Diagram¶
graph TD
A[Twilio WhatsApp Webhook] --> B[Execute SQL Query - User Lookup]
B --> C{User Found?}
C -->|No| D[Send "User Not Found" Message]
C -->|Yes| E[Set User Phone & Query]
E --> F[Call Sales Tracking Agent]
F --> G[Send WhatsApp Response]
H[Manual Trigger] --> I[Execute SQL Query - All Users]
I --> J[Append to Google Sheets]
Trigger¶
- Primary: Webhook trigger listening for POST requests from Twilio WhatsApp
- Secondary: Manual trigger for data export operations
Nodes Used¶
| Node Type | Purpose |
|---|---|
| Webhook | Receives incoming WhatsApp messages from Twilio |
| PostgreSQL | Queries user database for validation and data export |
| IF | Conditional logic to check if user exists |
| Set | Formats user data for downstream processing |
| Execute Workflow | Calls the sales tracking agent workflow |
| Twilio | Sends WhatsApp responses back to users |
| Manual Trigger | Allows manual execution for data export |
| Google Sheets | Exports user data to spreadsheet |
External Services & Credentials Required¶
Twilio¶
- Credential Name: "Twilio WhatsApp kdp"
- Purpose: Send and receive WhatsApp messages
- Required: Account SID, Auth Token, WhatsApp-enabled phone number
PostgreSQL (Supabase)¶
- Credential Name: "PostgresOnSupabase"
- Purpose: User database access
- Required: Host, database name, username, password
Google Sheets¶
- Credential Name: "Google Sheets account 3"
- Purpose: Data export functionality
- Required: OAuth2 credentials with Sheets API access
Environment Variables¶
No specific environment variables are configured in this workflow. All configuration is handled through n8n credentials.
Data Flow¶
Input¶
- WhatsApp Message: Contains sender phone number (WaId), message body, and Twilio metadata
- Manual Trigger: No input data required
Processing¶
- Phone numbers are normalized with "+" prefix
- User existence is validated against the "youthEntrepreneursReal" table
- Valid queries are packaged with phone number, message, and channel information
Output¶
- WhatsApp Response: AI-generated response or error message
- Google Sheets: Complete user database export (manual trigger path)
Error Handling¶
- User Not Found: Sends standardized error message "Sorry, your number was not found in our database"
- Workflow Retry: The sales tracking agent call has retry-on-fail enabled
- Webhook Disabled: The primary webhook is currently disabled (likely for testing)
Known Limitations¶
- Webhook trigger is currently disabled
- No validation for message content or format
- Single database table dependency for user validation
- No rate limiting or spam protection visible
Related Workflows¶
- Mark - SalesTrackingAgent (ID: SQuf6XRV3xERKdsY): Handles the actual AI processing of user queries
Setup Instructions¶
-
Import Workflow: Import the JSON into your n8n instance
-
Configure Credentials:
- Set up Twilio API credentials with WhatsApp sandbox or production access
- Configure PostgreSQL connection to your user database
- Set up Google Sheets OAuth2 credentials
-
Database Setup: Ensure the "youthEntrepreneursReal" table exists with required columns:
phoneNumber(string)- Other user fields as shown in the Google Sheets mapping
-
Webhook Configuration:
- Enable the webhook trigger
- Configure Twilio webhook URL to point to your n8n webhook endpoint
- Set up WhatsApp number in Twilio console
-
Dependent Workflow: Ensure the "Mark - SalesTrackingAgent" workflow is available and properly configured
-
Testing: Use the pinned test data to verify the workflow processes messages correctly
-
Production: Enable the webhook trigger and configure Twilio to send production traffic