My wife and I like the respectful parenting philosophy called RIE, which offers a substantial amount of materials on its foundational principles, but I often have questions about handling specific situations. I built this chatbot to provide RIE-inspired advice—and to explore GPT-4. In this post, I’ll share how it works and how I tried to give AI a gentle, respectful voice. This was a quick project, done for fun, so not a lot of time or effort was invested in the user experience.
Frontend
React 18 with TypeScript
UI Framework
Tailwind
Build Tool
Vite
Backend
Netlify Functions
AI
OpenAI GPT-4
Database
Supabase
Deployment
Netlify
Chatbot implementation
The chatbot functionality is implemented through a combination of frontend state management and serverless backend functions.
Message flow
- Upon visiting the chat page, the user is greeted with a preset system message, which serves as a helpful guide and also a disclaimer.
- User enters a message in the ChatInput component.
- The message is stored in local state and persisted to localStorage.
- The message is sent to the Netlify serverless function.
- The function forwards the message to OpenAI’s API.
- The response is returned to the frontend and displayed.
- Both user messages and AI responses are stored in Supabase.
OpenAI integration
The application uses OpenAI’s GPT-4 model with these parameters:
const completion = await openai.chat.completions.create({
model: "gpt-4",
temperature: 0.5,
max_tokens: 750,
presence_penalty: 0.6,
frequency_penalty: 0.5,
messages: [
{
role: "system",
content: systemPrompt || "You are a helpful assistant.",
},
...body.messages,
],
});
These parameters are optimized for:
- Temperature (0.5): Balanced creativity and consistency.
- Max tokens (750): Concise yet informative responses.
- Presence/frequency penalties: Reduced repetition and more diverse responses.
System prompt
The chatbot’s personality and knowledge base is defined by this system prompt:
You are the Enkel Chatbot, an AI assistant specialized in the RIE (Resources for Infant Educarers) parenting philosophy.
Your purpose is to provide helpful, evidence-based information about respectful parenting practices based on the teachings of Magda Gerber and the RIE approach.
When responding to questions:
- Focus on RIE principles: respect, trust in the child's competence, sensitive observation, and allowing natural development
- Emphasize the importance of treating infants and children as whole people deserving of respect from birth
- Provide practical advice that parents can implement
- Be warm, supportive, and non-judgmental
- When appropriate, cite or reference specific RIE concepts or practices
- If asked about topics outside of parenting or child development, politely redirect to your area of expertise
- Never provide medical advice or diagnoses
- Always clarify that you are an AI assistant providing information, not a replacement for professional guidance
Remember that parenting approaches vary widely, and while you specialize in RIE philosophy, acknowledge that there are many valid approaches to raising children.
Database “architecture”
The application uses Supabase as its backend database, with a very simple schema:
create table public.messages (
id uuid default gen_random_uuid() primary key,
created_at timestamp with time zone default timezone('utc'::text, now()) not null,
role text not null check (role in ('user', 'assistant')),
content text not null,
session_id uuid not null,
parent_id uuid references public.messages(id)
);
This schema allows for:
- Unique message identification
- Timestamp tracking
- Role differentiation (user vs. assistant)
- Session grouping
- Parent-child relationships between messages
Conclusion
This parenting chatbot demonstrates how easily you can create a specialized AI chatbot. There are several enhancements that I would consider making, but my wife and I are essentially the only users (although we’ve used it a lot!).