Meet TherapyRobo
Chat with the AI assistant that handles FAQ questions with empathy, books appointments through natural language, and guides clients through intake, all with emotionally intelligent responses.
Empathetic RAG
Semantic FAQ matching via text-embedding-004, intent matters more than exact wording, grounded in verified clinic data
Crisis Detection
Real-time distress flagging surfaces 988 Lifeline resources, zero missed flags in testing across acute scenarios
Smart Booking
Natural language intake extracts client details into structured JSON for direct CRM and EHR integration
Few-Shot Tone
Emotionally intelligent prompting validates feelings, normalizes therapy-seeking, and uses stigma-reducing language
Multi-Layer Gen AI Pipeline
From user input to empathetic response, five interconnected layers working in harmony.
User Input
Client message received via chat interface
Agent, Intent Detection
Routes to FAQ, Booking, Intake, or Conversation handler
Embeddings + RAG Retrieval
text-embedding-004 converts query to vector, cosine similarity finds closest FAQ match, HuggingFace dataset deepens conversational quality
Few-Shot Prompting + Generation
Gemini 2.0 Flash generates response with emotional tone trained from few-shot examples, validates feelings, normalizes therapy
Structured Output + Crisis Check
Extracts booking/intake data into JSON for CRM integration. Crisis detection flags distress keywords and surfaces 988 Lifeline.
Build Your Own TherapyRobo
Customize the AI assistant's knowledge base, choose your LLM backbone, and fine-tune the personality, all from one control panel.
Upload Dataset
Feed your clinic's FAQ, intake forms, and counseling corpus to train the RAG pipeline with domain-specific knowledge.
Choose LLM
Select the foundation model that powers your assistant, from Gemini to open-source alternatives, and configure inference parameters.
Configure Personality
Define the emotional tone, few-shot examples, crisis protocols, and conversation style that shape every client interaction.
Explore the Full Project
Dive into the source code, watch the walkthrough, or try the interactive version on Kaggle.
Kaggle Notebook
Full end-to-end notebook with embeddings, RAG, and agent pipeline
Interactive Version
Chat with TherapyRobo live, the input-enabled Kaggle notebook
YouTube Walkthrough
Video overview of the architecture, design decisions, and live demo
Project Weblog
Detailed write-up with research notes and implementation journal
Key Code from the Notebook
Explore the core building blocks, embeddings, RAG retrieval, few-shot prompting, structured output, and the agent orchestrator.
def get_google_embedding(text):
response = client.models.embed_content(
model="models/text-embedding-004",
contents=text,
config=types.EmbedContentConfig(
task_type="retrieval_document"
)
)
return response.embeddings[0].values
# Generate embeddings for all FAQ questions
questions = [item['question'] for item in faq_data]
question_embeddings = [
get_google_embedding(q) for q in questions
]
from sklearn.metrics.pairwise import cosine_similarity
def get_faq_item(user_query, top_k=1):
query_embedding = get_google_embedding(user_query)
similarities = cosine_similarity(
np.array(query_embedding).reshape(1, -1),
np.array(question_embeddings)
)[0]
top_indices = similarities.argsort()[::-1][:top_k]
return [faq_data[i]['answer'] for i in top_indices]
# Example usage
user_input = "I want to try a session"
response = get_faq_item(user_input)[0]
few_shot_prompt = [
{"user": "I'm nervous about starting therapy.",
"bot": "That's completely understandable. Many people
feel that way. Would you like to know what
to expect in your first session?"},
{"user": "I've never talked to anyone about this.",
"bot": "Thank you for trusting us. You've taken a
brave first step. We're here to support you."},
]
def few_shot(user_message):
prompt = """You are TherapyRobo, a supportive,
emotionally intelligent virtual assistant.
Your tone: kind, validating, never robotic."""
for ex in few_shot_prompt:
prompt += f"User: {ex['user']}\nBot: {ex['bot']}\n"
prompt += f"User: {user_message}\nTherapyRobo:"
return prompt
booking_prompt = f"""You are a Therapy centre assistant.
Extract from the client's message:
- client_name
- phone_number
- email
- therapist_name
- day
- time
Return a JSON object.
Client: "{client_request}" """
response = client.models.generate_content(
model="gemini-2.0-flash",
contents=booking_prompt,
config=types.GenerateContentConfig(
temperature=0.1,
max_output_tokens=256
)
)
booking_data = json.loads(convert_json(response.text))
def agent_detect(user_input):
"""Route to the right handler based on intent"""
category = classify_intent(user_input)
if "faq" in category:
prompt = few_shot(user_input)
answer = gemini_faq_handler(prompt)
return answer
elif "booking" in category:
booking_info = collect_user_info(fields)
result = gemini_booking_handler(booking_info)
return result
elif "document" in category:
intake, conversation = collect_intake_info()
return intake
# Fallback: RAG-powered conversation
return generate_rag_response(user_input)
Hi there! I'm TherapyRobo, your clinic's virtual assistant. I can help you with questions, booking appointments, or just chat. How can I support you today?
The Challenge
Mental health clinics lose potential clients before they ever speak to a therapist. Nearly 60% of people who consider therapy never follow through, often because the intake process feels cold, confusing, or overwhelming. Small practices rely on phone lines and PDF forms that treat vulnerable people like billing inquiries. Every friction point is an exit point - and in mental health, that exit means someone does not get help.
The Approach
I built a multi-layer Gen AI pipeline using Google Gemini. The retrieval layer uses text-embedding-004 to semantically match user queries against the clinic FAQ dataset, so intent matters more than exact wording. This feeds a RAG pipeline that grounds every response in verified clinic data, eliminating hallucination risk in a healthcare-adjacent context. Few-shot prompting trains the emotional tone - the assistant validates feelings, normalizes therapy-seeking, and uses stigma-reducing language. For structured tasks, prompt-based extraction pulls client details from natural language into JSON for direct CRM and EHR integration. The Hugging Face mental_health_counseling_conversations dataset deepens conversational quality. A crisis detection layer flags acute distress and immediately surfaces resources like the 988 Lifeline.