Search code examples
node.jsdialogflow-esactions-on-googlegoogle-home

Dialogflow Webhook UpdatePermissions custom prompt


I'm currently trying to implement a prompt for push notifications in my dialogflow webhook. It works fine and sets the user up for push notifications if I implement it in the fashion described in the actions on google documentation (https://developers.google.com/actions/assistant/updates/notifications)

conv.ask(new UpdatePermission({
            intent: 'send_notification'
        }));

When the user activates this section of code they are prompted with

Is it okay if I send push notifications for my_updates_intent?

There is no problem with this message, however, I wish at the very least to prefix it with a message of my own so that I can display this prompt contextually, depending on where the user is within the conversational flow. For example:

Your email has been set. We can set up notifications to keep you informed. Is it okay if I send push notifications for my_updates_intent?

Or

No problem, we wont send you an email. If you are interested, we can set up notifications to keep you informed. Is it okay if I send push notifications for my_updates_intent?

Using the Permission constructor, the one UpdatePermission inherits, I can set a context that allows me to do just this.

conv.ask(new Permission({
    context: "So we can give you directions",
    permissions: ['DEVICE_PRECISE_LOCATION'],
});

Which will respond with:

So we can give you directions, I'll just need to get your street address from Google. Is that ok?

The first half of that message being something I wrote, and the second half coming from Google based on the type of permission I am requesting.

Logically I assumed that perhaps I could approach this by using the base Permission constructor with the permissions set to UPDATE:

conv.ask(new Permission({
    context: 'Your email has been set. We can set up notifications to keep you informed',
    permissions: ['UPDATE'],
    updatePermissionValueSpec: {
        arguments: undefined,
        intent: 'send_notification'
    }
}));

This, however, responds just the same as the UpdatePermission constructor and completely ignores my context. I have not been able to find any documentation or online resource that addresses this issue. Is it at all possible? or am I missing something obvious?


Solution

  • After contacting the actions on google support, I learned that customisation of the UpdatePermission message is not currently possible.

    From the support team:

    Unfortunately, altering this message is not possible for updates and push notifications. I'm adding this to our system as a feedback.

    Hopefully, this helps anyone else facing a similar issue.