Surely you have read the entire series of articles on how to use Chatfuel to make chatbots for your fanpage, right?
I have shared the good things in those posts. If you have not read it, you can access your articles to read again following the links below.
- Use Chatfuel to make chatbot update situation of Covid-19 virus (Chatfuel part 1)
- Use Chatfuel to make chatbot send pictures (Chatfuel part 2)
- Use Chatfuel to make chatbot look up gasoline prices (Chatfuel part 3)
And continue the series of interesting games when making chatbots with Chatfuel, today I bring you another tutorial, which is to do chatbot looking up weather data.
Ok, got it Let’s go
To use in this article I need an api that provides weather data value and search on google, you will encounter quite a lot of results returned like this. https://rapidapi.com/blog/access-global-weather-data-with-these-weather-apis/
Here, I use the OpenWeatherMap API! provided at https://openweathermap.org/api
To use it, we need to create an account here to get api_key. Please register an account here: https://home.openweathermap.org/users/sign_up
Then there will be an email sent to us like this, including instructions for use. If you do not see enough details, we will look at its api page.
Ok, got it So there is API key, we start the code to submit data when querying. Please use the code below.
In the above code, remember to change the api key that OpenWeatherMap has emailed to you.
Next is the setup for chatbot, you setup as shown below
Explain that because we use to receive the value of the user’s province or city to send a bot message to the bot to return the result, we use the get method to receive the user’s data, then will Return the data via the code we made above.
Finally, after setup is complete, we run the test and the results will be the same. Wish success