Watson Assistant

Expand all | Collapse all

Weather Skill for Watson Assistant

  • 1.  Weather Skill for Watson Assistant

    Posted Tue July 20, 2021 06:14 PM
    Are there any tutorials or examples on how to add weather skills to a Watson Assistant chatbot? I would like to build a chatbot that can provide weather details for a specific location is asked something like: "How is the weather there now?" or "What is the weather forecast for next week?" etc. Does The Weather Company has API that can be used by Watson Assistant? Is there a free version just like there is the Lite version for the CloudPak for Data? Thank you.

    ------------------------------
    Antonel Neculai
    ------------------------------


  • 2.  RE: Weather Skill for Watson Assistant

    Posted Tue July 20, 2021 09:49 PM
    Edited by Vincent Kok Tue July 20, 2021 09:50 PM
    Hi Antonel, 

    I have not encountered any tutorials or examples. But I guess you could use the web hooks tutorial by Morgan Carroll here: https://www.youtube.com/watch?v=5z3i5IsBVnk

    The API that you can use is from Openweather: https://openweathermap.org/api 

    Hope it helps. 

    Thanks!

    Vincent Kok
    https://www.linkedin.com/in/vincekok/

    ------------------------------
    Vincent Kok
    ------------------------------



  • 3.  RE: Weather Skill for Watson Assistant

    Posted Mon July 26, 2021 09:09 AM
    Thank you Vincent for the info sources. I have started working on developing the chatbot connected to OpenWeather API. I have been successful calling the API so far, the only aspect I still have to work on is processing the return JSON file by the IBM Watson Functions using Node.js so it passes on a nice, human-friendly response back to Watson Assistant in the dialog to display for the user. Processing JSON file with Node.js or Python is a useful skill anyway, since it's needed in pretty much any Watson Assistant project, so I'll go for it. After the chatbot is ready, I will come back here and post a link to the project so others can see an example of how to implement weather with Watson Assistant.
    ------------------------------------------------------------
    Antonel Neculai
    https://www.LinkedIn.com/in/antonelneculai/
    -----------------------------------------------------------

    ------------------------------
    Antonel Neculai
    ------------------------------



  • 4.  RE: Weather Skill for Watson Assistant

    Posted Mon August 02, 2021 06:20 PM

    Hi Antonel,


    Capture the fields you want from the response by OpenWeather into a formatted string variable, and return it to your assistant. 

    My cloud function is:

    let rp = require('request-promise')
    function main(params) {
    const options = {
    uri: "http://api.openweathermap.org/data/2.5/weather?q=" + encodeURIComponent(params.object_of_interest) + "&units=metric&APPID=my_openweather_api_id" ,
    json: true
    }
    return rp(options)
    .then(res => {
    WeatherReport = "Current Temperature : " + res.main.temp + ", Pressure : " + res.main.pressure + ", Humidity : " + res.main.humidity + ", temp min : " + res.main.temp_min + " , temp max : " + res.main.temp_max
    return { WeatherReport
    }
    })
    }


    ------------------------------
    Allen Nugent
    ------------------------------



  • 5.  RE: Weather Skill for Watson Assistant

    Posted Tue August 03, 2021 04:09 PM
    Allen, thank you for the code. I truly appreciate you sharing it! I used it (and gave credit) in my solution and I published the entire solution so other beginners can follow the steps from A to Z to add the weather skill to their chatbot. The next challenge will be to adapt the code for a call into the forecast option of OpenWeather, which is a paid option. This will require improving the dialog node to discern between requests for the current weather or for a forecast.
    I will also explore the option of using IBM's weather solution. It seemed easier to work with OpenWeather, but it would be a pity not to explore all the options offered by IBM.

    ------------------------------
    Antonel Neculai
    ------------------------------



  • 6.  RE: Weather Skill for Watson Assistant

    Posted Thu July 29, 2021 02:13 PM
    I finished creating the IBM Watson Assistant skill to connect to OpenWeather API and get the current weather. The skill only gets the current weather, because OpenWeather only offers the current weather for free, you have to pay for access to the forecast weather API.
    Here is the link to the github repository with the files for this project. Feel free to use and modify according to your needs.
    GitHub - aneculai/watson-assistant_openweather-skill: Skill for IBM Watson Assistant to connect with OpenWeather API
    Also feel free to improve the project and share with this community any details that can benefit the IBM Watson users.

    ------------------------------
    Antonel Neculai
    https://www.linkedin.com/in/antonelneculai
    ------------------------------