Send an e-mail using Google Sheets? Yes, that’s right! Sheets can execute a lot even more than add numbers and calculate your mortgage payments. In our last post, we learned just how to consume JSON internet information making use of Google Sheets and also we developed templates to display screen and kind weather foreactors data. Today, we’ll construct on what we extended last time and also learn just how to send email using Google Sheets based on the JSON data we retrieve.

You are watching: Okay google do i need an umbrella today

Let’s acquire helpful and also develop somepoint helpful while we’re at it. Have you ever discovered yourself exterior somewhere and it starts to rain and also you realize you foracquired your umbrella? This has actually absolutely taken place to me! We have been experiencing drought problems in Southern The golden state for the last few years, and so I don’t always think around bringing an umbrella because rain is somewhat inconstant. (Thanktotally, I’m hearing rain external my home window ideal currently and we are receiving a lot more rain this year which is great!) Let’s usage Google Sheets to improve our situational awareness by retrieving the weather forecast for the day and sending us an e-mail prior to we leave in the morning if we need to bring an umbrella. Let’s get started!

Message Contents

Foreactors Weather API Overview

We will certainly retrieve weather forecast information utilizing the very same Web API that we made use of in our last short article. The data will be yielded in JSON format and also provide us via the weather foreactors for the next 5 days. As a review, the foreactors API accepts two parameters:

loc: location (example: San Diego, CA)deg: degree kind (F or C) Default is F.

Example: Rerevolve a JSON object through five day weather forecast information (deg F) Diego,CA°=FThis will certainly return a JSON object via the adhering to structure:

Create tradition attribute to recognize if rain likely

We’ll initially create a tradition function in Google Sheets to identify if rain is probable this particular day. Open Google Sheets and also develop a new spreadsheet.

Next, click Tools from the food selection and also choose Script editor. Google Sheets makes use of JavaScript for developing features so let’s create some JavaScript code to repursuit information from our foreactors weather API and recognize if rain is anticipated.

See more: How To Transfer Your Soul Into A Doll, Go Into A Doll'S Body

function forecast_today_object(city, threshold) var url = "" + encodeURI(city); var response = UrlFetchApp.fetch(url); var obj = JSON.parse(response.getContentText()); // check foreactors for today"s date var day = brand-new Date(); var day = padZero(day.getDate()); var month = padZero(day.getMonth() + 1); var year = date.getFullYear(); var now = year + "-" + month + "-" + day; var todayObj = obj.filter(function(o) rerevolve === now; ); if (todayObj.length > 0) var this day = todayObj<0>; this day.precip = parseFloat(today.precip); today.rainLikely = this day.precip >= threshold; rerotate today; else rerevolve error: "No foreactors information uncovered for today" ; Our forecast_today_object function provides the built-in UrlFetchApp.fetch approach to fetch the data from our weather company. After fetching the raw JSON text, we parse it, and also query the array of objects returned to uncover the foreactors weather object for this day. We appfinish a secondary field to our this particular day object dubbed this particular day.rainLikely and also collection this to true if the possibility of rain is greater than the threshost offered in the feature parameter.

As a next action, let’s develop a Sheets attribute to stringify our this day JSON object so it can be presented in a spreadsheet. This attribute will certainly not inevitably be compelled for us to send an email if rain is likely; but, it will certainly serve as a useful diagnostics tool for troubleshooting. Go ahead and also add this function too:

/** * Provide weather foreactors object for this day consisting of a "rainLikely" area worth based on "threshold" parameter * *