Я работаю над проектом по извлечению данных из phpmyadmin с помощью Dialogflow. Я следил за учебником на YouTube. Однако результаты после выполнения очень простого запроса не определены. Вот мой код
'use strict';
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
const mysql = require('mysql');
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
function welcome(agent) {
agent.add(`Welcome to my agent!`);
}
function fallback(agent) {
agent.add(`I didn't understand`);
agent.add(`I'm sorry, can you try again?`);
}
function connectToDatabase(){
const connection = mysql.createConnection({
host: '***.***.***.***',
user: '*************',
password: '*********',
database: '****************'
});
return new Promise((resolve, reject) => {
connection.connect();
resolve(connection);
});
}
function queryDatabase(connection){
return new Promise((resolve, reject) => {
connection.query('SELECT * FROM Data', (error, results, fields) => {
resolve(results);
});
});
}
function handleReadDB(agent){
return connectToDatabase()
.then(connection => {
return queryDatabase(connection)
.then(result => {
console.log(result);
connection.end();
});
});
}
let intentMap = new Map();
intentMap.set('Default Welcome Intent', welcome);
intentMap.set('Default Fallback Intent', fallback);
intentMap.set('ReadDB', handleReadDB);
// intentMap.set('your intent name here', googleAssistantHandler);
agent.handleRequest(intentMap);
});
результаты показывают что-то вроде этого
3: 10: 29,50 *
3: 10: 29.503 PM info
dialogflowFirebaseFulfillment undefined
Пожалуйста, помогите