Archived | Integrate weather information into Watson Assistant

Archived content

Archived date: 2019-05-21

This content is no longer being updated or maintained. The content is provided “as is.” Given the rapid evolution of technology, some content, steps, or illustrations may have changed.

Note: Watson Conversation is now Watson Assistant. Although some images and text in this how-to may refer to the service as Watson Conversation, the steps and processes will still work.

Weather insight is quickly becoming a crucial factor for many industries. With this how-to the reader will understand how to integrate weather insights into a chatbot. To retrieve weather data into the conversation the Weather Company Data service will be used, we’ll also be using Watson Assistant and the Node-RED platform.

What is the Weather Company Data service? This service allows a developer to integrate weather data from The Weather Company into your IBM Cloud application. You can retrieve weather data for an area specified by geolocation. This allows you to create applications that solve real world business problems where weather has a significant impact on the outcome.

What capabilities does Watson Assistant have? Watson Assistant adds a natural language interface to your application to automate interactions with your end users. Common applications include virtual agents and chatbots that integrate and communicate on any channel or device. Train a Watson Assistant dialog through an easy-to-use web application, designed so you can quickly build natural conversation flows between your apps and users, and deploy scalable, cost effective solutions.

Learning Objectives

Upon completing this tutorial the reader will understand how to:

  • Use the Weather Company Data service on IBM Cloud
  • Integrate weather retrieval into a Watson Assistant dialog


In order to complete this how-to, you will need the following prerequisites:

Estimated Time

The total time to complete this how-to is around 30 minutes.


1. Using the Weather Company Service


  • Here are some features that Weather Company Data service do:

    • Hourly forecast: An hourly weather forecast for the next 48 hours starting from the current time, for a specified geolocation.
    • Daily forecast: A daily forecast for each of the next 3, 5, 7, or 10 days starting from the current day, including forecasts for the daytime and nighttime segments.
    • Intraday forecast: A daily forecast for each of the next 3, 5, 7, or 10 days starting from the current day, which breaks each daily forecast into morning, afternoon, evening, and overnight segments.
    • Current conditions: Observed weather data (temperature, wind direction and speed, humidity, pressure, dew point, visibility, and UV Index) plus a weather phrase and a matching weather icon.
    • Historical data: Observed weather data from site-based observation stations for a specified geolocation that includes current observations and up to 24 hours of past observations.
    • Weather alerts: Government-issued weather alerts, including weather watches, warnings, statements, and advisories issued by the National Weather Service (US), Environment Canada, and MeteoAlarm (Europe).
    • Location services: The ability to look up a location name or geocode (latitude and longitude) to retrieve a set of locations that match the request.
    • Almanac services: Historical daily or monthly weather data sourced from National Weather Service observations stations from a time period spanning 10 to 30 years or more.

2. Integrate weather into Watson Assistant

  • Create a Watson Assistant service. You can organize your conversation by launching the tool after the service is created.


  • You can pull your location data from Watson Assistant by this code block in Node-RED flow
msg.payload = msg.payload.context.location;
return msg;
  • Make your context ready after receiving context from a Telegram chatbot
msg.chatId = msg.payload.chatId;
msg.payload = msg.payload.content;
return msg;
  • Make ready your context for the Telegram this time after conversation service
msg.payload = {
  chatId : msg.chatId,
  type : "message",
  content : msg.payload.output.text[0]};
return msg;

Note: Your conversation may differ according to created dialog!

  • Inside Watson Assistant nodes, there is an entity called sys-location which extracts place names (country, state/province, city, town, etc.) from the user’s input. By using it we can get a location name from context easily.
  "context": {
    "action": "weather",
    "location": "@sys-location"


3. Optionally use Node-RED and Telegram

The goal of this how-to was to educate the reader on the Weather Company Data and Watson Assistant services. I ended up using Telegram as a front-end for my chatbot, and Node-RED to handle the logic between the services. See the images below.




In this how-to we went over how to integrate Weather Company Data with Watson Assistant and use optionally how to use the Node-RED platform to tie everything together. The reader is encouraged to choose whatever platform and front-end they desire.

Ali Nihat Uzunalioglu