Commit 6fe22cd6 authored by Navodya Pasqual's avatar Navodya Pasqual

Text file output

parent 8531d68a
Abstraction is a very important feature of OOPs that allows displaying only the important information and hiding the implementation details.
\ No newline at end of file
const express = require('express'); const express = require('express');
const router = express.Router(); const router = express.Router();
const dialogflow = require('dialogflow'); const dialogflow = require('dialogflow');
fs = require('fs');
const config = require('../../config/digitalHuman/config'); const config = require('../../config/digitalHuman/config');
const projectId = config.googleProjectID const projectId = config.googleProjectID
...@@ -39,6 +39,14 @@ router.post('/textQuery', async (req, res) => { ...@@ -39,6 +39,14 @@ router.post('/textQuery', async (req, res) => {
console.log(` Query: ${result.queryText}`); console.log(` Query: ${result.queryText}`);
console.log(` Response: ${result.fulfillmentText}`); console.log(` Response: ${result.fulfillmentText}`);
fs.writeFile('output.txt', result.fulfillmentText , function (err,data) {
if (err) {
return console.log(err);
}
console.log(data);
});
res.send(result) res.send(result)
}) })
...@@ -63,7 +71,7 @@ router.post('/eventQuery', async (req, res) => { ...@@ -63,7 +71,7 @@ router.post('/eventQuery', async (req, res) => {
const result = responses[0].queryResult; const result = responses[0].queryResult;
console.log(` Query: ${result.queryText}`); console.log(` Query: ${result.queryText}`);
console.log(` Response: ${result.fulfillmentText}`); console.log(` Response: ${result.fulfillmentText}`);
res.send(result) res.send(result)
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment