> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fastgen.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Rain Probability App

This app will notify you each morning if rain is expected in your area and if you should bring an umbrella. It also serves as a great example on how you can retrieve information from a public API and turn it into a useful workflow for you.

<iframe width="674" height="315" src="https://www.youtube.com/embed/WRF95ZJzuvc" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen />

#### Time Frequence

The default template will execute daily in the morning. You can adjust the timing and time zone under `Condition` in the top action block.

#### HTTP Request

The HTTP action sends a request to a public API of [https://open-meteo.com](https://open-meteo.com). The default template sends a request to:

```json theme={null}
https://api.open-meteo.com/v1/forecast?latitude=40.7143&longitude=-74.006&daily=precipitation_probability_max&timezone=auto&forecast_days=1
```

In the request URL we are using latitude of `40.7143` and longitude of `-74.006` to get weather information for New York.

Visit [https://open-meteo.com/en/docs](https://open-meteo.com/en/docs) to get the coordinates for your location and just replace them in the URL.

If we make a request to that API, here's an example of output data we receive:

```json theme={null}
{
  "steps.get-rain-probability.outputs": {
    "Body": {
      "daily": {
        "precipitation_probability_max": [
          97
        ],
        "time": [
          "2023-07-21"
        ]
      },
      "daily_units": {
        "precipitation_probability_max": "%",
        "time": "iso8601"
      },
      "elevation": 51,
      "generationtime_ms": 0.18203258514404297,
      "latitude": 40.710335,
      "longitude": -73.99307,
      "timezone": "America/New_York",
      "timezone_abbreviation": "EDT",
      "utc_offset_seconds": -14400
    },
    "Header": {
      "Content-Type": "application/json; charset=utf-8",
      "Date": "Fri, 21 Jul 2023 12:00:27 GMT"
    },
    "Status": 200
  }
}
```

The data we are interested in is `precipitation_probability_max` which provides us with the highest rain probability for that specifc day. In this example the value for this is `97`, so a 97% probability for rain that day.

The following syntax let's us access that value from response:

* `{{steps.get-rain-probability.outputs.Body.daily.precipitation_probability_max.0}}`

#### Check Rain Probability

The default template uses a [Switch Condition](/actions/flow-control/switch) to check for the rain probability value and executes different alerts accordingly.

You can adjust the `75`, `50` or `30` cases to your preference. The switch condition will check the cases chronologically, so if case 1 is true it will be executed, no matter what has been defined in the following cases. You can change this to an [If Condition](/actions/flow-control/if) if you only want to be notified if rain probability exceeds a specfific value.

The [https://open-meteo.com](https://open-meteo.com) API provides a lot of flexibility and enables you to build all sorts of weather apps for you or your users!
