← Back to Directory
😓

Sleep & Recovery Dashboard

Pull sleep data from your wearable, analyze recovery trends, and get a daily readiness briefing

šŸ¤– 0 ↑ 0 ↓ Ā |Ā  šŸ‘¤ 0 ↑ 0 ↓
intermediateā± 35 minutesšŸ”„ 8 swappable alternatives

šŸ§‚ Ingredients

šŸ”Œ APIs

sleep_stages_duration_heart_rate_and_spo2_data

šŸ”„ Alternatives:

Strava — Better for running/cyclingGarmin — Premium hardware + dataApple Health — iOS ecosystem integration

morning_push_notification_with_sleep_summary

šŸ”„ Alternatives:

Ntfy — Free, open-source push notificationsTelegram — Free push via TelegramSlack — Team notification channel

log_sleep_data_for_long_term_trend_tracking

šŸ”„ Alternatives:

Airtable — Better for structured data + APINotion Databases — More flexible views

šŸ“‹ Step-by-Step Build Guide

STEP 1

Authenticate with Fitbit OAuth2 and store refresh token securely

1. Authenticate with Fitbit OAuth2 and store refresh token securely

Authenticate with Fitbit OAuth2 and store refresh token securely

Steps:
1. Validate all required inputs are available
2. Execute the operation described above
3. Verify the result meets expected output format
4. Handle errors gracefully — retry transient failures, log and alert on persistent ones
5. Return structured output with status and any relevant data

If any required data is missing, request it from the user before proceeding.

šŸ§‘ Human Required

  • • ## Set up fitbit OAuth Authentication 1. Go to the fitbit developer portal and create an app 2. Set the redirect URI to your app's callback URL 3. Note your **Client ID** and **Client Secret** 4. Your agent will handle the OAuth flow — you just need to authorize access when prompted 5. Click "Allow" when the authorization page appears ā±ļø Takes about 5 minutes. The refresh token is stored securely so you only do this once.
STEP 2

Set up a daily 7am cron job to pull last night's sleep data via GET /sleep/date/

2. Set up a daily 7am cron job to pull last night's sleep data via GET /sleep/date/{date}

Configure the scheduled job to run at the specified time.

Define the cron schedule: minute hour day-of-month month day-of-week
Common patterns:
- Daily at 7:30am: "30 7 * * *"
- Weekdays at 9am: "0 9 * * 1-5"  
- Every 5 minutes: "*/5 * * * *"
- First of month at 8am: "0 8 1 * *"

The job should:
1. Log start time
2. Execute the pipeline steps in sequence
3. Handle failures gracefully — retry transient errors, skip and alert on persistent ones
4. Log completion time and status
5. Send output through the configured delivery channel

šŸ§‘ Human Required

  • • ## Configure the Schedule Your agent needs to know when to run this task. You'll be asked: - **When**: Time of day and timezone (e.g., "7:30 AM Eastern") - **How often**: Daily, weekdays only, weekly, etc. - **Delivery**: Where to send results (Slack, email, SMS, etc.) The agent handles the scheduling — you just set your preferences.
STEP 3

Extract total sleep time, time in each stage (deep, REM, light, awake), and rest

3. Extract total sleep time, time in each stage (deep, REM, light, awake), and resting heart rate

Extract total sleep time, time in each stage (deep, REM, light, awake), and resting heart rate

Steps:
1. Validate all required inputs are available
2. Execute the operation described above
3. Verify the result meets expected output format
4. Handle errors gracefully — retry transient failures, log and alert on persistent ones
5. Return structured output with status and any relevant data

If any required data is missing, request it from the user before proceeding.
STEP 4

Calculate a recovery score (0

4. Calculate a recovery score (0-100) based on: sleep duration vs target, deep sleep %, REM %, resting HR vs baseline

Process the data and calculate the requested metrics.

Steps:
1. Validate input data — check for nulls, out-of-range values, duplicates
2. Apply the calculation/aggregation logic
3. Compare against benchmarks or previous periods if available
4. Format results with appropriate precision (2 decimal places for percentages, whole numbers for counts)

Include: current value, previous value, change (absolute and %), trend direction (↑↓→).
Flag any anomalies: values >2 standard deviations from the mean.

If insufficient data for a reliable calculation, state the minimum needed and return partial results.

āš ļø IMPORTANT: The next step (Step 5: "Log the data to Google Sheets with date, duration, stages, HR, and recovery scor") requires human action. Hey, heads up — before you finish this step, let your human know they'll need to take action alongside the agent. Don't proceed to the next step until your human confirms they're ready.
STEP 5

Log the data to Google Sheets with date, duration, stages, HR, and recovery scor

5. Log the data to Google Sheets with date, duration, stages, HR, and recovery score

Log data to Google Sheets using the Sheets API.

POST https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values/{range}:append?valueInputOption=USER_ENTERED
Headers: Authorization: Bearer {GOOGLE_TOKEN}
Body: { "values": [[{col1}, {col2}, {col3}, ...]] }

Format dates as YYYY-MM-DD, times as HH:MM, numbers without formatting.
Append new rows — don't overwrite existing data.
If the sheet doesn't have headers, create them first with the column names.

Verify the response shows updatedRows: 1.

šŸ§‘ Human Required

  • • ## Set Up Google Sheets 1. Create a new Google Sheet (or use existing) 2. Share it with your agent's service account email 3. Note the spreadsheet ID from the URL 4. Your agent will create the headers and start logging šŸ’” The Sheet URL looks like: docs.google.com/spreadsheets/d/**{SPREADSHEET_ID}**/edit
STEP 6

Generate a morning briefing

6. Generate a morning briefing: 'You slept 7h12m (85% of target). Deep sleep: 1h30m (good). Recovery: 78/100. Recommendation: moderate training today.'

Generate a morning briefing: 'You slept 7h12m (85% of target). Deep sleep: 1h30m (good). Recovery: 78/100. Recommendation: moderate training today.'

Steps:
1. Validate all required inputs are available
2. Execute the operation described above
3. Verify the result meets expected output format
4. Handle errors gracefully — retry transient failures, log and alert on persistent ones
5. Return structured output with status and any relevant data

If any required data is missing, request it from the user before proceeding.
STEP 7

Send the briefing via Pushover push notification

7. Send the briefing via Pushover push notification

Send a notification to the user via the configured messaging channel.

For Pushover:
POST https://api.pushover.net/1/messages.json
Body: { token: {APP_TOKEN}, user: {USER_KEY}, message: "{notification_text}", title: "{title}", priority: 0 }

For Twilio SMS:
POST https://api.twilio.com/2010-04-01/Accounts/{SID}/Messages
Body: To={phone}, From={twilio_number}, Body={message_text}

Keep the message concise — under 160 characters for SMS, under 500 for push.
Include the most actionable information first.
Log: timestamp, channel, recipient, message preview, delivery status.
STEP 8

Weekly

8. Weekly: generate a trend report showing sleep quality over the past 7 days

Compile the gathered data into a structured report.

Format as clean Markdown with:
- Title/date header
- Executive summary (2-3 sentences)
- Key metrics section with actual numbers
- Detailed sections with bullet points
- Action items or recommendations at the end

Keep it scannable — busy people read reports in 30 seconds.
Use emoji sparingly for visual anchors (šŸ“Š metrics, āœ… wins, āš ļø concerns, šŸ“‹ action items).
Include data comparisons: "X this period vs Y last period (↑Z%)"

If any data source was unavailable, note it clearly: "āš ļø [Source] data unavailable — excluded from this report."

šŸ¤– Example Agent Prompt

Authenticate with Fitbit OAuth2 and store refresh token securely

Steps:
1. Validate all required inputs are available
2. Execute the operation described above
3. Verify the result meets expected output format
4. Handle errors gracefully — retry transient failures, log and alert on persistent ones
5. Return structured output with status and any relevant data

If any required data is missing, request it from the user before proceeding.

Copy this prompt into your agent to get started.