Skip to content

Support Chatbot

An AI-powered support chatbot that provides instant assistance to SkillUp Bootcamp team members through Telegram, with the ability to upload and query documents for enhanced knowledge-based responses.

Purpose

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

Based on the workflow configuration, this appears to be a support system designed to help bootcamp staff (Program Officers, Trainers, Site Assistants) get immediate guidance on daily operations, safeguarding protocols, retention strategies, and other program-related questions. The chatbot can access uploaded documents (PDFs, CSVs, JSON files) to provide contextual answers from the organization's knowledge base.

How It Works

  1. Document Upload: Staff can upload PDF, CSV, or JSON documents through a web form to build the knowledge base
  2. File Processing: Uploaded files are automatically categorized by type and processed with appropriate document loaders
  3. Knowledge Indexing: Documents are split into chunks, embedded using OpenAI, and stored in a vector database for retrieval
  4. Chat Interface: Users interact with the bot through Telegram messages
  5. AI Response: The bot uses GPT-4 to generate responses, consulting the knowledge base when needed
  6. Instant Support: Responses are sent back through Telegram with actionable guidance

Workflow Diagram

graph TD
    A[File Upload Form] --> B[Workflow Configuration]
    B --> C[Route by File Type]
    C --> D[Add Metadata - PDF]
    C --> E[Add Metadata - CSV]
    C --> F[Add Metadata - JSON]
    D --> G[Vector Store - Insert Documents]
    E --> G
    F --> G
    H[Token Splitter] --> I[Document Loader - PDF]
    H --> J[Document Loader - CSV/JSON]
    I --> G
    J --> G
    K[Telegram Trigger] --> L[Knowledge Base Agent]
    L --> M[Send Text Message]
    N[OpenAI Embeddings] --> G
    N --> O[Vector Store - Retrieve Tool]
    P[OpenAI Chat Model] --> L
    O --> L
    Q[Twilio WhatsApp Trigger]
    R[Twilio WhatsApp Response Tool]

Trigger

  • Telegram Trigger: Activates when users send messages to the configured Telegram bot
  • File Upload Form: Web form trigger for uploading documents to the knowledge base
  • Twilio WhatsApp Trigger: Configured but not actively connected in the current flow

Nodes Used

Node Type Purpose
Form Trigger Provides web interface for document uploads
Set (Workflow Configuration) Adds metadata like upload date, filename, and file type
Switch (Route by File Type) Routes files to appropriate processors based on MIME type
Set (Add Metadata) Adds file-specific metadata for PDF, CSV, and JSON files
Document Loaders Extracts text content from uploaded files
Token Splitter Breaks documents into 1000-token chunks with 100-token overlap
Vector Store Stores and retrieves document embeddings for similarity search
OpenAI Embeddings Converts text to vector embeddings
OpenAI Chat Model GPT-4 model for generating responses
LangChain Agent Orchestrates the AI conversation with knowledge base access
Telegram Sends responses back to users

External Services & Credentials Required

  • OpenAI API: For embeddings and chat completions
    • Credential: "OpenAi account"
    • Used for: Text embeddings and GPT-4 responses
  • Telegram Bot API: For chat interface
    • Credential: "Waringa"
    • Used for: Receiving and sending messages
  • Twilio API: For WhatsApp integration (configured but unused)
    • Credential: "twilio samy b"
    • Used for: WhatsApp messaging capabilities

Environment Variables

No specific environment variables are configured in this workflow. All external service connections use n8n credential management.

Data Flow

Input: - Telegram messages with user questions - File uploads (PDF, CSV, JSON) through web form

Processing: - Documents are chunked, embedded, and stored in vector database - User queries are processed by AI agent with access to knowledge base - Relevant document chunks are retrieved based on semantic similarity

Output: - Contextual responses sent via Telegram - Confirmation of successful document uploads

Error Handling

The workflow includes basic routing logic but no explicit error handling nodes. Potential failure points: - File upload failures (unsupported formats) - OpenAI API rate limits or failures - Telegram delivery issues - Document processing errors for corrupted files

Known Limitations

  • Currently only supports PDF, CSV, and JSON file formats
  • Vector store is in-memory only (data lost on workflow restart)
  • No user authentication or access control
  • WhatsApp integration is configured but not connected to the main flow
  • No conversation history or session management

No related workflows mentioned in the provided context.

Setup Instructions

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

  2. Configure Credentials:

    • Set up OpenAI API credentials with access to embeddings and chat models
    • Create Telegram bot and configure API credentials
    • (Optional) Set up Twilio credentials for WhatsApp integration
  3. Activate Triggers:

    • Enable the Telegram trigger webhook
    • Enable the file upload form webhook
    • Test both triggers are receiving data
  4. Test Document Upload:

    • Access the file upload form URL
    • Upload a test PDF, CSV, or JSON file
    • Verify successful processing in execution logs
  5. Test Chat Interface:

    • Send a test message to your Telegram bot
    • Verify the bot responds with appropriate guidance
    • Test knowledge base queries with uploaded document content
  6. Customize System Prompt:

    • Modify the Knowledge Base Agent system prompt to match your organization's needs
    • Update the tool description for the Vector Store Retrieve Tool
  7. Monitor Performance:

    • Check OpenAI usage and costs
    • Monitor response times and accuracy
    • Adjust chunk size and overlap if needed for better retrieval