0

Is it possible to trigger the accountlinking on an implicit invocated intent? (One which isnt the first intent that is triggered).

publish settings

When i publish my agent to actions on google with the above settings, i don't get a request to link my account if i trigger the selected intents. If i change the sign in required to the default welcome intent i do get the request.

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

Thanks in advance!

Jordi
  • 3,041
  • 5
  • 17
  • 36

2 Answers2

0

Yes, this is possible and that's what most apps do, show a welcome message and carry on a simple conversation without requiring to link account and when users want to use a service then request to link.

You need to set-up account linking as usual, check out this doc.

frunkad
  • 2,433
  • 1
  • 23
  • 35
  • Yeah, i've set this up and it works on the default welcome intent. It just won't trigger on other intents – Jordi Nov 07 '18 at 07:48
0

We fixed it by implementing our own sign-in using actions on google in the register intenthandler. Like such:

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;
    }
Jordi
  • 3,041
  • 5
  • 17
  • 36