23

I want to make google voice actions app for my Google Home. But, based on quick research, as of Dec 11, google does not allow private projects for Google Home.

References:

I understand that I can preview the app from API.ai project, and it deployes to the linked Google Home device.

API.ai preview

But the issue is, the deployed app does not persist. It is no longer available after hour or so. How can I make it permanent (if there is a way)?

UPDATE

Based on Leon's answer, I just wanted to extend the steps on how to enable the sample for 24 hours.

  1. Click on the "Google Home Web Simulator" link on bottom right corner.
  2. Then you will be presented with google home device - click on "Start" button on that page
  3. On next page, top right corner you have the "ACTION PACKAGE" button Leon is talking about. Click on that and extend expiration time by clicking on "Preview for 24 hours" button. See screenshot below:

Extend for 24 hours

Hossain Khan
  • 6,332
  • 7
  • 41
  • 55

3 Answers3

31

I have found a way to create the Action on API.ai and then preview it indefinitely.

From API.ai:

  1. Open browser dev console (Network tab)
  2. Go to Integrations
  3. Turn on "Actions on Google" integration
  4. Click "Authorize"
  5. Click "Preview"
  6. Inspect the XHR response from https://console.api.ai/api/agent/googleassistant/preview in the Network dev console

    {  
      "status":{  
      "code":401,
      "errorType":"unauthorized",
      "errorDetails":"You are not authorized for this operation. ",
      "webhookTimedOut":false
       }
    }
    
  7. Copy/paste the content of the response into a file called action.json

Then, download and install the gactions CLI from here - gactions CLI and then run this command:

gactions preview --action_package action.json --preview_mins 9999999 \
  --invocation_name [your_own_invocation_name_here] 

The preview_mins value of 9999999 makes the preview effectively indefinite.

Here is a video demonstrating it:

Export action.json from API.ai for Google Action

Prags
  • 2,457
  • 2
  • 21
  • 38
Brady Holt
  • 2,844
  • 1
  • 28
  • 34
  • 1
    This is why we can have nice things! Awesome sleuthing and write up. – sgriffinusa Dec 20 '16 at 16:46
  • Thanks for sharing hidden gem! Definitely takes the answer to next level. – Hossain Khan Jan 07 '17 at 05:12
  • Great!! Private actions there we go! – adrianlzt Jan 20 '17 at 09:33
  • 3
    The `gactions` utility appears to have been updated and no longer (silently) allows extended previews like this answer suggests. I have worked around this personally by creating a `crontab` entry that runs the command in this answer once every 24 hours. – dadykhoff Mar 07 '17 at 23:37
  • I had the opposite experience of @dadykhoff. I was able to use the trick in this answer just this week to set a preview that claims to expire in 2036. It has been working for a few days now without issue. – Wehrdo Mar 29 '17 at 01:02
  • Just tried this with gactions, my web simulator reads `Previewing until: 02/25/2019, 10:27 PM` – Air Apr 02 '17 at 17:23
  • 1
    As noted in my comment, the extended previews are disabled silently despite the output of the CLI command. I found mine to be removed about a week later. – dadykhoff Apr 03 '17 at 19:24
  • I can't yet comment if this still works, but the CLI message returned to me is: "... is now available for you until 2036-04-15 9:03PM BST (19 years from now)". Thanks for sharing! – kirgy Apr 11 '17 at 09:25
  • Today Google updated the Actions on Google SDK to v2 to support all the new features announced at IO. API.AI projects created before today are now considered 'legacy' apps and the answer here should work for another year while they support it. For anyone who goes this route starting a new project today they will be on v2 of the SDK and this solution is no longer valid (though a similar methodology works, see my other answer). – dadykhoff May 18 '17 at 02:04
8

As of today, May 17 2017, the highest voted answer to this question no longer works for new API.ai projects due to the upgrading of the Actions on Google SDK to v2. A similar methodology to @Brady's answer does work still, but they've made it more difficult in some ways (more information needs to be provided to Google, globally unique invocation name despite being a local only test), and better in others (gactions CLI docs now explicitly state that indefinitely timed previews are accepted, and actually is the default if not provided as a argument to the gactions test call).

  1. Create your API.ai agent as normal.
  2. Under the "Integrations" side menu, open the "Actions on Google" settings.
  3. Select "Test" from the bottom of the dialog box that appears (you may need to jump through a few hoops here, signing in, authorizing account access, etc.)
  4. This is where it gets a little different. You now need to create a project on the Actions on Google console. Create or import a project to the console.
  5. The first required step is to supply an action package, which can come from either API.ai or the SDK directly. For API.ai, you have to go back to the Integrations page we were at and press "Update" on your Actions on Google settings. (On the previous version of the SDK, this was labeled "Deploy" and would have made your app public, but don't worry - all this does now is update the AoG console. You publish publicly from the AoG console later if desired).
  6. This new console requires more information outright than was necessary before. I found that the "Assistant app name" can be whatever you want, but the "Pronunciation" is strictly limited to a few conditions (globally unique, reserved keywords, non-brand violating). I also found that I could still invoke using the app name and not just the pronunciation, but I suspect that will be fixed.
  7. Once you've filled out all the necessary information, you can test from API.ai. Return to the AoG settings menu in API.ai and retrieve the response content from the HTTP request preview (just like in @Brady's answer above). Here we hit another difference. The content of the request response can't be used directly in the action.json file as it is wrapped in another object. You want to use only the object from the property actionPackage. (i.e. remove

    {
      "actionPackage": 
    

    from the beginning of the content and

    }
    

    from the end). You should end up with a object of a structure similar to this (but maybe not exactly, it depends on the content of your API.ai agent):

    {
      "actions": [...],
      "types": [...],
      "manifest": {...},
      "conversations": {...}
    }
    
  8. Put this into your action.json file.

  9. Execute the new gactions CLI command:

    gactions test --project <your_project_name_from_aog_console> --action-package action.json
    
  10. Enjoy your local v2 Actions on Google SDK project! And pray Google does not alter the deal any further...

I tried my best to recall what I had to do from memory, so there may be some mistakes in this write up. Hopefully this helps someone.

dadykhoff
  • 423
  • 5
  • 15
  • Even this solution no longer works, as of February 17 2018. XHR response is empty so it is not possible to get action.json. – Lukas Novak Feb 17 '18 at 10:37
  • Turns out there's a MUCH simpler way to get the action.json file now! There's an "Export as zip" option in Dialogflow (previously api.ai) now that contains the action.json. Where to click to get it: https://imgur.com/gajaqZz – Ben Feb 12 '19 at 17:51
6

You can extend the time the development action can be previewed on the web simulator or Google Home device. After you preview the action from API.AI, click on the list of action packages in the web simulator. Then select the "Preview for 24 hours" link for your action package.

Leon Nicholls
  • 4,623
  • 2
  • 16
  • 17
  • Thanks Leon. This helps, I just want to impress my guests, and opening laptop and clicking on preview every time wasn't feasible. – Hossain Khan Dec 12 '16 at 20:20