Skip to main content

How to Show Weather-Based Recommendations

Completion Time: 45 minutes

This guide shows you how to build a Content that switches to the right offer when the weather changes: umbrellas and indoor activities when it rains, sunscreen and outdoor tours when it is sunny, hot drinks and winter gear when it snows.

The Content does not need a Playlist or a Schedule. A Weather datasource supplies the current condition, and Datasource events on the Content jump to the matching page whenever that condition changes.

How it works​

PartWhat it does
Weather datasourceFetches the current condition for a location, as a text (Cloudy) and a code (26)
Override datasource (optional)An internal datasource with the same field, so you can change the condition by hand during a demo or a test
Datasource eventsContent-wide rules: when the condition matches X, jump to page Y
PagesOne page per offer, plus a Default page for anything else

Upsell ideas by condition:

ConditionUpsell idea
Showers, rain, cloudyUmbrellas, raincoats, indoor activities
Sunny, fairOutdoor activities, sunscreen
SnowWinter gear, hot drinks

Step 1: Create the Weather datasource​

  1. Go to Datasources and click Add external datasource.
  2. Choose the Weather type.
  3. Under Locations, click Add first location and choose Add by city (or Add by geo position for coordinates).
  4. Fill in City / Zip code and pick the Country code. Both are required. Optionally, set a Display name.
  5. Open Advanced settings > Refresh settings. Set Refresh type to Simple interval and Refresh interval (seconds) to 600–900 (10–15 minutes).
  6. Save.
Change the refresh interval

A new datasource refreshes once a day (86400 seconds) by default. With that setting, the Content can show a sunny offer all afternoon in the rain.

Refreshing more often than every 10–15 minutes does not help. Wallboard's weather service holds each location's data for up to 30 minutes before it asks the provider again. Your server may also enforce a Minimum datasource refresh time (seconds).

The current condition is in the datasource at:

query > results > channel > [location] > item > condition > text (for example "Cloudy")
query > results > channel > [location] > item > condition > code (for example "26")

channel is a list with one entry per location, in the order you added them.

Learn more: Weather datasource

Step 2: Create an override datasource for demos (optional)​

Real weather changes slowly. To show the switching live, or to test every page before go-live, create an internal datasource whose value you can change by hand:

  1. Go to Datasources and click Add internal datasource.
  2. Set Structure type to Table.
  3. Create one table with two columns and one row:
{
"Single Weather": {
"header": {
"Code": "number",
"Condition": "string"
},
"rows": [
{ "Code": 26, "Condition": "Cloudy" }
],
"connectors": {}
}
}

❓ Confirm how to paste this JSON in the new datasource editor. The old Edit JSON button exists only in the legacy editor; you can also add the table, columns and row by hand.

During the demo, you bind the Datasource events to this table instead of the Weather datasource (Step 4). For production, bind them to the Weather datasource.

Look up the codes

You can also import the full code list (Step 3) as a second table, so the codes are at hand while you set up the events.

Step 3: Decide what to match on: text or code​

Each condition comes as a text and as a code. Both work.

Match onGood forWatch out for
Text (condition > text)Demos: easy to read and to typeSpelling and capitals must match exactly when you use regular expressions (see Step 4)
Code (condition > code)Production: one number per condition, no spelling issuesYou need the code table below

Weather codes returned by the Weather datasource:

CodeTextCodeText
0Tornado24Windy
1Tropical storm25Cold
2Hurricane26Cloudy
3Severe thunderstorms27Mostly cloudy
4Thunderstorms28Mostly cloudy
5Mixed rain and snow29Partly cloudy
6Mixed rain and sleet30Partly cloudy
7Mixed snow and sleet31Clear
8Freezing drizzle32Sunny
9Drizzle33Fair
10Freezing rain34Fair
11Showers35Mixed rain and hail
12Rain36Hot
13Snow flurries37Isolated thunderstorms
14Light snow showers38Scattered thunderstorms
15Blowing snow39Scattered showers
16Snow40Heavy rain
17Hail41Scattered snow showers
18Sleet42Heavy snow
19Dust43Blizzard
20Foggy44Not available
21Haze45Scattered showers
22Smoky46Scattered snow showers
23Blustery47Scattered thundershowers
Where the codes come from

Wallboard's weather service gets its data from more than one weather provider and translates each provider's conditions into this one list. Two things follow from that:

  • Some codes never appear. Codes 1, 2, 6, 7, 8, 15, 23, 37, 38 and 41 are in the list but are not produced by any current provider. Keep them in your rules if you like; they will simply never match.
  • The same sky can get a different code. Which provider serves a location can change from one refresh to the next. For example, a lightly clouded sky can come back as 34 Fair or 30 Partly cloudy, and a clear night can come back as 32 Sunny. Group conditions generously rather than relying on one exact code.

Step 4: Add the Datasource events​

  1. Open the Content in the Content Editor and click the background, so that no Widget is selected.
  2. In the External events section, click Edit datasource events.
  3. Stay on the Content wide events tab, so the rules work from every page.
  4. Add one event per offer page. For each event:
    • Bound value: select the Weather datasource, then query > results > channel > the first location > item > condition > code (or text). For the demo, select the override datasource's Code (or Condition) column instead.
    • Evaluation type: regular expression (match), with the pattern from the table below.
    • Action: Jump to, with the target page.
  5. Add one more event for the Default page, with regular expression (no match).
  6. Click Save.

❓ Confirm how the data picker shows the channel list (the first location as 0 or by name) on a screenshot.

PageEvaluation typePattern
Rainregular expression (match)^(3|4|6|8|9|10|11|12|17|26|27|28|35|37|38|39|40|45|47)$
Snowregular expression (match)^(5|7|13|14|15|16|18|41|42|43|46)$
Sunnyregular expression (match)^(29|30|31|32|33|34|36)$
Defaultregular expression (no match)all of the codes above in one pattern

These groups are an example: the Rain page also takes cloudy skies, as in the upsell table above. Move codes between groups to fit your offers, but keep each code in one group only. If two content-wide events match the same value, both jump. ❓ Which jump wins was not checked; avoid the overlap.

The Default pattern is every code from the other three rows, so anything else (fog, wind, 44 Not available) lands on the Default page:

^(3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|45|46|47)$

Patterns by text (demos)​

PageEvaluation typePattern
Rainregular expression (match)^(Cloudy|Mostly cloudy)$|[Ss]hower|[Rr]ain|[Dd]rizzle|[Tt]hunder|Hail
Snowregular expression (match)[Ss]now|[Ss]leet|[Bb]lizzard
Sunnyregular expression (match)Sunny|Fair|Clear|Hot|Partly cloudy
Defaultregular expression (no match)^(Cloudy|Mostly cloudy)$|[Ss]hower|[Rr]ain|[Dd]rizzle|[Tt]hunder|Hail|[Ss]now|[Ss]leet|[Bb]lizzard|Sunny|Fair|Clear|Hot|Partly cloudy
Regular expressions are case-sensitive

The Case sensitive switch does not apply to regular expressions; they always match capitals exactly. A pattern with Rain does not match Heavy rain or Freezing rain, and Cloudy does not match Mostly cloudy. Use [Rr]ain, [Ss]now and so on, as above, or match on the code instead.

The text patterns follow the same groups as the code patterns: cloudy and mostly cloudy go to Rain, partly cloudy goes to Sunny. Some texts contain two words from different groups, for example Mixed rain and snow or Light snow showers. With the text patterns above, they match both Rain and Snow. If that matters, match on the code.

Why not "contains"?​

contains checks whether the value contains the whole text you enter. Rain does not contain Showers / Rain / Cloudy, so a grouped condition never matches. Use one contains event per word, or one regular expression (match) event per group, as above.

When the events run​

  • An event runs when its rule becomes true: when the datasource refreshes with a new value, or when you edit the override datasource.
  • While the value keeps matching, the event does not run again, so the Content does not jump back to the same page on every refresh.
  • When the value stops matching, the event is ready to run again the next time it matches.

❓ Check what the pages do between weather changes. If each page has a duration and the Content moves on to the next page, the offer changes even though the weather has not. Test on a device and, if needed, give the offer pages a duration long enough not to advance.

Learn more: Evaluation Types

Learn more: Jump To Action - Navigate Between Pages

Step 5: Test with the override datasource​

  1. Open the Content in preview.
  2. In a second browser tab, open the override datasource.
  3. Change the Code (or Condition) value and save:
Set the value toThe Content jumps to
12 / RainRain page
32 / SunnySunny page
16 / SnowSnow page
20 / FoggyDefault page

When everything works, change the Bound value of each event back to the Weather datasource.

Step 6: Show the live weather on the Default page​

The Default page is a good place for a Weather Widget, so viewers see the current conditions and forecast while no special offer applies.

Learn more: Weather Widget