Note: This document describes the intensity adjustment feature implementation. It serves as both implementation documentation and feature reference.
This document describes the intensity adjustment feature that allows users to control the frequency and intensity of their daily habit prompts through a poll-based interaction system.
- Added
Intensityfield toUserProfilestruct ininternal/flow/profile_save_tool.go - Default intensity:
"normal" - Backward compatibility: Existing profiles without intensity field automatically get set to
"normal" - The intensity value is exposed to all LLMs through the profile, allowing them to adjust prompt messaging accordingly
The intensity parameter supports three levels:
- low: Reduced frequency/intensity of prompts
- normal: Default frequency/intensity (default for all users)
- high: Increased frequency/intensity of prompts
The poll options are intelligently presented based on the user's current intensity level:
| Current Intensity | Available Options |
|---|---|
| low | "Keep current", "Increase" |
| normal | "Decrease", "Keep current", "Increase" |
| high | "Decrease", "Keep current" |
This prevents users from selecting options that would exceed the boundaries (e.g., can't decrease from "low" or increase from "high").
- The intensity adjustment poll is sent once per day, not once per prompt
- Tracking is done via
DataKeyLastIntensityPromptDatein the flow state - The poll is sent immediately after the daily habit prompt is sent
- If the user has already been prompted today, the poll is skipped
DataKeyLastIntensityPromptDate = "lastIntensityPromptDate"Tracks the last date the intensity poll was sent to prevent duplicate prompts on the same day.
- Added
Intensity stringfield with JSON tag"intensity" GetOrCreateUserProfile()sets defaultintensity="normal"for new and existing profiles
IntensityPollQuestion: Constant for the poll questionIntensityPollOptions: Map of intensity levels to available optionsSendIntensityAdjustmentPoll(): Sends the intensity poll with smart optionsParseIntensityPollResponse(): Parses poll responses and returns new intensity levelMockClient.SendIntensityAdjustmentPoll(): Mock implementation for testing
- Updated
promptButtonsClientinterface to includeSendIntensityAdjustmentPoll() SendIntensityAdjustmentPoll(): Wrapper method that validates recipient and delegates to client
checkAndSendIntensityAdjustment(): Checks if intensity poll should be sent today- Reads last prompt date from state
- Compares with today's date
- Gets user's current intensity from profile
- Sends poll if not already sent today
- Records today's date after sending
- Added intensity poll response detection and processing
- Parses intensity poll responses using
ParseIntensityPollResponse() - Updates user profile with new intensity level
- Logs all intensity changes for tracking
Daily Habit Prompt Sent
↓
Check Last Intensity Prompt Date
↓
Today? ────Yes──→ Skip
↓
No
↓
Get User's Current Intensity
↓
Send Intensity Poll (smart options)
↓
Record Today's Date
↓
(User responds)
↓
Parse Poll Response
↓
Calculate New Intensity
↓
Update User Profile
↓
Save Profile to State
Poll responses follow the standard format:
Q: How's the intensity? A: [selected_option]
Examples:
Q: How's the intensity? A: DecreaseQ: How's the intensity? A: Keep currentQ: How's the intensity? A: Increase
| Current | Response | New |
|---|---|---|
| low | Decrease | low |
| low | Keep | low |
| low | Increase | normal |
| normal | Decrease | low |
| normal | Keep | normal |
| normal | Increase | high |
| high | Decrease | normal |
| high | Keep | high |
| high | Increase | high |
-
intensity_test.go: Comprehensive tests for intensity parsing and options
- 11 test cases for
ParseIntensityPollResponse() - Tests for all three intensity levels
- Tests for boundary conditions (can't decrease from low, can't increase from high)
- Tests for "Keep current" option at all levels
- Tests for non-intensity responses
- 11 test cases for
-
scheduler_tool_test.go: Updated tests for daily prompt flow
- Tests now account for 2 messages (prompt + intensity poll)
- Reminder flow tests updated to expect 3 messages total
-
whatsapp_service_test.go: Messaging service tests pass
- Mock client implements
SendIntensityAdjustmentPoll()
- Mock client implements
# All tests
go test ./...
# Intensity-specific tests
go test ./internal/whatsapp/... -run TestIntensity
go test ./internal/whatsapp/... -run TestParse
# Flow tests
go test ./internal/flow/...-
Intensity-Based Behavior: Currently, the intensity value is stored but not actively used to modify prompt frequency. Future enhancements could:
- Adjust the time between prompts based on intensity
- Modify the tone/urgency of messages
- Control follow-up reminder frequency
-
Analytics: Track intensity changes over time to:
- Identify user engagement patterns
- Detect when users are struggling (frequent decreases)
- Celebrate progress (increases in intensity)
-
Personalization: Use intensity as a signal for:
- LLM prompt customization
- Adaptive scheduling (more/fewer prompts)
- Recommendation of habit difficulty levels
- Prevents user fatigue from excessive polling
- Aligns with the daily habit tracking cycle
- Gives users time to experience their current intensity level before adjusting
- Reduces cognitive load by not showing impossible options
- Prevents confusion from selecting unavailable choices
- Creates a cleaner, more intuitive user experience
- The intensity value is passed to LLMs through the profile
- LLMs can naturally incorporate intensity into their messaging
- Keeps the system flexible and adaptable
- Avoids hardcoded intensity-based logic in prompts
The intensity adjustment feature provides a user-friendly way to control prompt frequency through poll-based interaction. It's fully integrated with the existing profile system, properly tested, and designed for future extensibility.