我正在开发使用日历API从日历中列出事件并解析响应以获取摘要的云函数 我在旁边的对话框流控制台上测试了我的功能,它给了我想要的结果,但是当我将其与google上的操作集成在一起时,它总是很重要的
/ -----阅读事件的说明
//----- read the description for event
function getKeyPoint (agent) {
return fetchDescription(agent.parameters.date,agent.parameters.time).then(() => {
agent.add("The key point for the requiered event is "+keyPoint);
}).catch((err) => {
console.log("Error here "+err);
agent.add(`There is no description `);
});
}
function fetchDescription (date,time){
appointmentDuration = 1;// Define the length of the appointment to be one hour.
dateTimeStart = convertParametersDate(date,time);
dateTimeEnd = addHours(dateTimeStart, appointmentDuration);
return new Promise((resolve,reject)=>{
console.log("is listing now ");
calendar.events.list({
auth: serviceAccountAuth,
calendarId: calendarId,
timeMin: dateTimeStart.toISOString(),
timeMax: dateTimeEnd.toISOString()
},(err,calenderResponse)=>{
if (err || calenderResponse.data.items.length==0){
reject(err || new Error('No event at this time '));
}else {
var calenderResponseBody = calenderResponse.data;
var events=calenderResponseBody.items;
keyPoint = events[0].description;
resolve(keyPoint);
}
});
});
}
the package :
{
"name": "DialogflowFirebaseWebhook",
"description": "Firebase Webhook dependencies for a Dialogflow agent.",
"version": "0.0.1",
"private": true,
"license": "Apache Version 2.0",
"author": "Google Inc.",
"engines": {
"node": "6"
},
"scripts": {
"lint": "semistandard --fix \"**/*.js\"",
"start": "firebase deploy --only functions",
"deploy": "firebase deploy --only functions"
},
"dependencies": {
"firebase-functions": "^2.0.2",
"firebase-admin": "^5.13.1",
"googleapis": "^27.0.0",
"actions-on-google": "2.2.0",
"dialogflow-fulfillment": "^0.4.1"
}
}