Skip to content

SMS Support

An AI-powered WhatsApp support system that provides instant assistance to E!BA Academy staff using a comprehensive procedure handbook. The system combines conversational AI with document retrieval to deliver accurate, context-aware responses while maintaining strict formatting standards for WhatsApp messaging.

Purpose

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

Based on the workflow configuration, this system appears to serve E!BA Academy staff including Program Officers, Trainers, Field Operations Assistants (FOAs), and site staff. It provides instant access to procedure handbook information via WhatsApp, helping staff quickly resolve questions about daily operations, safeguarding protocols, retention strategies, and other program-related procedures during the 4-week non-residential program running from August 25 - September 19, 2025 in Mayuge and Iganga, Eastern Uganda.

How It Works

  1. Incoming Message: Staff send WhatsApp messages to the designated number, which triggers the webhook
  2. AI Processing: The message is processed by an OpenAI GPT-4o-mini model configured as an E!BA Academy Assistant
  3. Handbook Search: The AI automatically searches the vectorized procedure handbook using the retrieval tool to find relevant information
  4. Memory Management: The system maintains conversation context using a sliding window memory (20 messages) per user
  5. Response Generation: AI generates a response based on handbook content, following strict formatting rules for WhatsApp
  6. Text Cleanup: A cleanup function removes all markdown formatting to ensure plain text output
  7. Response Delivery: The cleaned response is sent back via Twilio WhatsApp API

The system also includes a separate document ingestion flow that allows administrators to upload new handbook content through a form interface, which gets processed and stored in the vector database.

Workflow Diagram

graph TD
    A[WhatsApp Webhook] --> B[E!BA Support Agent]
    B --> C[Text Clean up]
    C --> D[Code in JavaScript1]
    D --> E[Send WhatsApp response E!BA2]

    F[OpenAI Chat Model2] --> B
    G[Simple Memory2] --> B
    H[E!BA Vectorized] --> B

    I[On form submission] --> J[E!BA Storage]
    K[Default Data Loader3] --> J
    L[Embeddings OpenAI2] --> J
    L --> H
    M[Recursive Character Text Splitter1] --> K
    N[Reranker Cohere] --> H

    style A fill:#e1f5fe
    style E fill:#e8f5e8
    style I fill:#fff3e0

Trigger

Primary Trigger: WhatsApp Webhook - Type: HTTP POST webhook - Path: /webhook/33898c22-f5f0-45f0-9983-3fd19c2daebb - Purpose: Receives incoming WhatsApp messages from Twilio

Secondary Trigger: Form Submission - Type: Form trigger - Purpose: Allows administrators to upload new documents to the knowledge base

Nodes Used

Node Type Node Name Purpose
Webhook WhatsApp Webhook Receives incoming WhatsApp messages from Twilio
LangChain Agent E!BA Support Main AI assistant that processes queries and generates responses
OpenAI Chat Model OpenAI Chat Model2 GPT-4o-mini language model for conversation
Buffer Window Memory Simple Memory2 Maintains conversation context (20 message window)
Vector Store (Retrieve) E!BA Vectorized Searches handbook content as a tool for the AI agent
Vector Store (Insert) E!BA Storage Stores new documents in the knowledge base
Code Text Clean up Removes markdown formatting from AI responses
Code Code in JavaScript1 Extracts phone number and prepares response data
Twilio Send WhatsApp response E!BA2 Sends responses back via WhatsApp
Form Trigger On form submission Handles document uploads for knowledge base
Document Loader Default Data Loader3 Processes uploaded documents
Text Splitter Recursive Character Text Splitter1 Splits documents into chunks
Embeddings Embeddings OpenAI2 Creates vector embeddings for documents
Reranker Reranker Cohere Improves search result relevance

External Services & Credentials Required

OpenAI

  • Credential Name: "OpenAi account"
  • Used For: Language model (GPT-4o-mini) and text embeddings
  • Required: OpenAI API key

Twilio

  • Used For: WhatsApp messaging integration
  • Required: Account SID, Auth Token, WhatsApp-enabled phone number

PostgreSQL

  • Credential Name: "Postgres SMS"
  • Used For: Vector storage for document embeddings
  • Required: Database connection string with pgvector extension

Cohere

  • Used For: Document reranking to improve search relevance
  • Required: Cohere API key

Environment Variables

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

Data Flow

Input

  • WhatsApp Messages: Text messages from E!BA Academy staff
  • Document Uploads: PDF/text files containing handbook content (via form)

Processing

  • Messages are processed by AI agent with handbook context
  • Documents are split, embedded, and stored in vector database
  • Conversation history is maintained per user (WaId)

Output

  • WhatsApp Responses: Plain text responses (max 1590 characters)
  • Knowledge Base Updates: New documents added to searchable vector store

Error Handling

The workflow includes basic error handling through the AI agent's instructions: - If handbook doesn't contain relevant information, the system instructs users to escalate to Program Officers or Program Manager - Safeguarding issues are immediately escalated with specific contact information - The system avoids making policy exceptions or providing medical advice

No explicit error handling nodes are present in the workflow structure.

Known Limitations

Based on the AI agent configuration: - Response length limited to 1590 characters for WhatsApp compatibility - No markdown formatting allowed in responses - Cannot replace human escalation for serious issues - Zero tolerance policy enforcement requires human intervention - Limited to handbook content - cannot provide information outside the knowledge base

No related workflows are mentioned in the provided context.

Setup Instructions

Prerequisites

  1. n8n instance with LangChain nodes installed
  2. OpenAI API account
  3. Twilio account with WhatsApp Business API access
  4. PostgreSQL database with pgvector extension
  5. Cohere API account

Configuration Steps

  1. Import Workflow

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

    • Set up OpenAI API credentials ("OpenAi account")
    • Configure Twilio credentials for WhatsApp
    • Set up PostgreSQL connection ("Postgres SMS")
    • Add Cohere API credentials
  3. Database Setup

    • Ensure PostgreSQL has pgvector extension installed
    • Create tables: "SMS RAG For SkillUp" and "skillup"
  4. Webhook Configuration

    • Note the webhook URL from the WhatsApp Webhook node
    • Configure Twilio WhatsApp webhook to point to this URL
  5. Initial Data Load

    • Use the form submission trigger to upload initial handbook documents
    • Verify documents are properly processed and stored
  6. Testing

    • Send test messages to the WhatsApp number
    • Verify responses are generated and formatted correctly
    • Test document retrieval functionality
  7. Activation

    • Activate the workflow
    • Monitor initial usage and adjust system prompts if needed

Important Notes

  • The workflow is currently inactive ("active": false)
  • Ensure proper safeguarding escalation procedures are in place
  • Review and customize the AI agent's system prompt for your specific use case
  • Test thoroughly before deploying to production