How to use AccountLinking in ActionBuilder the correct way

account-linking
google-assistant

#1

Hi everyone,

First of all the account linking works. I just don’t know how I should structure the scenes the right way. Maybe somebody can give me some hints? It feels like there must be a simple explanation and I just can’t see it right now.

I checked the example from jovo on github.
And also the tutorial from google.

The jovo example is reduced to the minimum of showing account linking but the google docs say, don’t show account linking as your first step in an action. But where and how should that be implemented?

This is my current structure and I think I missunderstood something. Is it really the way to go to have two accountLinking scenes? It seems like google generates the second one with the name from the origin scene. Should there be an accountLinking scene for every scene that needs a login?

My current structure is the following:

  1. Innvocation
  2. MainMenuScene:
  • onenter -> webhook jovo -> ask with suggestions if user wants to go to account linking or the guestScene
  • GuestIntent -> GuestScene
  • UserIntent -> AccountLinkingScene
  1. AccountLinkingScene:
  • condition != verified -> GuestScene
  • condition == verified -> AccountLinkingScene_AccountLinking (auto generated system scene)
  1. AccountLinkingScene_AccountLinking
  • prompt (addition to the system prompt)
  • condition successful -> webhook jovo -> UserScene
  • condition dismiss -> prompt -> GuestScene
  • condition error -> prompt -> GuestScene
  1. UserScene
  • onenter -> webhook jovo -> should send the user suggestions what to do and asks for the next step.
  • different intents to go further

With this structure I get twice into “ON_SIGN_IN”. I think once from the AccountLinkingScene_AccountLinking condition webhook and once in the onEnter of the UserScene. I hoped for the “ON_SCENE” event and then from there to jump into an intent to send the right response.

Also somewhere in the docs it says the condition successful can transition back to the origin scene. But wouldn’t that end in a loop where the accountLinking will be called again?

Thank you for your help


#2

Hi, thanks for the detailed questions.

Could you provide the request json for both ON_SIGN_IN requests?


#3

Sure, here is the first request:

{
   "handler": {
      "name": "Jovo"
   },
   "intent": {
      "name": "",
      "params": {
         "AccountLinkingSlot": {
            "original": "",
            "resolved": "LINKED"
         }
      },
      "query": ""
   },
   "scene": {
      "name": "AccountLinkingScene_AccountLinking",
      "slotFillingStatus": "FINAL",
      "slots": {
         "AccountLinkingSlot": {
            "mode": "REQUIRED",
            "status": "SLOT_UNSPECIFIED",
            "updated": true,
            "value": "LINKED"
         }
      },
      "next": {
         "name": "UserScene"
      }
   },
   "session": {
      "id": "ABwppHEA3wz...9XxBdzEFO75jz-lEUrOnvNM5MP
      "params": {
         "_JOVO_SESSION_": {
            "new": false,
            "reprompts": {
               "NO_INPUT1": "<speak>Hello to your action.</speak>"
            },
            "createdAt": "2021-03-10T08:41:10.531Z"
         },
         "AccountLinkingSlot": "LINKED"
      },
      "typeOverrides": [],
      "languageCode": ""
   },
   "user": {
      "locale": "en-US",
      "params": {
         "userId": "23d1c0...dbb39afe0"
      },
      "accountLinkingStatus": "LINKED",
      "verificationStatus": "VERIFIED",
      "packageEntitlements": [],
      "gaiamint": "",
      "permissions": [],
      "lastSeenTime": "2021-03-10T08:41:41Z"
   },
   "home": {
      "params": {}
   },
   "device": {
      "capabilities": [
         "SPEECH",
         "RICH_RESPONSE",
         "LONG_FORM_AUDIO"
      ]
   }
}

and the second:

{
   "handler": {
      "name": "Jovo"
   },
   "intent": {
      "name": "",
      "params": {
         "AccountLinkingSlot": {
            "original": "",
            "resolved": "LINKED"
         }
      },
      "query": ""
   },
   "scene": {
      "name": "UserScene",
      "slotFillingStatus": "UNSPECIFIED",
      "slots": {}
   },
   "session": {
      "id": "ABwppHEA3wz...9XxBdzEFO75jz-lEUrOnvNM5MP
      "params": {
         "_JOVO_SESSION_": {
            "new": false,
            "createdAt": "2021-03-10T08:41:10.531Z",
            "reprompts": {
               "NO_INPUT1": "<speak>Hello to your action.</speak>"
            }
         },
         "AccountLinkingSlot": "LINKED"
      },
      "typeOverrides": [],
      "languageCode": ""
   },
   "user": {
      "locale": "en-US",
      "params": {
         "userId": "23d1c0...dbb39afe0"
      },
      "accountLinkingStatus": "LINKED",
      "verificationStatus": "VERIFIED",
      "packageEntitlements": [],
      "gaiamint": "",
      "permissions": [],
      "lastSeenTime": "2021-03-10T08:41:41Z"
   },
   "home": {
      "params": {}
   },
   "device": {
      "capabilities": [
         "SPEECH",
         "RICH_RESPONSE",
         "LONG_FORM_AUDIO"
      ]
   }
}

The Output from google Assistant is: “your signed in! let’s start at the main menu your signed in!”

“your signed in!” is defined in the ON_SIGN_IN function
“let’s start at the main menu” is defined in AccountLinkingScene_AccountLinking>Condition successfully > Prompt

My guess:
AccountLinkingScene_AccountLinking>Condition successfully > webhook Jovo > ON_SIGN_IN
AccountLinkingScene_AccountLinking>Condition successfully > Prompt
UserScene > onEnter > webhook Jovo > ON_SIGN_IN

and that’s why I think my structure is probably wrong :slight_smile:


#4

Hi @AlexSwe,

After some experimenting I think I found a solution.
First of all my structure was not right. I missunderstood the concept of the account linking scene. And second I think there is part of the condition missing in the google documentation. Because without this part, you end up in an infinit loop of calling the account linking.

Now my structure is like this:

  1. Innvocation
  2. MainMenuScene:
  • onenter -> webhook jovo -> sends suggestion chips for “guestScene” or “userScene” (needs account linking)
  • conditions
    • condition != verified -> GuestScene
    • condition == verified && user.accountLinkingStatus != “LINKED” -> MainMenuScene_AccountLinking (auto generated system scene)
  • GuestIntent -> GuestScene
  • UserIntent -> UserScene
  1. MainMenuScene_AccountLinking
  • prompt (addition to the system prompt)
  • condition successful -> webhook jovo -> MainMenuScene
  • condition dismiss -> prompt -> GuestScene
  • condition error -> prompt -> GuestScene
  1. UserScene
  • onenter -> webhook jovo -> works as intended

Lessons learned:

  • There is no need for a special custom accountLinkingScene. You just call the system AccountLinkingScene where ever you need it.
  • You need to extend the conditions with “&& user.accountLinkingStatus != “LINKED”” to prevent a loop.