Unstructured health data flowing into ChatGPT without governance isn't coaching—it's compliance risk. Most EU SMEs automating Garmin integration miss the operational AI implementation layer that transforms raw biometrics into defensible business decisions.
Automating Garmin Data Integration with ChatGPT Using Scheduled Data Feeds
Anyone interested in automating this?
This report details methods to automatically integrate Garmin data (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
- Navigate to Garmin Connect's Daily Summary page.
- Use browser developer tools to extract JSON data via network requests:
javascript
// 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)));
- Copy JSON output containing:
- Hourly heart rate
- Sleep stages
- Activity minutes
- Stress levels
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.
Semi-Automated Script-Based Solution
Architecture Overview
mermaid
graph TD
A[Garmin Fenix 6 Pro] -->|Sync| B(Garmin Connect)
B --> C[Python Script]
C -->|Store| D[(Local SQLite DB)]
D --> E[ChatGPT API]
E --> F[Coaching Insights]
Implementation Code
python
from garminconnect import Garmin
import sqlite3
from openai import OpenAI
import schedule
Initialize components
garmin_client = Garmin("user@example.com", "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
- Automated morning analysis
- Fallback to manual execution if needed
Full Automation with Serverless Architecture
For hands-free operation using cloud services:
AWS Lambda Implementation
yaml
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 * * ? *)
python
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
- Automatic credential rotation via AWS Secrets Manager
ChatGPT UI Integration Strategies
Method 1: Custom GPT Configuration
- Create Custom GPT in ChatGPT interface.
- Upload historical health data CSV for baseline analysis.
- Configure instructions:
- Request Garmin data via /garmin_update command
- Analyze trends against user's 30-day average
- Generate PDF workout plans
- Enable Code Interpreter for data visualization
Method 2: Plugin Development
javascript
// 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.
Security Considerations
| Aspect | Implementation |
|---|---|
| Credential Storage | AWS Secrets Manager with rotation |
| Data Transit | TLS 1.3 encryption |
| Access Control | IAM role-based permissions |
| Audit Logging | CloudTrail monitoring |
| Rate Limiting | 5 requests/minute queue |
Recommended Implementation Path
-
Initial Phase
- Manual data exports with template prompts
- Local Python script for daily analysis
-
Intermediate Phase
- AWS Lambda scheduled daily fetch
- SMS delivery via SNS
-
Advanced Phase
- Custom GPT with persistent memory
- Auto-sync browser extension
This phased approach balances complexity with immediate usability while building toward full automation.
Troubleshooting Common Issues
Authentication Failures
- Implement OAuth 2.0 refresh tokens
- Use headless browser authentication flow
python
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:
python
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.
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.
Written by Dr Hernani Costa | Powered by Core Ventures
Originally published at First AI Movers
Technology is easy. Mapping it to P&L is hard. At First AI Movers, we don't just write code; we architect the operational AI implementation layer that transforms health data into defensible business decisions for EU SMEs.
Is your workflow automation creating technical debt or business equity?
👉 Get your AI Readiness Assessment (Free Company Audit)
Assess your AI governance, workflow automation design, and operational AI implementation readiness in 20 minutes.
Top comments (0)