在帐户链接期间获取 SignIn.status 的未定义值
Getting Undefined value for SignIn.status during account linking
我正在处理帐户链接并在 Google 中设置 google 登录链接类型。
我创建了两个意图,一个将调用 google 登录功能,第二个将从 google 帐户读取数据。例如。电子邮件 ID、姓名。
在意图 1 中,我已为此意图启用 webhook 调用。
在意图 2 中,我已将事件设置为 actions_intent_SIGN_IN 并为此意图启用了 webhook 调用。
虽然我在内联编辑器中的这些函数(Intents 结果)已成功执行,但我仍然得到 SignIn.status 的未定义值,代码如下,请帮助。
'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).在我的操作调用中,它首先要求 Google 帐户链接,并且在链接过程之后它才继续前进。但是我需要开始行动,进行一些对话,并且在需要时才请求链接。我需要通过我的意图打电话。怎么做?
2).尽管我的这些函数(意图结果)已成功执行,但我仍然得到 SignIn.status
的未定义值
您的 testSigninData()
函数正在调用 Signin.status
,但您在此函数中没有任何名为 SignIn 的变量,因此它未定义。尝试更改您的函数,使其接受在登录期间提供的 conv、params 和 signin 对象。
如果您查看帐户链接 documentation,您可以看到在帐户链接过程中提供了哪些参数。
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
的 google 对话流处理程序上使用了操作。在您的代码中,您使用 WebhookClient 对象来处理对话流意图。我不确定您是否可以使用 WebhookClient 对 google accountlinking 进行操作。
如果在更改 testSigninDate
函数参数后它仍然不起作用,可能值得尝试删除 webhookclient 并查看是否可以使用 app.intent()
调用来处理您的意图就像上面的代码示例一样。
我正在处理帐户链接并在 Google 中设置 google 登录链接类型。
我创建了两个意图,一个将调用 google 登录功能,第二个将从 google 帐户读取数据。例如。电子邮件 ID、姓名。
在意图 1 中,我已为此意图启用 webhook 调用。
在意图 2 中,我已将事件设置为 actions_intent_SIGN_IN 并为此意图启用了 webhook 调用。
虽然我在内联编辑器中的这些函数(Intents 结果)已成功执行,但我仍然得到 SignIn.status 的未定义值,代码如下,请帮助。
'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).在我的操作调用中,它首先要求 Google 帐户链接,并且在链接过程之后它才继续前进。但是我需要开始行动,进行一些对话,并且在需要时才请求链接。我需要通过我的意图打电话。怎么做?
2).尽管我的这些函数(意图结果)已成功执行,但我仍然得到 SignIn.status
的未定义值您的 testSigninData()
函数正在调用 Signin.status
,但您在此函数中没有任何名为 SignIn 的变量,因此它未定义。尝试更改您的函数,使其接受在登录期间提供的 conv、params 和 signin 对象。
如果您查看帐户链接 documentation,您可以看到在帐户链接过程中提供了哪些参数。
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
的 google 对话流处理程序上使用了操作。在您的代码中,您使用 WebhookClient 对象来处理对话流意图。我不确定您是否可以使用 WebhookClient 对 google accountlinking 进行操作。
如果在更改 testSigninDate
函数参数后它仍然不起作用,可能值得尝试删除 webhookclient 并查看是否可以使用 app.intent()
调用来处理您的意图就像上面的代码示例一样。