My first time with Dialogflow or Nodejs, I'm sure this is the most poorly written, dumbest code you will ever see, but it works.
This code needs to be used inside the index.js file inside the fulfillment section of the DialogGlow interface. The database part doesnt work well, it just edits a predefined database entry, need to reset it each new conversation. The initial text of the entry serves as the prompt. You also need to match the names used in your prompt with the names inserted in the code.