Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

How can I transfer the information from mongodb database to dialogflow with node.js? #347

Open
usuario12345679 opened this issue Dec 5, 2022 · 2 comments

Comments

@usuario12345679
Copy link

Good afternoon I need help because the designed program shown below manages to transfer the information to the consolelog but it is not able to send it to dialogflow through agent.add function. In mongo db database is the information of people with name, department, position and mail. From dialogflow it will receive the position and the department, and the program must be able to search in the mongodb database a person who fullfils those two requirements and send all the information back to dialogflow. I think the key is to use the find() function and then know how to take that information to an array, but I don't know how. Any help is appreciated. (All functions for connecting to moongose are assumed to be OK.)

`function ConsultarDepartament(agent) {

    var departament = agent.parameters.departamentos;
    var cargo = agent.parameters.cargodepartamento;

   contactodepartamento.find({departament : 'departament', cargo : 'cargo'}) 
             .exec((err, res)=>{
       if(err) return console.log('Error ' + err)
          else console.log(res);

               });
      agent.add('The name and email of the person you are looking for is: '+);
     }`
@usuario12345679
Copy link
Author

++ The result coming from the function is an array stored in "res" as coming from mongodb:
{ _id 6*** department : "Automatic". cargo : "Director" name: "D*** mail: "d***" }
The problem is that I don't know how to get from the variable "res" that comes from mongodb, the name and the mail and put it in agent.add to send it to Dialogflow.

@usuario12345679
Copy link
Author

A value that is stored in an array (res[0].name) coming from the 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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant