Search code examples
loopsasynchronousactions-on-googlegoogle-home

Trigger action without user utterance


I want to write a Google Home action that tells the latest value of a field in a DB table. (Another service will keep updating the DB.)

How do I make Google Home speak the update automatically every 10 seconds without further user utterance after the Action is launched?

Interaction would be like this:
User: "OK Google, start Progress Updater"
Google Home: (Every X seconds) "10 percent."
Google Home: "19 percent"
...
Google Home: "100 percent."
Google Home: *"Task is complete!"
End of interaction

I know how to do it if a user has to say every time "Google Home, get me update". Is there a way to do it in an automatic loop?

Tried following code based on response from @Prisoner

conv.ask(new MediaObject({
    name: 'Jazz in Paris',
    url: 'https://storage.googleapis.com/automotive-media/Jazz_In_Paris.mp3',
    description: 'A funky Jazz tune',
    icon: new Image({
      url: 'https://storage.googleapis.com/automotive-media/album_art.jpg',
      alt: 'Media icon',
    }),
  }));
});

Solution

  • The best tool that we have to do this is the Media prompt.

    Under this scheme, when you return any progress except for "complete", you'll include a Media object with a 10 second audio. When the audio finishes playing, you'll get a MEDIA_STATUS result, indicating the audio has finished. You can then check the status and reply accordingly, possibly including another Media in your prompt.