Skip to main content

Get Greeting

Retrieve a personalized greeting message based on your journaling history, current streak, and recent mood.
curl http://127.0.0.1:5000/api/greeting

Response Types

First-Time User (No Entries)

{
  "greeting": "Good morning",
  "message": "Every great journey begins with a single step. Start your journaling adventure today!",
  "has_entries": false,
  "streak": 0
}

Returning User (No Groq API)

{
  "greeting": "Good afternoon",
  "message": "You're on a 7-day streak! Don't break it - write today.",
  "has_entries": true,
  "streak": 7,
  "total_entries": 45,
  "ai_generated": false
}

AI-Powered Greeting (With Groq API)

{
  "greeting": "Good evening",
  "message": "Nice to see you back. Your 12-day streak shows real commitment, and your recent reflections on work and creativity suggest things are flowing well.",
  "has_entries": true,
  "streak": 12,
  "total_entries": 67,
  "ai_generated": true
}

Response Fields

greeting
string
required
Time-based greeting: Good morning, Good afternoon, or Good evening
message
string
required
Personalized message based on journaling context
has_entries
boolean
required
Whether the user has any journal entries
streak
number
Current journaling streak (days)
total_entries
number
Total number of journal entries (only if entries exist)
ai_generated
boolean
Whether the message was generated by AI (only if Groq API configured)

Greeting Logic

Time-Based Greeting

Based on current hour:
TimeGreeting
00:00 - 11:59Good morning
12:00 - 16:59Good afternoon
17:00 - 23:59Good evening

Message Generation

No Entries

Random motivational quote:
  • “Every great journey begins with a single step. Start your journaling adventure today!”
  • “Your thoughts matter. Take a moment to capture them.”
  • “The best time to start journaling was yesterday. The second best time is now.”
  • “Writing is thinking on paper. Begin your reflection journey today.”
  • “A journal is a friend who listens without judgment. Say hello!”

With Entries (No AI)

Context-based messages:
  • Already journaled today: “Welcome back! You’ve already journaled today. Keep the momentum going!”
  • Active streak: “You’re on a -day streak! Don’t break it - write today.”
  • No current streak: “Ready to reflect? Your journal awaits.”

With Entries (AI-Powered)

Personalized narrative considering:
  • Total entry count
  • Current streak
  • Whether you journaled today
  • Recent mood patterns (“mostly positive”, “mixed”, “reflective”)
  • Recent themes (work, health, creativity, etc.)
AI greetings are limited to 30 words and avoid excessive exclamation marks for a natural tone.

Context Sent to AI

When using Groq API, only metadata is sent, not full entry text.
Example context:
Total journal entries: 67
Current streak: 12 days
Already journaled today: no
Recent mood: mostly positive
Recent themes: work, creativity, health
See Groq API Integration for privacy details.

Use Cases

Welcome Screen

Display greeting when user opens the app:
const { greeting, message } = await fetch(
  'http://127.0.0.1:5000/api/greeting'
).then(r => r.json());

document.getElementById('greeting').textContent = greeting;
document.getElementById('message').textContent = message;

Motivation Dashboard

Combine greeting with stats:
const greeting = await fetch('http://127.0.0.1:5000/api/greeting')
  .then(r => r.json());
const stats = await fetch('http://127.0.0.1:5000/api/stats')
  .then(r => r.json());

const motivation = `
  ${greeting.greeting}! ${greeting.message}
  
  Current streak: ${stats.streak.current_streak} days
  ${stats.encouragement}
`;

Notification Content

Use for push notifications or reminders:
import requests
from datetime import datetime

greeting = requests.get('http://127.0.0.1:5000/api/greeting').json()
hour = datetime.now().hour

if hour >= 20 and not greeting.get('journaled_today', False):
    send_notification(
        title="Don't forget to journal!",
        body=greeting['message']
    )

AI vs Non-AI Examples

Without Groq API

Simple, rule-based:
{
  "greeting": "Good morning",
  "message": "You're on a 5-day streak! Don't break it - write today.",
  "has_entries": true,
  "streak": 5,
  "total_entries": 23
}

With Groq API

Contextual, personalized:
{
  "greeting": "Good morning",
  "message": "Your 5-day streak is building nicely, and I noticed your recent entries about morning walks have a particularly upbeat tone.",
  "has_entries": true,
  "streak": 5,
  "total_entries": 23,
  "ai_generated": true
}

Fallback Behavior

If AI generation fails:
{
  "greeting": "Good afternoon",
  "message": "Welcome back! You have 45 entries in your journal.",
  "has_entries": true,
  "streak": 0,
  "total_entries": 45,
  "ai_generated": false
}

Guidelines for AI Greetings

The AI is instructed to: ✅ Be warm but not overly enthusiastic
✅ Acknowledge streaks naturally
✅ Reference recent themes or moods if relevant
✅ Keep under 30 words
✅ Sound like a supportive friend
❌ Don’t use excessive exclamation marks
❌ Don’t be overly effusive or cheesy
❌ Don’t guilt-trip if they haven’t journaled

Performance

  • Local greeting (no AI): < 10ms
  • AI greeting (with Groq): 200-500ms depending on API latency
Consider caching AI greetings for a few hours to reduce API calls and improve performance.

Caching Strategy

let cachedGreeting = null;
let cacheTime = null;

async function getGreeting() {
  const now = Date.now();
  
  // Cache for 3 hours
  if (cachedGreeting && (now - cacheTime) < 3 * 60 * 60 * 1000) {
    return cachedGreeting;
  }
  
  cachedGreeting = await fetch('http://127.0.0.1:5000/api/greeting')
    .then(r => r.json());
  cacheTime = now;
  
  return cachedGreeting;
}

Next Steps

Stats API

Get streak and engagement data

Insights API

Discover patterns in journaling

Build docs developers (and LLMs) love