Skip to content

KDP Workflow

This workflow implements "Mshauri," an AI-powered business coach designed to help young entrepreneurs in rural Kenya manage credit challenges through SMS and WhatsApp interactions. The system provides personalized coaching in multiple languages and tracks business metrics to support youth entrepreneurship programs.

Purpose

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

Based on the workflow configuration, this appears to be part of the Educate! Kenya Digital Product, supporting out-of-school youth entrepreneurs across Makueni and other Kenyan counties. The AI coach specializes in credit management coaching, helping youth recover money owed, prevent bad credit habits, and build confidence in charging for their products and services. The goal is to achieve a 20% uplift in youth business profit by providing accessible business coaching via SMS (shortcode 24436) and WhatsApp.

How It Works

  1. Message Reception: The workflow receives incoming messages from two channels - WhatsApp (via Twilio webhook) and SMS (via Africa's Talking webhook)
  2. Message Processing: JavaScript code processes the incoming message data and prepares it for the AI agent
  3. AI Coaching: The Mshauri AI agent analyzes the youth's business challenge and provides personalized coaching advice in their preferred language (English, Swahili, or Sheng)
  4. Data Storage: Airtable tools store conversation data and business metrics for program tracking
  5. Response Routing: A switch node determines the appropriate response channel
  6. Message Delivery: Responses are sent back via WhatsApp through Twilio

The AI agent is specifically trained to: - Provide exactly 3 micro-actions per conversation - Communicate in mobile-friendly, short messages - Focus exclusively on credit management challenges - Reference previous conversations for continuity - Escalate severe financial distress cases to Community Education Advisors

Mermaid Diagram

graph TD
    A[Twilio WhatsApp Webhook] --> C[Code in JavaScript1]
    B[Africa's Talking SMS Webhook] --> D[AI Agent]
    C --> D
    D --> E[Code in JavaScript2]
    E --> F[Switch]
    F --> G[Send WhatsApp response via Twilio]

    H[OpenRouter Chat Model] --> D
    I[Get a record in Airtable] --> D
    J[Get a record in Airtable1] --> D

    style A fill:#e1f5fe
    style B fill:#e1f5fe
    style D fill:#fff3e0
    style G fill:#e8f5e8

Trigger

The workflow is triggered by incoming messages through two webhook endpoints: - WhatsApp: Twilio webhook at path e733f4f7-5496-4f25-ae81-5b02094461bd - SMS: Africa's Talking webhook at path eda54d73-9621-4f15-b1db-4affd2f92668

Both webhooks accept POST requests and process incoming messages from youth entrepreneurs.

Nodes Used

Node Type Purpose
Webhook Receives incoming WhatsApp and SMS messages
Code (JavaScript) Processes message data and prepares responses
AI Agent Provides business coaching using the Mshauri persona
OpenRouter Chat Model Powers the AI agent with language model capabilities
Airtable Tool Stores and retrieves conversation and business metric data
Switch Routes responses to appropriate delivery channels
Twilio Sends WhatsApp responses back to users

External Services & Credentials Required

Required Credentials:

  • OpenRouter API (openRouterApi): For AI language model access
  • Airtable Token API (airtableTokenApi): For data storage and retrieval
  • Twilio API (twilioApi): For WhatsApp message sending

External Services:

  • OpenRouter: Provides access to language models for AI coaching
  • Airtable: Stores conversation history and business metrics
  • Twilio: Handles WhatsApp message delivery
  • Africa's Talking: Receives SMS messages (webhook only)

Environment Variables

No specific environment variables are configured in this workflow. All external service connections are managed through n8n credential system.

Data Flow

Input:

  • WhatsApp Messages: JSON payload from Twilio containing message content, sender phone number, and metadata
  • SMS Messages: Form data from Africa's Talking with message text, sender number, and delivery details

Processing:

  • Message content is extracted and processed
  • AI agent analyzes the business challenge
  • Conversation history and metrics are stored in Airtable
  • Response is generated with exactly 3 micro-actions

Output:

  • WhatsApp Response: Coaching advice sent via Twilio WhatsApp API
  • Data Storage: Conversation records and business metrics saved to Airtable

Error Handling

The workflow currently has limited explicit error handling. All nodes are marked as disabled, suggesting this is a draft or staging version. In production, error handling should include: - Webhook validation for incoming messages - Fallback responses if AI agent fails - Retry logic for external API calls - Escalation paths for technical failures

Known Limitations

Based on the AI agent configuration: - Responses are limited to 160 characters per SMS message - Only handles business coaching topics (redirects other inquiries) - Requires manual escalation for severe financial distress cases - Depends on stable internet connectivity for rural users - Limited to credit management coaching scope

No related workflows are mentioned in the current configuration. This appears to be a standalone coaching system.

Setup Instructions

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

  2. Configure Credentials:

    • Set up OpenRouter API credentials for AI model access
    • Configure Airtable API token for data storage
    • Add Twilio API credentials for WhatsApp messaging
  3. Set Up Webhooks:

    • Configure Twilio webhook to point to the WhatsApp webhook URL
    • Set up Africa's Talking SMS webhook endpoint
    • Ensure both webhooks are accessible from external services
  4. Configure Airtable:

    • Set up Airtable base and tables for conversation storage
    • Configure table schemas to match the workflow requirements
    • Update Airtable node configurations with correct base and table IDs
  5. Test Channels:

    • Send test messages via WhatsApp to verify Twilio integration
    • Test SMS functionality through Africa's Talking
    • Verify AI responses are appropriate and formatted correctly
  6. Enable Workflow: Remove the disabled: true flags from all nodes and activate the workflow

  7. Monitor Performance: Set up logging and monitoring to track conversation quality and system performance