What This Automation Does
This workflow listens for new or updated activities on Strava and sends personalized triathlon coaching feedback automatically.
It solves the problem of manual data review by quickly processing detailed running, cycling, and swimming stats.
The result is tailored advice sent by email or WhatsApp right after workouts.
The workflow captures raw Strava data, flattens it into clear text, then asks Google Gemini AI to analyze and create customized coaching.
It formats that coaching into clean HTML and sends it out.
Inputs → Processing → Output
Inputs
- Strava API: Sends activity updates for running, cycling, swimming.
- Google Gemini API: Provides AI coaching analysis based on flattened activity data.
- Gmail and WhatsApp Business Cloud: Deliver coaching feedback messages timed after activity uploads.
Processing Steps
- Trigger on Strava activity upload or change.
- Run JavaScript to flatten nested JSON data into readable lines.
- Send simplified data to the Google Gemini Fitness Coach agent.
- Parse AI response and convert to structured HTML.
- Prepare and send email with coaching content.
- Optionally send WhatsApp message with same content.
Output
Personalized coaching email and WhatsApp message with training insights and advice.
Who Should Use This Workflow
This is for triathletes tracking activities that want quick, clear coaching advice.
People who use Strava regularly and want automated feedback without extra work.
Coaches with multiple athletes can also modify it for scalable, consistent advice.
Non-technical users can set it up inside n8n with some configuration.
Tools and Services
- Strava API: Sends real-time activity updates.
- Google Gemini API: AI analyzes activity data and writes coaching feedback.
- Gmail API: Sends coaching emails automatically.
- WhatsApp Business Cloud API (optional): Sends coaching messages via chat.
- n8n Automation Platform: Runs the workflow logic and integrates APIs.
Beginner Step-by-Step: How to Use This Workflow in n8n
Download and Import
- Use the Download button on the page to get the workflow file.
- Open the n8n editor where you want to run the workflow.
- Use the Import from File option to upload the downloaded workflow.
Configure Credentials and Settings
- Enter your Strava OAuth API Key in the Strava Trigger node.
- Paste Google Gemini API credentials in the AI agent node.
- Confirm Gmail OAuth credentials for sending email.
- Optionally connect WhatsApp Business Cloud API if used.
- Update any recipient emails, WhatsApp phone numbers, or IDs to fit your use.
Test and Activate
- Run a test by uploading or updating an activity in Strava.
- Confirm the workflow triggers and emails or WhatsApp messages arrive.
- Activate the workflow toggle to run automatically.
This method lets you quickly put the workflow in production without building from zero.
For privacy and control, consider self-host n8n.
Code to Flatten Strava Activity JSON
This JavaScript runs inside a Code node to convert complex JSON into string lines for AI consumption.
// Recursive function to flatten JSON into a single string
function flattenJson(obj, prefix = '') {
let str = '';
for (const key in obj) {
if (typeof obj[key] === 'object' && obj[key] !== null) {
str += flattenJson(obj[key], `${prefix}${key}.`);
} else {
str += `${prefix}${key}: ${obj[key]}
`;
}
}
return str;
}
const data = $input.all();
let output = '';
data.forEach(item => {
output += flattenJson(item.json);
output += '\n---\n';
});
return [{ json: { data: output } }];
This helps AI clearly read important metrics without confusion.
Customizations
- Change coaching detail: Adjust prompt in Fitness Coach node to ask for brief or detailed advice.
- Switch communication: Replace Gmail node with Slack or SMS nodes.
- Add extra data points: Modify flatten code to include weather or GPS details.
- Serve many athletes: Setup database nodes to send personalized coaching to multiple users.
- Language settings: Update AI prompt for coaching in other languages if needed.
Troubleshooting Common Issues
- Trigger not firing: Check Strava webhook URLs and permissions.
- Weak AI advice: Ensure complete data is flattened and sent.
- Email fails to send: Refresh Gmail OAuth credentials.
- WhatsApp messages missing: Verify WhatsApp API tokens and quota.
- Broken HTML emails: Test HTML conversion node output before sending.
Pre-Production Checklist
- Confirm valid Strava API keys and webhook setup.
- Test Google Gemini AI responses for quality.
- Verify Gmail sending rights and OAuth tokens.
- Send test emails and WhatsApp messages.
- Check workflow auto-triggers with new Strava activities.
Deployment Guide
After testing, switch workflow to active mode in n8n.
Watch workflow logs for errors regularly.
Setup alerts for email or WhatsApp failures.
Consider self-host n8n for full workflow control.
Summary of Benefits
✓ Saves hours of manual data review weekly.
✓ Delivers personalized coaching fast.
✓ Supports multiple communication channels.
✓ Easy to configure inside n8n.
✓ Flexible for different athlete levels.
