So.. the weather, huh?
Weather-triggered push notifications are one of my favorite campaigns I have ever done. The concept of connecting real-world elements like weather to customer communications is extremely fascinating to me because it connects two different values – what the product provides with the weather forecast, which we all use.
While working for a taxi app, I implemented push notifications that alerted users when rain was forecasted in their city within the next few hours. Though this might sound complex, it’s surprisingly straightforward to set up – let me show you how.
Important Notes Before We Begin
- This solution is designed for small to medium businesses, not enterprise-level operations like Uber, for example. It’s a free, easy to set up way to test weather-triggered campaigns to see if they have a positive outcome for your audience.
- The customer engagement platform I use in this example is Braze with its templating language Liquid. The same is achievable with almost any other platform – as I’ve covered in my previous article comparing 15 customer engagement platforms and their templating languages.
- You’ll need access to a weather API for real-time forecasts. I used OpenWeatherAPI in this example because I have experience with it, and it offers 1,000 free API calls a day. I also recommend the National Weather Service API which is completely free, but covers only the USA territory
- While the focus is put on push notifications, this approach works with any messaging channel – email, SMS, in-app messages, WhatsApp and any others.
Step-by-Step Implementation Guide
1. Select Your Weather API Endpoint
For this example, I’m going to use OpenWeatherAPI. It’s the best known weather API that has a lot of different API endpoints – some provide hourly weather forecast, come daily, some focus on air quality…
The one I selected is called 5-day forecast endpoint with 3-hour intervals. It gives a weather forecast in the selected location for the next 5 days in 3 hours increments. The API endpoint looks like this:
https://api.openweathermap.org/data/2.5/forecast?q={city name}&appid={API key}
You can see we’ll need two variables:
- City name – which we’ll use for simplicity. Though you can use more precise geolocation options like ZIP codes or latitude and longitude coordinates.
- API key – which you can obtain by creating a free OpenWather account and navigating to “my API keys” in your profile.
2. Configure Braze Canvas Settings
As mentioned before, this will work with any customer engagement platform that is able to fetch data from an external API – I’m using Braze as an example.
I’ve set some rules for this push notification campaign which I’m going to use to configure the flow:
- Audience requirement: Users must have a city specified in their profile.
- Sending frequency: One notification per day per user.
- I don’t want to send multiple of the notification to the same user if it’s raining the whole day.
- I don’t want to send multiple of the notification to the same user if it’s raining the whole day.
- Send schedule: Recurring, every 3 hours.
- The API gives forecasts in 3 hour intervals, so we need to check if the forecast has changed and send the push if rain is detected.
These are mandatory, but you can add additional audience filters and change the other flow settings.
3. Fetch The Weather Forecast for the Push Notification
First, we’re gonna use Liquid to make a request to OpenWeatherAPI. We’re gonna need the API key which we issued earlier, and the user’s city that we’re gonna pull from each user’s profile.
{% assign api_key = "your_api_key_here" %}
{% connected_content
https://api.openweathermap.org/data/2.5/forecast?q={{${city}}}&appid={{api_key}}
:method get
:headers {
"Content-Type": "application/json"
}
:cache_max_age 9000
:save weather_data
%}
Note the :cache_max_age 9000 setting – it ensures we cache the responses for 9,000 seconds (2.5 hours), so when multiple users live in the same city, we don’t have to make a new request and spend API tokens for each.
Now we have the weather forecast saved in a “weather_data” variable in a JSON format.
In this JSON, we are only interested in the first item for the key “list” – it represents the weather forecast for the next 3 hours.
Using liquid, we want to check if the weather ID is between 500 and 600 – numbers that represent various rain intensity levels on OpenWeatherAPI. If that is true, it will generate the copy for the push, but if the forecast is not rain – it will abort sending the message.
{% if weather_data.list[0].weather[0].id >>= 500 and weather_data.list[0].weather[0].id < 600 %}
{{weather_data.list[0].weather[0].description | capitalize}} expected in {{city}} soon.
{% else %}
{% abort_message() %}
{% endif %}
4. And we’re done!
Literally 10 lines of code later, we have a super-personalized weather-triggered push notification!
Applications Across Industries
It’s not only taxi apps that can benefit from weather triggered-campaigns, there is also a plethora of other industries:
- Transportation: Bike-sharing and food delivery services can alert users about adverse weather conditions
- Outdoor Recreation: Apps can send safety alerts and activity recommendations.
- Retail: Promote weather-appropriate products (rainwear during wet seasons, storm supplies before severe weather).
- Events and Tourism: Notify customers about weather-related schedule changes or indoor alternatives.
- Home Services: Help lawn care and snow removal companies coordinate operations.
The Conclusion
The power of weather-triggered notifications extends beyond this specific implementation. Any real-world data source can be integrated into your marketing campaigns using a similar approach – you just need to identify an appropriate API and connect it to your customer engagement platform.
The key is starting with this simple implementation to prove the concept’s value for your business before investing in more complex solutions. By connecting real-world triggers to user communications, you can create highly relevant, personalized experiences that genuinely benefit your users while driving engagement with your service.