Basically I am trying to do web scraping in this Intent of Dialogflow to my website. I'm working with node js in my local IDE. But it always goes for the catch of promise and show 'myError' in the Google Assistant.
Thanks for any help!
I've tried the web scraping code in a separate node js script file and it works fine and get the desire result. But when i copy & paste it in the intent function and add the return (if don't return I can't deploy) it goes straight to the catch of the promise.
I read this article with similar problem but didn't work. Cheerio.load messes with responses for Google Assistant
function mostrarEventos(agent) {
const cheerio = require('cheerio');
const rp = require('request-promise');
// const url = 'https://germantellezv.github.io'
const options = {
uri: 'http://germantellezv.github.io/',
transform: function(body){
return cheerio.load(body);
}
}
return rp(options)
.then($ => {
var result = $('.projects-title').find('p').text()
agent.add(`${result}`)
agent.add('hola mundo')
return console.log('testing'); //irrelevant
}).catch(err => {
agent.add('myError')
return console.log(err) // irrelevant
})
}
I expect to see the result of my web scraping in the google assistant. Or at least, undertand why it doesn't goes for the .then
Update: i tried a change in the .catch adding agent.add(err) and now i see in the google assistant this: RequestError: Error: getaddrinfo EAI_AGAIN germantellezv.github.io:80
Google Cloud Platform give me $300 for use his services and i used it to firebase and that's all.
To conclude, I could not make requests to the external Google network because my plan was free. Now I am using the Blaze plan and I just saw that my Google assistant already made web scraping successfully. People had said it but I didn't find that limitation in the documentation so here I leave that information: https://cloud.google.com/dialogflow/docs/fulfillment-configure
Look at this limitation item configure fulfillment limitations
Thanks for your time and help!