【发布时间】:2020-10-26 22:32:02
【问题描述】:
我正在使用 DialogFlow 为一家意大利餐厅创建助手。
我已将语言设置为西班牙语,一切似乎都很好,但是当我显示预订的最后日期时,它以英语显示(周五和五月在附件图片的情况下)。
这是生成上述对餐桌预订过程的特定响应的代码:
function createBooking(agent) {
let guests = agent.parameters.comensales;
let time = new Date(agent.parameters.time);
let date = new Date(agent.parameters.date);
let bookingDate = new Date(date);
var numeroReserva = Math.random().toString(16).slice(2, 8).toUpperCase();
bookingDate.setHours(time.getHours());
bookingDate.setMinutes(time.getMinutes());
let now = new Date();
if (guests < 1){
agent.add('You need to reserve a table for at least one person. Please try again!');
} else if (bookingDate < now){
agent.add(`No puedes reservar una fecha pasada. Por favor, inténtalo de nuevo!`);
} else if (bookingDate.getFullYear() > now.getFullYear()) {
agent.add(`No puedes hacer una reserva para ${bookingDate.getFullYear()} todavía. Por favor, elige una fecha en ${now.getFullYear()}.`);
} else {
let timezone = parseInt(agent.parameters.time.toString().slice(19,22));
bookingDate.setHours(bookingDate.getHours() + timezone);
agent.add(`Perfecto. He reservado una mesa para ${guests} el ${bookingDate.toString().slice(0,21)}`);
agent.add(`Tu código de reserva es: ${numeroReserva}`);
agent.add('Nos vemos pronto!');
agent.add('Buon appetito!');
}
}
【问题讨论】:
-
您如何填充响应?它是 webhook 还是其他机制?如果您能详细说明如何构建响应,我认为这会有所帮助。
-
@Kolban 你说得对,我应该详细说明。我正在使用 Fulfillment 并使用我刚刚在问题中附加的 js 函数。
标签: dialogflow-es chatbot