Prajval Raval
Prajval Raval

Reputation: 23

Google Action asking for parameters before account linking

I am using OAuth Authorisation Flow for my google action and for some reason, it is asking for parameters then initiating account linking and then asking for parameters again.

Example Response:

image image

Code

app.intent('Create Channel Intent', async (conv, params) => {

  if (!conv.user.access.token) {

    conv.ask(new SignIn());

  } else {

    var locale = conv.user.locale;

    if (locale === 'hi-IN') {

      var accessToken = conv.user.access.token;

      var channelNameRaw = params.channelname;
      var channelNameData = await helperFunctions.hinditranslate(channelNameRaw);
      var channelNameLwr = channelNameData.toLowerCase();
      var channelName = helperFunctions.replaceWhitespacesFunc(channelNameLwr);

      const headers = await helperFunctions.login(accessToken);
      const speechText = await helperFunctions.createChannel(channelName, headers);

      conv.ask(speechText);

    } else {

      var accessToken = conv.user.access.token;

      var channelNameRaw = params.channelname;
      var channelNameData = channelNameRaw.toLowerCase();
      var channelName = helperFunctions.replaceWhitespacesFunc(channelNameData);

      const headers = await helperFunctions.login(accessToken);
      const speechText = await helperFunctions.createChannel(channelName, headers);

      conv.ask(speechText);

    }

  }

});

Dialogflow

code code

Upvotes: 0

Views: 81

Answers (2)

YemG
YemG

Reputation: 11

I am %99 sure that your intent's sloth filling is off.

Your Create Channel Intent has channelname as required parameter. Without Sloth-filling, intents won't call your server/code until every required parameter is fulfilled.

What happening is:

  1. You are calling Create Channel intent and it asks for channel name as it is mandatory
  2. User gives a channel name, intent calls your code as all required parameters are fulfilled.
  3. Your code trigger sign_in intent as user haven't signed in yet.
  4. User gives permission which triggers actions_intent_SIGN_IN event
  5. Your Create Channel Intent has been called as it has actions_intent_SIGN_IN as trigger and asks for channelname as this intent is brand new.

To fix do one of this:

  • Enable sloth-filling at the bottom of intent.
  • Add an output context and add #[CONTEXT-NAME].channelname as default value to channelname parameter (without bracelets) . You can assign default values by clicking the appearing 3 dot when your mouse is over the parameter.
  • Split Capturing sign_in event from your Create Channel Intent

Hope it helps.

Upvotes: 1

hfurkanvural
hfurkanvural

Reputation: 590

You shouldn't add training phrase to your SignIn event intent. If the intent which asks for signin permission has training phares would be enough. Because it directs to actions_intent_SIGN_IN event and continues on there unless user didn't signed in yet. I guess you made these two action in one intent so this makes it confused and tries to call same intent and asks for parameters.

If you had to use this way try to use context so you can pass parameter values to this intent on second call.

Upvotes: 1

Related Questions