我正在dialogflow内联编辑器中编写一个函数,该函数对已链接的Google日历进行更改,但不断出现错误:
"error": "conv.parameters.date.split is not a function"
当我查看Firebase上的日志或履约记录时。我发誓该功能在前一天才起作用,但是无论我做什么,都无法起作用。
功能如下:
app.intent('Make Appointment', (conv) => {
const dateTimeStart = new Date(Date.parse(conv.parameters.date.split('T') [0] + 'T' + conv.parameters.time.split('T')[1].split('-')[0] + timeZoneOffset));
const dateTimeEnd = new Date(new Date(dateTimeStart).setHours(dateTimeStart.getHours() + 1));
const appointmentTimeString = dateTimeStart.toLocaleString(
'en-US',
{ month: 'long', day: 'numeric', hour: 'numeric', timeZone: timeZone }
);
// Check the availibility of the time, and make an appointment if there is time on the calendar
return createCalendarEvent(dateTimeStart, dateTimeEnd).then(() => {
conv.add(`Ok, your reservation for. ${appointmentTimeString} is booked`);
}).catch(() => {
conv.add(`I'm sorry, there are no slots available for ${appointmentTimeString}.`);
});
});
我了解错误是什么,我想知道是否有人知道一种使用适用于“转换”的不同方法来完成相同操作的方法。
谢谢!
注意:我在代码中提供的所有凭据对Google日历api都是正确的。