我正在尝试使用谷歌登录方法为我的AoG,为我的用户提供更多的自定义体验,并将存储一些用户的数据,以便我可以提供更多相关的答案。我正在使用dailogflow.After调用登录我得到这个错误
app.intent('Default Welcome Intent',(conv)=>{
conv.ask(`HIIIIIIIIIIIIIIIIIIIIIIIIIII`);
});
app.intent('ask_for_sign_in', (conv) => {
conv.ask(new SignIn(`to get sign in details`));
});
app.intent('ask_for_sign_in_confirmation', (conv, params, signin) => {
if (signin.status !== 'OK') {
return conv.ask('You need to sign in before using the app.');
}
const payload = conv.user.profile.payload
conv.ask(`I got your account details, ${payload.name}. What do you want to do next?`)
const access = conv.user.access.token;
db.collection("user").doc(access).set({
name:"name",
name2 : conv.user.access.name,
}).then(()=>{
conv.close(`document successfully written`);
return;
}).catch((e)=>{
conv.close(`error writing document ${e}`);
})
// possibly do something with access token
return conv.ask('Great! Thanks for signing in.');
});
app.intent('Start Signin', conv => {
conv.ask(`siging you in`);
conv.ask(new SignIn('To get your account details'))
})
app.intent('Default Welcome Intent',(conv)=>{
conv.ask(`hi`);
})
// Create a Dialogflow intent with the `actions_intent_SIGN_IN` event.
app.intent('Get Signin', (conv, params, signin) => {
if (signin.status === 'OK') {
const payload = conv.user.profile.payload
const {email} = conv.user;
conv.ask(`I got your account details, ${payload.name}.and ${email} What do you want to do next?`)
db.collection(`user`).doc(email).set({
name:"some name",
}).then(()=>{
conv.ask(`success`);
return;
}).catch((e)=>{
conv.close(`unscess ${e}`);
})
} else {
conv.ask(`I won't be able to save your data, but what do you want to do next?`)
}
})
这个代码将完美地工作,如果像我这样的人想要存储用户的数据,以便您可以在需要时提供相关信息,它在模拟器上工作也不用担心,并且不要忘记在dailogflow中添加clientID app=dailogflow({debug:true,clientID:"your clientID"})
并从谷歌模块{dailogflow,signIn}=require("actions-on-google")
上的动作获取signIn方法..