【问题标题】:How to pass information from one intent to another如何将信息从一个意图传递到另一个意图
【发布时间】:2020-06-16 14:55:58
【问题描述】:

使用 Google 登录进行帐户链接,我已阅读用户电子邮件。 如何将此对话数据传递给下一个意图?


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”替换什么或者应该在我的代码中添加什么。

【问题讨论】:

    标签: dialogflow-es actions-on-google dialogflow-es-fulfillment


    【解决方案1】:

    您不必将其传递给您的下一个意图。一旦您的用户通过 accountlinking 登录,用户的电子邮件就可以通过 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>`
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-11
      • 2019-01-25
      • 1970-01-01
      • 2023-03-22
      • 1970-01-01
      • 1970-01-01
      • 2014-11-15
      • 1970-01-01
      相关资源
      最近更新 更多