Open Weather

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 
  • Screenshot_2022-06-23_at_11.33.02_PM.png

Integration

library_add_check

Prerequisites

  • Ensure you have an Open Weather account.
  • Ensure you have access to your Open Weather API key. Contact your Open Weather account manager for compatible API key. Read more on Open Weather API here
  • Ensure that you are tracking users' co-ordinates (latitude and longitude) as user attributes on MoEngage 

Available APIs

The following are the Open Weather APIs can be used within your MoEngage campaigns:

  1. Current weather data 
  2. Hourly Forecast 4 days
  3. One call API
  4. Daily Forecast 16 Days
  5. Climate forecast for 30 days 
  6. 5 day weather forecast 
  7. 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.

  1. Revamped UI Old UI

    Navigate to Settings -> Advanced Settings -> Content API. Click + Add content API at the top right corner of the Content API screen.

    ContentAPI_Navogation.png

  2. 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.

    Screenshot_2022-06-30_at_1.04.55_PM.png

  3. Click save.
  4. You will now see the Open weather API listed in Content APIs. 
    Screenshot_2022-06-30_at_1.08.33_PM.pngNote - 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 

  1. On step 2 on your campaign creation, enter @. 
  2. In the pop up, you can select the Open Weather Content API configured in Step 2. Screenshot_2022-06-30_at_1.13.30_PM.png

  3. 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 
    JSON
    {
        "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
      }

     

    You can print the output in the template or use the Personalized Previews to preview. In the API response, if the weather description is Rain, the user would then receive the push message - "Its raining. Get an umbrella".

Previous

Next

Was this article helpful?
0 out of 0 found this helpful

How can we improve this article?