使用Google Sign in进行账户链接,我已经读取了用户的电子邮件,我如何将这个对话数据传递给下一个意图?
app.intent("Get Signin",(conv , params, signin) =>{
if(signin.status === 'OK'){
const email = conv.user.email
conv.ask(`I got your email as ${email}. How would you like to redeem?`)
conv.ask(new Suggestions(['QR code'],['16 digit code'],['Cancel']))
}
else
{
conv.close("Please sign in to redeem");
}
})
app.intent("numcode",(conv,{num, points}) => {
const mailOptions = {
from: "abc",
to: email,
subject: "YAY!",
html: `<p>Hello !! <br> You have ${points} in (${num}). </p>`
}
transporting.sendMail(mailOptions, (err, info) => {
if(err)
{
console.log(err);
}
})
conv.ask("You have succesfully finished.");
})
我想给用户发送一封邮件,那么应该用 "to: email "来代替什么,或者应该在我的代码中添加什么。
你不需要把它传给你的下一个意图。一旦你的用户通过账户链接登录,用户的电子邮件就可以通过conv对象获得。你可以调用 conv.user.email
来检索它。当您的用户触发您的numcode意图时,它应该用用户的电子邮件填充to属性。
在您的邮件选项中,您可以做如下操作。
const mailOptions = {
from: "abc",
to: conv.user.email,
subject: "YAY!",
html: `<p>Hello !! <br> You have ${points} in (${num}). </p>`
}