Weather API

Contextual Location Partner

Overview

WeatherAPI provides real-time and forecasted weather data for any global location. By integrating WeatherAPI with CleverTap, you can:

  • Trigger contextual campaigns based on local weather
  • Deliver personalized messages such as umbrella offers on rainy days or sunscreen promos on sunny days
  • Drive higher engagement through dynamic targeting powered by weather conditions

This document shows you how to configure WeatherAPI in CleverTap using Linked Content and use it in a Push Notification campaign.

Prerequisites for Integration

Before integrating WeatherAPI with CleverTap, check the following:

  • An active WeatherAPI account
  • Your WeatherAPI Key (from the WeatherAPI dashboard)
  • Access to the CleverTap Dashboard with admin permissions

Integrate WeatherAPI with CleverTap

The integration involves the following three important steps:

  1. Generate WeatherAPI Key
  2. Configure Linked Content in CleverTap
  3. Configure Personalized CleverTap Campaign

Generate WeatherAPI Key

An API key is required to authenticate requests to WeatherAPI. To retrieve the key, perform the following steps:

  1. Log in to your WeatherAPI dashboard.
  2. Go to My Account > API Key.
  3. Copy the key. Youโ€™ll use this to configure Linked Content in CleverTap.
Weather API Key

Weather API Key

Configure Linked Content in CleverTap

Connect WeatherAPI with CleverTap to fetch weather data dynamically for each user.

  1. Go to Settings > Setup > Linked Content on the CleverTap dashboard.
  2. Click + Linked Content.
  3. Fill in the following values:
FieldValue
NameWeather Lookup
MethodGET
Destination URLhttps://api.weatherapi.com/v1/current.json?key=<API_KEY>&q={{city}}

Replace <API_KEY> with your actual WeatherAPI key. The {{city}} parameter will be dynamically mapped from each user's profile property.

  1. Click Test to preview the API response. You should see an output in JSON, such as:
{
  "location": {
    "name": "Paris",
    "country": "France"
  },
  "current": {
    "condition": {
      "text": "Sunny"
    },
    "temp_c": 25.0
  }
}
  1. Click Autofill Objects with Response to map the JSON fields.
  2. Click Test and Save to complete the setup.
Configure Linked Content in CleverTap

Configure Linked Content in CleverTap

Configure Personalized CleverTap Campaign

Use the configured Linked Content inside a push notification campaign to dynamically personalize the message based on each userโ€™s local weather. To do so, perform the following steps:

  1. Go to Campaigns, click + Campaign and select Push Notifications as a messaging channel.
  2. Configure the Who, When, and Where sections based on qualifying requirements.
  3. In the What section, click Personalization (top-right corner).
  4. Select the link content configured in the previous step Configure Linked Content in CleverTap.
  5. Map the city parameter in the Weather API to the appropriate user property in CleverTap (for example, {{@Profile.city | default: 'Mumbai'}}). and click Apply.
Personalization Setup

Personalization Setup

  1. Personalize the Title or Message field using a Liquid snippet. Following is an example where the conditions defined in the Liquid snippet use the weather API to determine which message to send based on the current weather at the user's location.
{% if Linked.WeatherLookup.current.condition.text == "Sunny" %}
๐ŸŒž Get 15% off on Sunscreens!
{% elsif Linked.WeatherLookup.current.condition.text == "Rain" %}
๐ŸŒง๏ธ Special deal on Umbrellas just for you!
{% else %}
๐ŸŒค๏ธ Enjoy shopping with us today!
{% endif %}

Messages can be customized further for weather types such as Cloudy, Storm, and so on. To learn more about Liquid syntax and available personalization tags, refer to Liquid Tags in CleverTap.

  1. Click Preview and Test to validate output against a test profile.

The following is a personalized notification sample based on the userโ€™s local weather data, fetched dynamically using WeatherAPI.

Push Notification

Push Notification

  1. After confirming accurate rendering, click Publish to launch the campaign.

Once live, the campaign will automatically personalize notifications based on each userโ€™s real-time weather data.