Account Linking Actions On Google - dialogflow-es

After Sign is done, my output for "Get Signin" intent is not displayed.
Using Google-Sign in
app.intent("redeem", (conv) => {
conv.ask(new SignIn("To redeem "));
})
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} , how would you like to redeem? `)
conv.ask(new Suggestions(['QR code'], ['code']));
}
else {
conv.close("Please sign in to redeem");
}
})
After a successful sign in I get this message:
Dialogflow Get Signin (top part):
Dialogflow Get Signin (bottom part):

When the Sign-In completes, it triggers the actions_intent_SIGN_IN Dialogflow event. So your "Get Signin" Intent needs to have this set in the Event field, with no training phrases.
It might look something like this
Since you don't have an Event or Training phrases set, that Intent will never be triggered. Instead, when the Sign-in completes, Actions will send the Event, but since there is nothing setup to handle the event in Dialogflow, it will fail to do anything, so it will exit with the error about not responding.

Related

How to implement the 'Account Sign-in' helper in Google dialogflow? Getting a 'The agent returned an empty TTS'

I require Account linking for my chatbot and so I included the Account Sign-in helper as below -
const {dialogflow, SignIn} = require('actions-on-google');
const app = dialogflow();
app.intent('Default Welcome Intent', (conv) => {
conv.ask(new SignIn());
});
//I have an intent 'Get Signin' triggered by event 'actions_intent_SIGN_IN'
app.intent('Get Signin', (conv, params, signin) => {
if (signin.status === 'OK') {
const email = conv.user.email;
conv.ask(`I got your email as ${email}. 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 next?`);
}
});
When invoking my app, I get a 'The agent returned an empty TTS' response. What changes do I need to make?
Thanks in advance
The Authorization and Token Url are part of an Oauth process. It requires you to have your own service with user accounts to verify the user. If you don't have this I recommend you to use Google Sign-in instead, it is the easiest way of AccountLinking and should work out of the box. If you do need the OAuth sign-in, then I recommend you to read up on how OAuth works, because that is where the Authorization and Token Url are for.
When you setup acccountlinking correctly, the empty TTS should be fixed.

Asking for location permissions

I have an action that is requesting location, but I'm a little confused by the Dialogflow setup of this. This is my code:
app.intent('bus_stop_nearby_permission', (conv) => {
conv.ask(new Permission({
context: 'To get nearby bus stops',
permissions: 'DEVICE_PRECISE_LOCATION',
}));
});
app.intent('bus_stop_nearby', (conv, input, granted) => {
if (granted) {
conv.close(`Location was granted ${JSON.stringify(conv)}`);
} else {
conv.close(`Location was not granted!`);
}
});
In Dialogflow the initial intent bus_stop_nearby_permission is triggered by asking for bus stops near me with a training phrase, there is no event attached to this dialog. The follow-up intent bus_stop_nearby has the action_intent_PERMISSION event attached to it and no training phrases. Right now my action asks for permissions but doesn't understand any confirmation input, and just defers to the fallback intent when I say yes to it.
Screenshots of bus_stop_nearby intent:
Screenshot of bus_stop_nearby_permission:
Do I need to add follow up contexts for when the user approves the location request?
The event should be actions_intent_PERMISSION with an "s" at the end of "action".
Easy and common typo to miss.

Why doesn't the permission for a name work?

I'm trying to allow a permission in Google Assistant, but the simulator just asks to "repeat the answer" when asking for a name. Here is the code for permission.
app.intent('Default Welcome Intent', (conv) => {
conv.ask(new Permission({
context: 'Hi there, to get to know you better',
permissions: 'NAME'
}));
});
On deploying the code via Firebase, no errors are thrown.
Thanks in advance.
In your agent Default Welcome Intent is the intent which asks for NAME permission.
You will have to implement another intent to handle this permission. Lets call it user_info intent.
So when Actions On Google asks the question, and the user responds “yes” or “no” (grants or declines); Actions On Google will then send an event called “actions_intent_PERMISSION” to DialogFlow. We’ll use that event to trigger this particular intent. Once the intent is triggered, we’ll make sure to send the “user_info” action to our application.
In the application, we’ll register the “user_info” action and make sure to check whether the user has granted or declined the permissions. For that, we call the isPermissionGranted helper method.
app.intent('user_info', (conv, params, permissionGranted) => {
if (!permissionGranted) {
throw new Error('Permission not granted');
}
const {requestedPermission} = conv.data;
if (requestedPermission === 'NAME') {
conv.user.storage.name = conv.user.name.display;
return conv.close(responses.sayName(conv.user.storage.name));
}
throw new Error('Unrecognized permission');
});

DialogFlow NodeJs - Set Response Message after webhookClient.setFollowupEvent

I am using https://github.com/dialogflow/dialogflow-fulfillment-nodejs to create fulfillment webhook for dialogflow.
Currently I have intent that have 1 required parameter with prompt (so the agent will ask specific question for this parameter) and enable webhook call for this intent.
In the webhook, I check the parameter if that parameter is valid (call external api or something else), then I will trigger setFollowupEvent to move to other intent. But if the parameter is not valid, then I will trigger setFollowupEvent to return to this intent so the user should input it again. But I want to give the user a reason why that parameter is not valid.
The code is something like this
function registerUserStartHandler(agent) {
let payload = request.body.originalDetectIntentRequest.payload;
let senderDetail = getSenderDetail(payload);
return isUserRegistered(senderDetail.senderId, senderDetail.platformType).then((res) => {
if (res) {
agent.add('User already registered, enter another user');
//register_user_ask_user is this same intent (so I just returned to current intent if failed)
agent.setFollowupEvent('register_user_ask_user');
} else {
agent.setFollowupEvent('register_user_ask_other_info');
}
return Promise.resolve();
})
}
But, currently dialogflow will return to user the prompt message that I defined for that required parameter not the reason message.
How to replace this prompt message with my message from webhook?

Account linking Google actions via api.api

We are using api.api with fulfillment
After asking to sign in with the code:
app.askForSignIn();
We get intent call for input.unknown
We added sign handler but it is not called
const SIGN_IN = 'sign.in';
actionMap.set(SIGN_IN, signInLogic);
function signInLogic(app) {
let intent = app.getIntent();
console.log('signInLogic start intent: ', intent);
}
What needs to define in api.ai as intent to get the correct intent call?
I could not find a place to define system intents

Resources