You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, i want to create weather.js intent that return current weather from city
for example, when user type "weather new york" it return current temperature, humidity, wind, cloud.
I'm using your example code but got the following error
ReferenceError: fetchCities is not defined
at new module.exports (D:\Pproject\WAbot\whatsbot\computed_intents\weather.js:13:9)
at LanguageProcessor.loadIntent (D:\Pproject\WAbot\LanguageProcessor.js:64:55)
at D:\Pproject\WAbot\LanguageProcessor.js:50:37
at Array.forEach ()
at LanguageProcessor.loadIntents (D:\Pproject\WAbot\LanguageProcessor.js:50:15)
at new LanguageProcessor (D:\Pproject\WAbot\LanguageProcessor.js:37:14)
at Object. (D:\Pproject\WAbot\bot.js:11:19)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
[nodemon] app crashed - waiting for file changes before starting...
this is my code
constgot=require('got');module.exports=class{constructor(processor){this.processor=processor// the instance of LanguageProcessor.js that created this instancethis.keywords=["weather","like"]// keywords to identify the intentthis.entities={}this.meta={// set some metadata"userFacingName": ["weather"],"description": "Ask about the weather in different cities","examples": ["weather in SF?","new york weather","listen fren, you better tell me what its like in Bombay"]}fetchCities()}asyncfetchCities(){consturl=`http://api.openweathermap.org/data/2.5/weather?q=dhaka&units=metric&appid=060a6bcfa19809c2cd4d97a212b19273&language=tr`;constresponse=awaitgot(url).then(asyncok=>{constresp=JSON.parse(ok.body)temp=resp.main.temp_maxhumi=resp.main.humiditywind=resp.wind.speedclou=resp.clouds.alldesc=resp.weather[0].descriptionconsole.log(temp,humi,wind,clou,desc)})// this.processor.updateEntities ("weather", {"new york": "Rainy", "sf": "Bright", "new delhi": "Sunny", "tokyo": "Heavy Rain"})}/** * Async function that is called when somebody calls the `weather` command * @param {string[]} entities - what city? * @param {string} user - ID of the user */asyncanswer(entities,user){// fetch the cities you can answer for, possibly using a REST API// fetch weather.com/rest or somethingreturnentities//console.log(entities)}}
I have successfully fetch the data from openweathermap.org API and test it using repl.it
this is the code that i use to fetch the data
Hi, i want to create weather.js intent that return current weather from city
for example, when user type "weather new york" it return current temperature, humidity, wind, cloud.
I'm using your example code but got the following error
this is my code
I have successfully fetch the data from openweathermap.org API and test it using repl.it
this is the code that i use to fetch the data
it return this in repl.it
https://prnt.sc/wbxhmd
you can check the code here
https://repl.it/@AbdulAziz27/FloweryMindlessBytecode?lite=true
Thanks
The text was updated successfully, but these errors were encountered: