0

A value that is stored in an array (res[0].name) coming from a mongodb database, has to be sent to dialogflow by using agent.add. It turns out that in the visual studio console the value res[0].name appears correctly, but when you add it in agent.add('The name is: '+res[0].name) the result in dialogflow is NOT AVAILABLE. Does anyone know if you need some kind of converter?

Tried everything, but I guess the closest version is this: `

    function Consult(agent) {

      // Value coming from Dialogflow
      const department = agent.parameters.department;
      const position = agent.parameters.position;

   Consult.find({department : department, position : position}) //Database finding
               .exec((err, res)=>{
         if(err) return console.log('Error: ' + err)
                console.log(res[0].name);
               const a = res[0].name;
              });
             return agent.add("the name of the person you are searching for is: "+res[0].name);
              );

`

Gorka
  • 1
  • 1

0 Answers0