AI Assistant Agent: Chat Flow¶
This workflow provides a multi-modal AI assistant system that routes users to specialized AI agents based on their selected topic. It handles session management, supports both text and voice responses, and integrates with TextIt for messaging across WhatsApp and Telegram platforms.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
How It Works¶
- Session Initialization: When a user first interacts, they select from available AI assistant options (Finance & Budget Codes, Programs, SEED Bootcamp, etc.)
- Session Validation: The system validates the user's selection and creates a session record in the database
- Message Processing: Incoming messages are routed to the appropriate AI assistant based on the established session
- AI Response Generation: Specialized assistants (OpenAI GPT models) generate responses, with some supporting voice output
- Response Delivery: Messages are sent back through TextIt to the user's preferred platform (WhatsApp/Telegram)
- Session Management: The system tracks conversation state and handles session cleanup
Workflow Diagram¶
graph TD
A[Textit Init Webhook] --> B[Available Options]
B --> C[Validate Option]
C --> D[Create Session]
C --> E[Wrong Selection]
E --> F[Send Error Message]
D --> G[Success Response]
H[Textit Webhook] --> I[Contains message?]
I --> J[Get Session Info]
J --> K[If whatsapp and SEED]
K --> L[If no session]
L --> M[Session Routing]
M --> N[Financial Codes Assistant]
M --> O[Programs Assistant]
M --> P[SEED Bootcamp Assistant]
M --> Q[SkillUp Handbook Assistant]
M --> R[SkillUp Protocols Assistant]
M --> S[AI Trainer]
N --> T[Response]
O --> T
P --> T
Q --> T
R --> T
S --> U[Response1]
U --> V[Split Out]
V --> W[Edit Fields2]
W --> T
T --> X[If Audio]
X --> Y[Voice ID1]
Y --> Z[Generate voice 11labs1]
Z --> AA[Media Upload]
AA --> BB[Edit Fields1]
BB --> CC[Send Message]
X --> DD[Edit Fields]
DD --> CC
CC --> EE[Output1]
Trigger¶
The workflow is triggered by two webhook endpoints:
- Textit Init: /webhook/b156b269-b5cd-4035-af14-99b6210c955b/init - Handles initial session setup
- Textit Webhook: /webhook/b156b269-b5cd-4035-af14-99b6210c955b - Processes ongoing chat messages
Nodes Used¶
| Node Type | Purpose |
|---|---|
| Webhook | Receives incoming messages from TextIt platform |
| Set | Data transformation and field mapping |
| If | Conditional logic for routing and validation |
| Switch | Routes users to different AI assistants based on session intent |
| Postgres | Database operations for session management and budget code lookups |
| OpenAI Assistant | Specialized AI agents for different topics |
| LangChain Agent | Custom AI agent with tools for financial codes |
| HTTP Request | Sends messages back to TextIt and handles voice generation |
| AI Transform | Processes and formats AI responses |
| Split Out | Handles multiple response messages from AI Trainer |
| Respond to Webhook | Sends responses back to webhook callers |
External Services & Credentials Required¶
- OpenAI API: For AI assistant responses and language models
- TextIt API: For message sending and media upload
- ElevenLabs API: For text-to-speech voice generation
- Supabase: Vector database for document retrieval
- PostgreSQL: Session management and budget code storage
Environment Variables¶
No specific environment variables are documented in the workflow configuration.
Data Flow¶
Input: - Webhook requests from TextIt containing user messages and metadata - Session initialization requests with topic selection
Processing: - Session validation and routing - AI assistant response generation - Optional voice synthesis - Message formatting
Output: - Text or voice responses sent via TextIt API - Session state updates in database - Webhook acknowledgments
Error Handling¶
- Invalid Session: Returns 400 error response for missing or invalid sessions
- Wrong Topic Selection: Sends error message and prompts user to select valid option
- WhatsApp SEED Restriction: Blocks SEED Bootcamp access on WhatsApp platform
- Voice Generation Failure: Continues with text-only response if voice generation fails
- Chat End Detection: Terminates sessions when users say goodbye
Known Limitations¶
- SEED Bootcamp is temporarily unavailable on WhatsApp
- Voice responses are limited to specific AI assistants
- Session cleanup occurs weekly for old sessions
- Some nodes are disabled (marked as legacy/old versions)
Related Workflows¶
No related workflows are mentioned in the current configuration.
Setup Instructions¶
- Import Workflow: Import the JSON configuration into your n8n instance
- Configure Credentials:
- Set up OpenAI API credentials for multiple assistants
- Configure TextIt API token for message sending
- Add ElevenLabs API key for voice generation
- Set up Supabase credentials for vector storage
- Configure PostgreSQL connection for session management
- Database Setup:
- Create required tables:
chat_sessions,budget_categories,budget_codes,budget_intents - Set up Supabase vector store with
documentstable
- Create required tables:
- Webhook Configuration:
- Configure TextIt to send webhooks to the provided endpoints
- Ensure webhook URLs are accessible from TextIt platform
- AI Assistant Setup:
- Configure OpenAI assistants with appropriate knowledge bases
- Set up vector embeddings for document retrieval
- Testing: Test each AI assistant route and voice generation functionality
- Monitoring: Set up error workflow monitoring (referenced as workflow ID: 9e8TMRhOpJOVa8sP)