在帐户链接期间获取SignIn.status的未定义值 [英] Getting Undefined value for SignIn.status during account linking

查看:180
本文介绍了在帐户链接期间获取SignIn.status的未定义值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在进行帐户链接和在Google的链接"类型中设置google登录.

I am working on the Account Linking & set google Sign-IN in Linking type in Google.

我创建了两个意图,一个意图将调用google登录功能,第二个意图将从google帐户中读取数据.例如.电子邮件ID,姓名.

I have created two intents, one will call the google Sign-In feature and the second one will read the data from google account for. eg. email id, name.

意图1,我已为此意图启用了webhook调用.

In Intent 1, I have enabled the webhook call for this intent.

在Intent 2中,我已将Event设置为actions_intent_SIGN_IN&为此目的启用了webhook调用.

In Intent 2, I have set Event to actions_intent_SIGN_IN & enabled the webhook call for this intent.

尽管我在Inline Editors中的这些函数(Intents结果)已成功执行,但是我仍在获取SignIn.status的Undefined值,下面给出了代码,请提供帮助.

Though my these functions (Intents results) in Inline Editors are successfully executing, still I am getting Undefined value for SignIn.status, code is given below, please help.


'use strict';
const {dialogflow, SignIn} = require('actions-on-google');

const app = dialogflow({  
  clientId: "174911074867-tuffsr7ec28vg7brppr0ntkjutthfq8n.apps.googleusercontent.com",
}); 
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');

process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements

exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });

function accountlinking(agent) {      
  var signin=new SignIn('To get your account details'); 
}  
function testsignData(agent) {    
   console.log("status :"+SignIn.status); 
} 
  let intentMap = new Map();  
  intentMap.set('Intent1', accountlinking);  
  intentMap.set('Intent2', testsignData);  

  agent.handleRequest(intentMap); 
});

1).在我进行Action通话时,它要求先关联Google帐户,而在关联过程完成后,它才继续前进.但是我需要开始行动,进行一些交谈,然后在需要时才请求链接.我需要通过我的意图打电话给我.该怎么做?

1). On my Action calling, it is asking for the Google Account linking first and after linking process only it is moving ahead. But I need to get into the action, have a little conversation and when required only then asking for the Linking. I need to call via my intent. How to do that?

2).尽管我成功执行了这些函数(Intents结果),但我仍在获取SignIn.status的未定义值

2). Though my these functions (Intents results) are successfully executing, still I am getting Undefined value for SignIn.status

推荐答案

您的testSigninData()函数正在调用Signin.status,但是此函数中没有名为SignIn的任何变量,因此这是未定义的原因.尝试更改您的函数,使其接受登录期间给出的转换,参数和登录对象.

Your testSigninData() function is calling Signin.status, but you don't have any variable called SignIn in this function, so that is why it is undefined. Try changing your function so it accepts a conv, params and signin object that are given during a sign-in.

如果您查看链接文档的帐户,则您可以查看在帐户链接过程中提供了哪些参数.

If you have a look at the account linking documentation you can see which parameters are provided during the accountlinking process.

在Google上执行操作的帐户链接设置示例

const {dialogflow, SignIn} = require('actions-on-google');
const app = dialogflow({
  // REPLACE THE PLACEHOLDER WITH THE CLIENT_ID OF YOUR ACTIONS PROJECT
  clientId: CLIENT_ID,
});

// Intent that starts the account linking flow.
app.intent('Start Signin', (conv) => {
  conv.ask(new SignIn('To get your account details'));
});
// 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;
    conv.ask(`I got your account details, ${payload.name}. What do you want to do next?`);
  } else {
    conv.ask(`I won't be able to save your data, but what do you want to do next?`);
  }
});

以上代码使用了名为app的googledialogflow处理程序上的操作.在您的代码中,您正在使用WebhookClient对象来处理dialogflow意图.我不确定您是否可以将WebhookClient用于Google帐户链接上的操作.

The above code uses the actions on google dialogflow handler called app. In your code you are using the WebhookClient object to handle dialogflow intents. I'm not sure if you can use the WebhookClient for actions on google accountlinking.

如果在更改testSigninDate函数参数后它仍然不起作用,则可能值得尝试删除webhookclient并查看是否可以使用app.intent()调用来处理您的意图,就像上面的代码示例一样

If it still doesn't work after you changed the testSigninDate function parameters, it might be worth trying to remove the webhookclient and see if you can use the app.intent() calls to handle your intents just like the above code example.

这篇关于在帐户链接期间获取SignIn.status的未定义值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆