基于隐式调用意图的帐户链接

Accountlinking on implicit invocation intent

是否可以根据隐式调用的意图触发帐户link? (不是触发的第一个意图)。

当我使用上述设置将我的代理发布到 google 上的操作时,如果我触发了选定的意图,我不会收到对 link 我的帐户的请求。 如果我将所需的登录更改为默认的欢迎意图,我会收到请求。

Is accountlinking on intents other than the main intent possible or do i need specific changes for this?

提前致谢!

是的,这是可能的,这就是大多数应用程序所做的,显示欢迎消息并进行简单的对话而无需 link 帐户,当用户想要使用服务时请求 link.

您需要像往常一样设置帐户 link,请查看此 doc

我们通过使用注册意图处理程序中 google 上的操作实现我们自己的登录来修复它。像这样:

CheckAccountLinking: async function(conv, input) {  
        if (!hasAccountLinked(conv)) {
            conv.ask(new actionsOnGoogle.SignIn());
            return;
        }

        conv.ask(`Continue message`);
    }

    const hasAccountLinked = function(conv)
    {
        console.log(`checking if account is linked`);
        console.log("Payload user:", conv.body.originalDetectIntentRequest.payload.user);
        const isLinked = conv.body.originalDetectIntentRequest.payload.user !== undefined && conv.body.originalDetectIntentRequest.payload.user.accessToken !== undefined;

        console.log("Has account linked", isLinked);
        return isLinked;
    }