Automate Your Training Uploads with a Python Script

Hi everyone!

I’ve created a Python script to automate uploading training schedules created by ChatGPT to your Intervals.icu calendar. It reads a trainings.json file with your planned workouts and sends them directly to the calendar using the API. This works for cycling, running, and swimming workouts with detailed steps like intervals, durations, and power zones.

Why Automate?

  • Saves time compared to manual entry.
  • Ensures consistency in formatting.
  • Easily adaptable for different training schedules.

You can find the script, detailed instructions, and examples on GitHub:

Let me know if it helps or if you have suggestions for improvements!

9 Likes

Thanks I’ll have a play. From my first attempt with ChatGPT the JSON file workouts are not fully correct so might need some model training. But then I asked him to create me a python script to send the data to Intervals.icu and it has given me a basic script.

You can put the template json from the repo in the promt and ask to use the same schema.
I also provided this blog posts (APPS in EXCEL - a guide to getting started & Using IA/ChatGPT to write intervals.icu workouts) to give him some information about how to build the trainings.

Thanks. It was easy to convert and upload a FIT file as an activity.

I can send you a copy if you want to add it to your github archive.

1 Like

UPDATE: I made a custom GPT that you can use to build trainingplans and upload them to Interval.icu: Coach GPT for Intervals.icu
I would love the have some feedback!

1 Like

Hi Stuart, thanks for testing the script and share your feedback.
You can always send me the copy or add it with a pull request.

I conducted a test and submitted a pull request on GitHub. It appears quite promising. Would you prefer receive feedback on the forum or on GitHub? (such as duplicate, bulk handling, placing the plan within a Plan instead of directly in the calendar…) Keep up the good work!

I’m looking if there’s a video tutorial somewhere how to interact with Intervals.icu through API using Python? I have VSC on my computer and basic Python skills. I have some sample JSON files for some workouts I created using ChatGPT so my next step is to test API.

I’ve tried a little bit with different prompt parameters and it looks very promising. Thank you for your work!

1 Like

Hi Radvocaat,
Thanks for spending some time on it and for your pull request!
I think we can keep the forum for the overall discussion and on Github the more technical stuff? I know they’re way more possibilities whit the Python script and API calls, but I started this project because I’m doing my first 1/4 triathlon this year with some friends and wanted to provide them something to build a training schema. So I made it as simple as possible :slight_smile:

1 Like

I don’t have any video tutorial, but there’s a guideline on the Github repo. You can find any step you need to achive the upload of the events.
Let me know if anything isn’t clear!

1 Like

Thanks for creating the script! Been trying it out and it seems that it doesn’t accept distances (km or mi) and that there’s no option for repetitions (e.g. “6x”). It also gave me an error when submitting a duration with hours. Are these features that could be added?

Hi, indeed the script is pretty short and simple, but normally works well with the output from the ChatGPT coach. You can also ask the GPT to change hours to minutes and write-out the repetitions? The distances need to be added to the script. Feel free to add the features true a pull request or you can suggest them in an Issue on GitHub and I’ll try to add them when I find some time.

Thanks - It definitely works well when asking ChatGPT to adapt to the current format, only mentioned some ease of use updates. Not familiar with GitHub, but I’ll try and submit my suggestions there.

1 Like

No problem! It works well so far. (And doing a first 1/4 triatlon with friends sounds familiar! Enjoy!

I’m having mixed results with this with a running plan. CoachGPT is outputting the json in chucks (which is expected), however when importing (using the PowerShell script) some workouts are imported as swims & others without any load. Potential bug, or is there a way to specify the workout type?

example json, the first workout imports as a swim, the second correct & the third with zero load.

{
  "trainings": [
    {
      "date": "2025-02-06",
      "name": "6k Easy + Strides",
      "steps": [
        {"duration": "6k", "zone": "Z2", "description": "Easy steady pace run"},
        {"duration": "6x20s", "zone": "Z5", "description": "Strides with 40s recovery"}
      ]
    },
    {
      "date": "2025-02-08",
      "name": "6k Tempo Run",
      "steps": [
        {"duration": "10m", "zone": "Z2", "description": "Warm-up"},
        {"duration": "6k", "zone": "Z4", "description": "Sustained tempo pace run"},
        {"duration": "5m", "zone": "Z1", "description": "Cool-down"}
      ]
    },
    {
      "date": "2025-02-11",
      "name": "10k Easy Run",
      "steps": [
        {"duration": "10k", "zone": "Z2", "description": "Steady easy pace run"}
      ]
    }
	]
}

Yes, like this:
result = intervals.updateActivity(id,[‘type’] = ‘HighIntensityIntervalTraining’)

For instance this with HIIT type.

Hey and what about building plan like pro, I mean with power ranges? Do somebody have json example for it?

Ass mentioned in the other post, the name of the workout needs to have the type of wourkout

"type": "Ride" if "Bike" in training["name"] else "Run" if "Run" in training["name"] else "Swim",

Normaly the GPT should make the Name like: “Bike - VO2 Intervals”.

Another problem I see is that you use k instead of km, the scripts only works with km.

I need to check and debug the Powershell script. The only problem here is that I only have Linux, so need to spin up a VM for that. I asked ChatGPT to convert the Python script to Powershell :slight_smile: Just putted the latest version to Github, maybe this brings any solution.

1 Like