node.js - Actions on Google 的登录方法存在问题
问题描述
我正在尝试为我的 AoG 使用谷歌登录方法,为我的用户提供更多定制体验,并将存储用户的一些数据以便我可以给出更相关的答案。我正在使用 dailogflow。调用登录后我得到这个错误
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 中添加 clientIDapp=dailogflow({debug:true,clientID:"your clientID"})
并从谷歌模块上的操作中获取登录方法{dailogflow,signIn}=require("actions-on-google")
..
推荐阅读
- python - 第 21 行,在
os.startfile(fileName) AttributeError: 模块 'os' 没有属性 'startfile' - python - sqlalchemy.exc.ArgumentError: Object category_tb('23','cat1','cat1desc','0') 作为 SQL 文字值不合法
- php - PHP Mailer 无法在 Live Server 上运行,但在 localhost 上运行良好
- python - 如何可视化 Conv1D 层中的内核?
- java - 如何在 Mockito 中模拟类型转换实例
- php - 请求回调 url 的数据
- deno - deno 安装和 deno 编译之间有什么区别?
- ansible - 有没有办法从 Ansible 中的下载链接中获取文件的文件名
- react-native - 如何在世博会的一个上传按钮中实现图像和 pdf 选择器?
- ruby - Rubocop 安装(机器:linux-gnu,Ubuntu)