Skip to main content

Automating Garmin Data Integration with ChatGPT Using Scheduled Data Feeds

Updated 5 min readMarkdown
Automating Garmin Data Integration with ChatGPT Using Scheduled Data Feeds

Automating Garmin Data Integration with ChatGPT Using Scheduled Data Feeds

TL;DR: Learn how to automate Garmin data integration with ChatGPT using scheduled feeds. This guide covers manual, semi-automated, and serverless methods.

This report details methods to automatically integrate Garmin data into a ChatGPT-based personal coaching assistant using OpenAI's GPT-4o model, exploring manual, semi-automated, and fully automated approaches.

This report details methods for automated Garmin data integration (e.g., Fenix 6 Pro) into a ChatGPT-based personal coaching assistant using OpenAI's GPT-4o model. We explore both manual and fully automated approaches while addressing security, reliability, and usability considerations.

Manual Data Transfer Workflow

For users preferring direct control, this method uses Garmin Connect's export functionality with manual ChatGPT interactions:

Step 1: Daily Data Export from Garmin Connect

  1. Navigate to Garmin Connect's Daily Summary page.
  2. Use browser developer tools to extract JSON data via network requests:
// Console command to fetch yesterday's data
fetch(`https://connect.garmin.com/modern/proxy/wellness-service/wellness/dailySummaryChart/${username}?date=${getYesterdayDate()}`)
.then(response => response.json())
.then(data => console.log(JSON.stringify(data)));
  1. Copy JSON output containing:
    • Hourly heart rate.
    • Sleep stages.
    • Activity minutes.
    • Stress levels read read

Step 2: ChatGPT Interaction Template

Paste structured prompts into ChatGPT:

/coach Today's Health Data:
- Resting HR: 52 bpm ▲2% from baseline
- Sleep: 6h24m (Deep: 1h12m, REM: 1h48m)
- Steps: 8,432 (76% of goal)
- Stress Avg: 42 (Moderate)
[Paste full JSON here]
Generate recovery recommendations.

This approach maintains user control but requires daily manual effort read read.

Semi-Automated Script-Based Solution

Architecture Overview

Implementation Code

from garminconnect import Garmin
import sqlite3
from openai import OpenAI
import schedule

# Initialize components
garmin_client = Garmin("[email protected]", "password")
openai_client = OpenAI(api_key="sk-...")
db_conn = sqlite3.connect('health_data.db')

def daily_fetch():
. # Get yesterday's data
. data = garmin_client.get_wellness_data(datetime.date.today() - datetime.timedelta(days=1))
. 
. # Store locally
. cursor = db_conn.cursor()
. cursor.execute('''
. INSERT INTO daily_metrics
. (date, steps, avg_hr, sleep_duration)
. VALUES (?,?,?,?)
. ''', (data['date'], data['steps'], data['heart_rate'], data['sleep']))
.
. # Generate summary
. response = openai_client.chat.completions.create(
. model="gpt-4o",
. tools=[health_analysis_tool],
. messages=[{"role": "user", "content": f"Analyze: {data}"}]
. )
. print(response.choices[0].message.content)

# Schedule daily 6AM execution.
schedule.every().day.at("06:00").do(daily_fetch)

while True:
. schedule.run_pending()
. time.sleep(60)

Key Features:

  • Local data storage for privacy read
  • Automated morning analysis.
  • Fallback to manual execution if needed read

Full Automation for Garmin Data Integration with Serverless Architecture

For hands-free operation using cloud services, a robust AI Architecture is essential.

AWS Lambda Implementation

Resources:
. DailyGarminLambda:
. Type: AWS::Serverless::Function
. Properties:
. Runtime: python3.9
. Handler: index.handler
. Policies:
. - SecretsManagerReadWrite
. Environment:
. Variables:
. GARMIN_USER: !Ref GarminUserSecret
. OPENAI_KEY: !Ref OpenAIKeySecret
. CodeUri: ./src/
. Events:
. DailySchedule:
. Type: Schedule
. Properties:
. Schedule: cron(0 12 * * ? *)
# src/index.py
def handler(event, context):
. client = Garmin(os.environ['GARMIN_USER'], get_secret('GARMIN_PASS'))
. data = client.get_daily_summary()
.
. prompt = f"""
. As a coaching assistant, analyze this daily data:
. {json.dumps(data)}
. Highlight 3 improvement areas and suggest tomorrow's workout.
. """
.
. openai_response = openai.ChatCompletion.create(
. model="gpt-4o",
. messages=[{"role": "user", "content": prompt}]
. )
.
. send_sms(os.environ['USER_PHONE'], openai_response.choices[0].message.content)

Advantages:

  • Zero manual intervention.
  • SMS/email delivery of insights read
  • Automatic credential rotation via AWS Secrets Manager.

ChatGPT UI Integration Strategies

Method 1: Custom GPT Configuration

  1. Create Custom GPT in ChatGPT interface.
  2. Upload historical health data CSV for baseline analysis.
  3. Configure instructions:
- Request Garmin data via /garmin_update command
- Analyze trends against user's 30-day average
- Generate PDF workout plans
  1. Enable Code Interpreter for data visualization read

Method 2: Plugin Development

// chrome-extension/content-script.js
document.addEventListener('garminData', (e) => {
. const chatInput = document.querySelector('textarea');
. chatInput.value = `/analyze_garmin ${JSON.stringify(e.detail)}`;
. chatInput.dispatchEvent(new Event('input'));
});

This browser extension auto-injects Garmin data into ChatGPT's input when users visit Garmin Connect read.

Security Considerations

Addressing credential storage and access control is a core part of any AI Governance & Risk Advisory.

AspectImplementation
Credential StorageAWS Secrets Manager with rotation read
Data TransitTLS 1.3 encryption.
Access ControlIAM role-based permissions.
Audit LoggingCloudTrail monitoring.
Rate Limiting5 requests/minute queue.
  1. Initial Phase
    • Manual data exports with template prompts.
    • Local Python script for daily analysis read read
  2. Intermediate Phase
    • AWS Lambda scheduled daily fetch.
    • SMS delivery via SNS.
  3. Advanced Phase
    • Custom GPT with persistent memory.
    • Auto-sync browser extension.

This phased approach, often guided by an initial AI Readiness Assessment, balances complexity with immediate usability while building toward full automation read read.

Troubleshooting Common Issues

Authentication Failures

  • Implement OAuth 2.0 refresh tokens.
  • Use headless browser authentication flow read
from garminconnect import (
. Garmin,
. GarminConnectAuthenticationError,
. GarminConnectConnectionError,
)
try:
. client = Garmin("user", "pass")
. client.login()
except GarminConnectAuthenticationError:
. # Handle 2FA
. client.login_2fa()

Data Formatting

Convert Garmin's nested JSON to flattened CSV:

def flatten_json(data):
. return {
. 'date': data['calendarDate'],
. 'steps': data['steps'],
. 'sleep_score': data['sleep']['sleepScore'],
. 'stress_avg': data['stress']['avgStressLevel']
. }

Model Context Limits

Implement summarization pipeline:

Raw Data → Daily Summary → Weekly Trends → Monthly Report

Chunking strategy maintains context while providing granular insights read.

This integration enables real-time health coaching through automated data synthesis. By combining Garmin's detailed biometrics with GPT-4o's analytical capabilities, users receive personalized guidance while maintaining full control over their data flow.

Further Reading


Written by Dr Hernani Costa, Founder and CEO of First AI Movers. Providing AI Strategy & Execution for Tech Leaders since 2016.

Subscribe to First AI Movers for practical and measurable business strategies for Business Leaders. First AI Movers is part of Core Ventures.

Ready to increase your business revenue? Book a call today!

3 views

About the author

  • PhD in Computational Linguistics. I build the operating systems for responsible AI. Founder of First AI Movers, helping companies move from "experimentation" to "governance and scale." Writing about the intersection of code, policy (EU AI Act), and automation.

No comments yet. Be the first to comment.

More from this blog