Introduction
MoEngage <> Open Weather
MoEngage <> Open weather integration allows you to enrich and personalize your marketing campaigns. You can directly fetch the user location and weather updates on the fly and send personalised campaigns to your users.
For example- A typical use-case for an E-commerce industry: You want to nudge users to buy
- Sunglasses, if the weather in the user's location in sunny
- An umbrella, if there is a high likelihood of raining
Integration
library_add_check |
Prerequisites
|
Available APIs
The following are the Open Weather APIs can be used within your MoEngage campaigns:
- Current weather data
- Hourly Forecast 4 days
- One call API
- Daily Forecast 16 Days
- Climate forecast for 30 days
- 5 day weather forecast
- Road risk API
Steps
The following example shows three different types of messages based on the current weather conditions at a user’s coordinates. We will be hitting Current Weather API using MoEngage Content APIs to get the weather details
Step 1: Add content API on MoEngage
info |
Information We've revamped our dashboard settings UI. Content API is now available in Settings -> Advanced Settings -> Content API in the revamped UI. For more information, refer to Summary of Changes - Settings UI Revamp. |
-
Navigate to Settings -> Advanced Settings -> Content API. Click + Add content API at the top right corner of the Content API screen.
Navigate to Settings >> APIs >> Content API. Click Add.
- Add Current weather API details here.
API URL:
https://api.openweathermap.org/data/2.5/weather?lat={{UserAttribute['latitude']}}&lon={{UserAttribute['longitude']}}&appid=<your open weather API key>
Parameters
Your parameters will be auto-populated. Just update the values with the personalised variables. You can type "@" and select the variable.
- Click save.
- You will now see the Open weather API listed in Content APIs.
Note - You can also test your APIs by clicking on the Test button. You can your API response and validate.
Step 2: Using content APIs in MoEngage campaigns
You can now use these content APIs in your campaigns. Read here to know more about Content APIs
- On step 2 on your campaign creation, enter @.
- In the pop up, you can select the Open Weather Content API configured in Step 2.
- You can use MoEngage Templating Language to parse through the API response and define the content of your campaign based on the local weather. For example:
If local weather is Sunny => Get a sunscreen
If local weather is Rain => Get an umbrella
Sample API response
{ "coord": { "lon": -122.08, "lat": 37.39 }, "weather": [ { "id": 800, "main": "Clear", "description": "clear sky", "icon": "01d" } ], "base": "stations", "main": { "temp": 282.55, "feels_like": 281.86, "temp_min": 280.37, "temp_max": 284.26, "pressure": 1023, "humidity": 100 }, "visibility": 10000, "wind": { "speed": 1.5, "deg": 350 }, "clouds": { "all": 1 }, "dt": 1560350645, "sys": { "type": 1, "id": 5122, "message": 0.0139, "country": "US", "sunrise": 1560343627, "sunset": 1560396563 }, "timezone": -25200, "id": 420006353, "name": "Mountain View", "cod": 200 }
Rain
, the user would then receive the push message - "Its raining. Get an umbrella".