Dialogflow es 更改dialogflow中的日期格式

Dialogflow es 更改dialogflow中的日期格式,dialogflow-es,dialogflow-es-fulfillment,Dialogflow Es,Dialogflow Es Fulfillment,我目前正试图用dialogflow建立一个聊天机器人/代理,但我对编程业务/IT方面的知识一无所知。我是一个学生,有一个留言板,上面展示了如何创建聊天机器人,哈哈。但我很感兴趣,坐下来试着为我的作品创作一个。一个简单的机器人,告诉客户开门时间,并提供一些信息,以节省我们的一些电话。到现在为止,一直都还不错。我想包括预订表的功能,我的问题如下: 我读过很多关于将日期和时间格式改为“周四下午4点”而不是“2020-12-26T16:00:00+01:00”的问题。 正如我所说的,到目前为止我还不知道

我目前正试图用dialogflow建立一个聊天机器人/代理,但我对编程业务/IT方面的知识一无所知。我是一个学生,有一个留言板,上面展示了如何创建聊天机器人,哈哈。但我很感兴趣,坐下来试着为我的作品创作一个。一个简单的机器人,告诉客户开门时间,并提供一些信息,以节省我们的一些电话。到现在为止,一直都还不错。我想包括预订表的功能,我的问题如下: 我读过很多关于将日期和时间格式改为“周四下午4点”而不是“2020-12-26T16:00:00+01:00”的问题。 正如我所说的,到目前为止我还不知道如何更改代码以获得不同的输出,所以我的问题是,您是否可以告诉我在哪里必须这样做,或者在哪里可以找到解决方案。别误会,我很想知道怎么做,所以是的,如果你能保存那份圣诞礼物,我会很高兴:) 顺致敬意,
所以,你的问题含糊不清,缺乏细节
如果您想在当地时间将“2020-12-26T16:00:00+01:00”转换为“星期四下午4点”,请使用以下帮助功能:

function convertParametersDateTime(date, time){
  return new Date(Date.parse(date.split('T')[0] + 'T' + time.split('T')[1].split('+')[0]));
}


// A helper function that adds the integer value of 'hoursToAdd' to the Date instance 'dateObj' and return a new Data instance.
function addHours(dateObj, hoursToAdd){
    return new Date(new Date(dateObj).setHours(dateObj.getHours() + hoursToAdd));
}

// A helper funciton that converts the Date instance 'dateObj' into a string that represents this time in English.
function getLocaleTimeString(dateObj){
    return dateObj.toLocaleTimeString('en-US', {hour: 'numeric', hour12: true});
}

// A helper dunction that converts the Date instance 'dateObj' into a string that represents this date in English
function getLocaleDateString(dateObj){
    return dateObj.toLocaleDateString('en-US', {weekday: 'long', month: 'long', day: 'numeric'});
}
这些是助手函数。出于您的意图,您必须在履行功能中调用它们。下面是一个非常简单的示例:

function makeAppointment (agent) {
    // Use the Dialogflow's date and time parameters to create Javascript Date instances, 'dateTimeStart' and 'dateTimeEnd',
    // which are used to specify the appointment's time.
    const dateTimeStart = convertParametersDateTime(agent.parameters.date, agent.parameters.time);
    const dateTimeEnd = addHours(dateTimeStart, appointmentDuration);
    const appointmentTimeString = getLocaleTimeString(dateTimeStart);
    const appointmentDateString = getLocaleDateString(dateTimeStart);

    agent.add(`Here's the summary of your reservation:\nDate&Time: ${appointmentDateString} at ${appointmentTimeString}`);

}

这些代码可能包含一些语法错误。这些功能提供了您想要的功能,但您必须根据需要进行调整。

好的。非常感谢您的详细回答,我会尽我最大的努力:)