What I'm trying to do is to be able to use request-promise-native and cheerio in my dialogflow webhook to scrape some articles from a website, I've tried several ways but never been able to work it out.
My last attempt was doing as suggested in this post, but i could not make it work.
If you want to have a look at my code, here it is the code i wrote, with a bit of explanation: https://github.com/Vaelthur/webscraping-with-dialogflow-incomplete
The problem is in the function registered to the
scrpwb
intent.You are calling
prova_promise
, which returns a Promise (which is correct!), but does not itself return a Promise. So the function returns nothing, which is handled immediately by the handler rather than waiting for the Promise to complete.The solution is simple - make sure it returns a Promise which you can do with something like
and the rest being exactly the same.