我们使用 firebase 云功能来实现我们的功能,并使用外部 rest api 来进行 crud 操作。
我们有几个后续行动的一个意图,它看起来像这样
- Create Note
- - Create Note - fallback*
- - - Create Note - fallback - yes
- - - Create Note - fallback - no
* the fallback allows us to capture free text
在我们的网络钩子中,我有以下满足
app.intent("Create Note", (conv) => {
if (!conv.user.storage.note) conv.user.storage.note = {};
conv.ask("Go ahead, talk to Talkatoo!");
});
app.intent("Create Note - fallback", (conv) => {
conv.user.storage.input = conv.input.raw;
let response = conv.user.storage.note
? conv.user.storage.note.body.concat(conv.input.raw)
: conv.user.storage.input;
conv.ask("So far this is what I heard you say, let me know if this is complete. ", response);
});
app.intent("Create Note - fallback - yes", (conv) => {
// based on the conv.user.storage.note object
// either make a call to create a note or update a note
// make call to external api and based on the response
// set the value for conv.user.storage.note
conv.ask("Great news, let me save that for you!");
});
app.intent("Create Note - fallback - no", (conv) => {
// based on the conv.user.storage.note object
// either make a call to create a note or update a note
// make call to external api and based on the response
// set the value for conv.user.storage.note
// Send the user back to Create Note to capture the rest of their input
conv.followup("my_custom_event");
});
问题是,conv.user.storage.note
当我从 API 获得响应时,它正在设置,但随后它被重置为空,因此每次都会创建一个新注释。我正在尝试将用户的各种输入附加为一个注释