【发布时间】:2018-09-27 18:48:10
【问题描述】:
首先要了解一些信息:我的 Google Assistant 聊天机器人目前有 2 个功能(意图),即注册用户(输入:用户的姓名、出生日期和 ID)和向另一个用户付款(输入: 收款人的姓名和身份证以及要支付的金额)。我已经设置好了,一个 index.js webhook 链接到 firebase。
以下是我目前用于 2 个意图的代码:
app.intent('onboard user', (conv, {name, surname, birthdate, ID}) => {
var user = db.collection("Users").doc(ID);
var setUser = user.set({
"FirstName": name,
"Surname": surname,
"DateofBirth": new Date(birthdate),
"ID": ID,
"AccountCreated": new Date(),
});
conv.close('Is this correct? Your full name is ' + name + ' ' + surname + '. You were born on ' + birthdate + ' and your ID is ' + ID);
});
app.intent('payment', (conv, {recipient, amount, ID}) => {
var transactionRef = db.collection("Transactions").doc(ID);
var setTransaction = transactionRef.set({
"Recipient": recipient,
"Amount": amount,
"ID": ID,
"Date": new Date(),
});
conv.close('Is this correct? You wish to pay ' + recipient + ' with ID ' + ID + ' ' + amount.amount + ' ' + amount.currency);
});
我有一些非常简单的需求想要实现,即验证指定的ID是否超过6位,最好是出生日期在合理的范围内(可能在1910年到2010年之间)。
问题是我无法找到有关如何执行此操作的明确指南。我最初是按照 Google 的 Google Assistant 和 Dialogflow 教程以及其他一些在线指南进行操作的。但我觉得这并没有让我了解除了为 Google 助理开发的基本知识之外的任何内容。
我查看了后续意图,但如果我的要求没有得到满足,我特别想打电话给他们。简单来说:
if(ID.length < 6){
\\assistant gives informative response asking and prompts for ID again
}
因此,如果我能在这方面寻求帮助,以及任何好的指南/教程,作为扩展助手开发理解的良好资源,我将不胜感激。
【问题讨论】:
标签: javascript dialogflow-es google-assistant-sdk