Action not Working when called by google assistant

dialogflow
google-assistant

#1

----------------------------------Solved----------------------------
Hey!
I´m trying to build an app that integrates with my smart home manager program got it pretty figured out, was working just fine, and then it started to only work from the dialog flow test console when called from google gives me this error:


Here´s my app.js :
‘use strict’;

const { App } = require(‘jovo-framework’);
const { Alexa } = require(‘jovo-platform-alexa’);
const { GoogleAssistant } = require(‘jovo-platform-googleassistant’);
const { JovoDebugger } = require(‘jovo-plugin-debugger’);
const { Dialogflow } = require(‘jovo-platform-dialogflow’);
const { FileDb } = require(‘jovo-db-filedb’);
const request = require(‘request’);
const axios = require(‘axios’);

// ------------------------------------------------------------------
// APP INITIALIZATION
// ------------------------------------------------------------------

const app = new App();

app.use(
//new Alexa(),
new GoogleAssistant(),
new JovoDebugger(),
new FileDb(),
new Dialogflow()

);

// ------------------------------------------------------------------
// APP LOGIC
// ------------------------------------------------------------------

app.setHandler({
async HelloWorldIntent() {
var conversa = this
var lang = conversa.$request.getLocale();
request(‘http://127.0.0.1:3001/ping’, function (error, response, body) {
try {
if (error) {
conversa.tell(“There was an error connecting to the server, please try again later or contact the system administrator”)
return;
}
else {
if (lang.includes(‘en’))
conversa.ask(“Hello! I´m Aria,” + " what can I help?");
else if (lang.includes(‘pt’))
conversa.ask(“Olá em que posso ajudar?”);
}
}
catch (err) {
throw (err)
}
});
},
LAUNCH() {
return this.toIntent(‘HelloWorldIntent’);
},

// Default_Welcome_Intent() {
// var conversa = this
// request(‘http://127.0.0.1:3001/ping’, function (error, response, body) {
// try {
// if (error) {
// conversa.tell(“There was an error connecting to the server, please try again later or contact the system administrator”)
// return;
// }
// else {
// conversa.ask(“Hello! I´m Aria,” + " what can I help?");
// }
// }
// catch (err) {
// throw (err)
// }
// });
// },

async turnLightOnIntent() {
var conversa = this
var code = “NULL”;
await (async () => {
try {
const response = await axios.get(http://127.0.0.1:3001/setDev?usr=4&devName=${this.$inputs.name.value}&value=255)
code = response.data.code
console.log(code)
if (code == ‘SUCCESS’) {
conversa.tell('The device ’ + conversa.$inputs.name.value + ‘, is now on!’);
} else if (code == “NO_PERM”) {
conversa.tell("I´m sorry, I don´t have permission to operate in the " + conversa.$inputs.room.value)
} else if (code == “INVALID_VALUE”) {
conversa.tell(“The value entered is invalid, please contact the system administrator for more info!”)
} else if (code == “NOT_FOUND”) {
conversa.tell(“No device named " + conversa.$inputs.name.value + " was found!”)

    }
  } catch (error) {
    conversa.tell("There was an error while performing the action, please try again later or contact the system administrator!")
  }
  return;
})();

},

async turnLightOffIntent() {
var conversa = this
var code = “NULL”;
console.log(this.$request.getLocale())
await (async () => {
try {
// var teste = JSON.parse(conversa)
// console.log(teste.queryResult)
const response = await axios.get(http://127.0.0.1:3001/setDev?usr=4&devName=${this.$inputs.name.value}&value=0)
code = response.data.code
if (code == ‘SUCCESS’) {
conversa.tell('The device ’ + conversa.$inputs.name.value + ‘, is now off!’);
} else if (code == “NO_PERM”) {
conversa.tell("I´m sorry, I don´t have permission to operate in the " + conversa.$inputs.room.value)
} else if (code == “INVALID_VALUE”) {
conversa.tell(“The value entered is invalid, please contact the system administrator for more info!”)
} else if (code == “NOT_FOUND”) {
conversa.tell(“No device named " + conversa.$inputs.name.value + " was found!”)
}
} catch (error) {
conversa.tell(“There was an error while performing the action, please try again later or contact the system administrator!”)
throw error
}
return;

})();

},

async getTemperatureIntent() {
var conversa = this
var code = “NULL”;
await (async () => {
try {
const response = await axios.get(http://127.0.0.1:3001/getTemp?usr=4&roomName=${conversa.$inputs.room.value})
code = response.data.code
console.log(code);
var lang = conversa.$request.getLocale();
console.log(lang)
if (code == “NO_SENS”) {
conversa.tell(conversa.$inputs.room.value + " has no Temperature sensors associated!")
}
else if (code == “NO_READ”) {
conversa.tell(conversa.$inputs.room.value + " has no Temperature readings!")
} else if (code == “NO_PERM”) {
conversa.tell("I´m sorry, I don´t have permission to operate in the " + conversa.$inputs.room.value)
}
else if (code == “ERROR”) {
conversa.tell(“An error has occurred. Please try again later”)
}
else if (code == “NO_DIV”) {
conversa.tell("No home place named, " + conversa.$inputs.room.value + “, was found”)
}
else {
if (lang.includes(‘en’))
conversa.tell(conversa.$inputs.room.value + " current temperature is " + code);
else if (lang.includes(‘pt’))
conversa.tell("A temperatura atual é de, " + code)
}
} catch (error) {
conversa.tell(“There was an error while performing the action, please try again later or contact the system administrator!”)
}
return;
})();
}
})
module.exports = { app };

Thanks in advance :smile:


#2

Hi @Diogo_Cardoso, welcome to the Jovo community :tada:

Ca you share the request that causes the error?