PBA PL Demo - AI-Powered Student Project Support Bot¶
An intelligent Telegram bot that helps students discover and learn about academic projects across different terms, senior years, and subjects. The bot uses AI to provide contextual responses about project titles and descriptions, with collaborative prompt management through PromptLayer and comprehensive conversation logging.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
Based on the workflow implementation, this bot appears to serve students and educators by: - Providing instant access to project information across different academic terms and subjects - Maintaining conversation context to deliver relevant, personalized responses - Enabling non-technical teams to collaboratively manage and update bot behavior through PromptLayer - Tracking all interactions for analysis and improvement
How It Works¶
- Message Reception: A user sends a message to the Telegram bot
- Prompt Retrieval: The system fetches the latest approved prompt from PromptLayer using the "prod" tag
- AI Processing: The Support Bot agent processes the user's message using:
- The retrieved prompt as system instructions
- Conversation history from memory
- Access to project database through Airtable tool
- Response Generation: The AI model (Google Gemini) generates a contextual response
- Message Delivery: The bot sends the response back to the user via Telegram
- Interaction Logging: The complete conversation is logged to PromptLayer for analysis
The bot can search for specific projects by term, senior year, and subject, providing students with detailed project descriptions and challenges they aim to solve.
Workflow Diagram¶
graph TD
A[Message to bot] --> B[Pull Prompt from PromptLayer]
B --> C[Support Bot]
D[OpenRouter Chat Model] --> C
E[Simple Memory] --> C
F[Get project titles and descriptions] --> C
C --> G[Send Bot's Response]
G --> H[HTTP Request - Log to PromptLayer]
I[Webhook]
J[Embeddings Google Gemini]
Trigger¶
Telegram Trigger: Activates when users send messages to the configured Telegram bot. The trigger captures message content and user information to initiate the workflow.
Nodes Used¶
| Node Type | Purpose |
|---|---|
| Telegram Trigger | Receives incoming messages from users |
| HTTP Request (PromptLayer) | Fetches the production-tagged prompt template |
| LangChain Agent | Core AI bot that processes messages and generates responses |
| OpenRouter Chat Model | Google Gemini 2.5 Flash Lite language model for AI responses |
| Airtable Tool | Searches project database by term, grade, and subject |
| Buffer Window Memory | Maintains conversation context with 1-message window |
| Telegram Send | Delivers bot responses back to users |
| HTTP Request (Logging) | Logs interactions to PromptLayer for analysis |
| Webhook | Additional endpoint (purpose unclear from current connections) |
| Google Gemini Embeddings | Text embeddings (not currently connected) |
External Services & Credentials Required¶
PromptLayer¶
- Purpose: Collaborative prompt management and interaction logging
- Credentials: API key for prompt retrieval and logging
- Configuration: Prompt template named "pbapldemo" with "prod" label
OpenRouter¶
- Purpose: Access to Google Gemini 2.5 Flash Lite model
- Credentials: OpenRouter API credentials
- Model:
google/gemini-2.5-flash-lite
Telegram¶
- Purpose: Bot messaging platform
- Credentials: Telegram Bot API token
- Setup: Bot must be created via BotFather
Airtable¶
- Purpose: Project database storage
- Credentials: Airtable API token
- Database: "PBA Virtual Bot Project" base with "PBA Projects' Title and Description" table
Google AI¶
- Purpose: Text embeddings (if enabled)
- Credentials: Google Palm API key
Environment Variables¶
No explicit environment variables are defined in this workflow. All sensitive data is managed through n8n's credential system:
- OpenRouter API credentials
- PromptLayer API key
- Telegram Bot token
- Airtable API token
- Google AI API key
Data Flow¶
Input¶
- User Message: Text message from Telegram user
- User Context: Telegram user ID and chat information
- Prompt Template: Latest production prompt from PromptLayer
Processing¶
- Message Analysis: AI agent processes user intent
- Database Query: Searches Airtable for relevant projects based on term/grade/subject
- Context Integration: Combines current message with conversation history
- Response Generation: AI creates contextual response
Output¶
- Bot Response: Formatted message sent back to user
- Interaction Log: Complete conversation logged to PromptLayer with metadata
Error Handling¶
- Support Bot Node: Configured with retry on failure (2-second wait between attempts)
- Memory Management: Uses session-based memory tied to chat ID to prevent cross-user contamination
- API Resilience: Multiple external service dependencies may require additional error handling
Known Limitations¶
- Memory Window: Only retains 1 previous message, limiting conversation context
- Single Model: Relies solely on Google Gemini 2.5 Flash Lite
- Database Dependency: Project information accuracy depends on Airtable data quality
- Prompt Management: Changes to production prompts immediately affect all users
Related Workflows¶
No related workflows identified in the current context.
Setup Instructions¶
1. Import Workflow¶
- Import the workflow JSON into your n8n instance
- Ensure all required node types are available
2. Configure Credentials¶
Create the following credentials in n8n:
OpenRouter API - Name: "OpenRouter Org" - Add your OpenRouter API key
Telegram Bot API - Name: "PBA PL Demo" - Create bot via @BotFather on Telegram - Add bot token
Airtable API - Name: "pba" - Add Airtable personal access token - Ensure access to base "appntXVw3V83JQuiW"
Google Palm API - Name: "Waringa Voice" - Add Google AI API key
3. Set Up PromptLayer¶
- Create account at PromptLayer
- Create prompt template named "pbapldemo"
- Tag desired prompt version with "prod" label
- Update API key in HTTP Request nodes
4. Configure Airtable Database¶
Ensure your Airtable base contains:
- Base ID: appntXVw3V83JQuiW
- Table: "PBA Projects' Title and Description"
- Required fields: Term, Grade, Subject, project titles and descriptions
5. Test and Activate¶
- Test the workflow with sample messages
- Verify all external service connections
- Activate the workflow to enable the Telegram trigger
6. Webhook Configuration (Optional)¶
If using the webhook node, configure the endpoint path and update any calling systems to use the generated webhook URL.