Automating University Schedule #1
Tags: node, googlecalendar, javascript, automation
Published: 2019-10-21 21:48:06

---
title: Automating University Schedule #1
published: true
description: How I automated my university schedule with node.js & google calendar
tags: Nodejs, google calendar, javascript, automation
cover_image: https://thepracticaldev.s3.amazonaws.com/i/jx2ycud8a2himsikcmbu.jpg
---

# Index
 - 🤔 Why?
 - 🤨 How?
   - How did I do it?
 - Code Showcase
 - Final Results
 - 🤗 Conclusion

### 🤔 Why?
Around 1 month ago I started university, and one of the things I found myself doing all the time was looking at my schedule looking for what classes I had and in what classroom it was. I found that really annoying, mostly because the only way to check it was in a online page. 😣

![schedule](https://thepracticaldev.s3.amazonaws.com/i/ttcjsotk5g0swp66zvbp.JPG)

One of the things I like to do is to automate things I do more than once. And this type of project is why I got into programming in the first place.

So, I have to use my programming skills to solve / automate this scenario which will save my screen time.

![coding](https://media.giphy.com/media/26tn33aiTi1jkl6H6/giphy.gif)


### 🤨 How?

#### How I did it?

First, I learned how to use the [Google Calendar in Node.js](https://developers.google.com/calendar/quickstart/nodejs). Then, I realized that I had to do everything because there isn't any tool already created to do what I want. So I decided to roll up my sleeves and get down to business. 💪

In this first version it was a lot more manual than I had hoped for, but it gave me a foundation that I could build upon and improve in future versions. 😤
Well, by manual I mean I had to do this steps:
 - Open google chrome developer console
 - Navigate into the schedule page
 - Login with my credentials
 - Check the network (in the console) for the response that contained the schedule .json
 - Save that file to my desktop
 - Run my application

And after all that is done I have my schedule in my calendar, which then synchronizes in all my devices, including my smartphone.


### Code Showcase

Here are the overall steps and gist.

 1. First I save the .json in the app folder
![jsonResponse](https://thepracticaldev.s3.amazonaws.com/i/pgtar5y5i06fg4976ns0.JPG)

 2. Then I had to authenticate into google calendar, for that I used this npm package for node.js:
{% github googleapis/google-api-nodejs-client no-readme %}

It wasn't that difficult as long as you follow the quick guide that google provides:
{% gist https://gist.github.com/StereoPT/168d5324455f91bfb3da7f3ae7083409 %}


 3. Next, I looped through all the Classes and Created a Event for each to add to Google Calendar
{% gist https://gist.github.com/StereoPT/78e4a4633ebcc18d11cf482cd1b7d572 %}
{% gist https://gist.github.com/StereoPT/556386a51672e328a29e35180c3e4000 %}


### Final Results

In this first version I had the functionality working, even though it's not really automated it does what I need to.
And this is what I got:
![Horario Helper](https://thepracticaldev.s3.amazonaws.com/i/5xb0veyotuz2kdpkj1np.JPG)

![Google Calendar](https://thepracticaldev.s3.amazonaws.com/i/cwqe3vmlp4hc8rj17m6w.JPG)

### 🤗 Conclusion

This is what technology is all about. Identify the problem and come up with a solution, even if the solution takes some versions to be good.
There are so many possibilities with the combination of the tools like GoogleApi and Node.js. And with those we can increase our productivity.

!!! Be sure to Comment 🌟 ... You guys all Rock !!!

*P.S: This is my first post. Feel free to point out any mistakes so I can improve*
*P.S^2: When I have the time I will post the second part where I really automate it*