Search code examples
actions-on-googleapi-ai

askForPermission not working on Actions on Google simulator


I am trying to get the current location of the user and I am using the Api.AI web tool to create my actions/intent.

Deployed using -

firebase --only functions

API.AI Action - enter image description here

Simulator - enter image description here

Full index.js - link

But when my action is triggered I get this message -

Sorry, this action is not available in simulation

Can't we ask for permission on a simulation ? Also how do I test my app on a real device ?

EDIT: The permission function is stuck in a loop -

enter image description here


Solution

  • Your problem is in this block of code:

    //Action business logic
    function welcomeMessage(app){
        app.tell('Welcome !, Do you want to book a ride ?'); // Todo: Insert proper messages.
    }
    

    The app.tell() method sends the message and then closes the conversation. If you want to send the message to the user and keep the conversation going (ie - you're expecting a response) you need to use app.ask().

    This is what is causing the "Sorry" message when you reply "Yeah" - your Action is no longer listening.

    You can ask for permission in the simulation. Once you have run it once in the simulator, you should be able to access it on any device that is linked to the same account you used to develop the Action, or to other accounts you've permitted (once they have run the simulator).