I'm pretty sure the answer to this is "no" but I figured I'd share the question anyway in case others have a clever workaround :)
I'm building a recipe action so the user could say "Let's make tortilla soup" and then say "next step" to move on to the next part of the recipe. Between each step there might be a long pause as the user is cutting vegetables, etc. Is it possible to have Home either indefinitely wait for a user response or wait for several minutes? Currently it'll wait a few seconds and say something like "Sorry I didn't understand that response" and eventually quit the action.
Forcing the user to go through the "OK, Google, let me talk to the Chef" action over and over is pretty annoying and, I assume, would require immediately ending the conversation after every step, otherwise the device will hang and say "Sorry I didn't understand".
Update
I've found a pretty hacky way of doing this by abusing SSML. There are two options, you can stack up <break/>s
assistant.ask(`<speak><break time="120s"/><break time="120s"/></speak>`);
This actually causes the Home to play a really weird droning noise. Something the devs might wanna look at :D
Another option (which avoids the drone) is to play a 2 minute silent audio clip. According to the docs, 2 minutes is the limit for <audio> but you can stack them up. I just verified that you can make it sit there for at least ten minutes.
assistant.ask(`<speak><audio src="https://.../pause.mp3">hello</audio><audio src="https://.../pause.mp3"></audio></speak>`)
You cannot speak directly to the agent while its paused like this but you can say "OK Google, [whatever command]" and that command will actually get passed to the agent.
There's not currently a way to have the Assistant wait indefinitely for a response.
While technically possible, an app using the suggested workaround to delay responding wouldn't pass the review process - the policies document mentions avoiding playing a silent sound file and communicating for a period in excess of 120 seconds.
A different approach could be to have your app remember the current position in a recipe, but end the conversation after each step. You could then use action invocation to allow the user to say something like "OK Google, ask [your app name] to continue the recipe", jumping back into the conversation and hearing the next step.
There is not, but there is a recently announced feature that might help you do what you're trying.
When answering, you can give the reply and play an audio file using the Media Control. This has several advantages over using the SSML approach you give:
You'll get an event when the audio finishes, so you can prompt again with the guide, or a tip, or a reminder that your action is still there... and then play more audio while you wait.
At any time, the user can say "Hey Google, next step" and your server will get the message and you can send the next step. Or they can say "hey Google, repeat that" and you'll get that message and can repeat the instructions.
They can also ask other questions of your Action that you can answer.
Related
For the google actions that i am developing some responses are complex and take more than 5 seconds to process.
Could someone please suggest how can this be handled.
Generally i would consider using loading dots and then replacing that message with the result but i don't see any Google Action API for it. Also is there any endpoint to which we could async send back the result later ?
Thanks
PS: I am using Conversation API.
We don't really have a good way to handle this right now, but we have a couple of approaches that sorta work based on your needs.
Notifications are currently available for the Assistant on smartphones, and they're coming for speakers. In some cases, it might make sense to say that you're working on the problem and you'll send a notification when you have it, and then resume the conversation from the notification.
Another approach is to use the Media Response to play a bit of "hold music". At the end of the segment of music, your webhook will get a notice that the music has completed. If you have the result available, you can report it at that time.
In my conversation dialogflow, I would like to add some progress messages like hang in with me, I'm looking up for that data or similar in the conversation. Is there any guidance or best practice to do this?
Unfortunately, there is no good way to do this at this time. If your webhook takes longer than about 5 seconds, Dialogflow will return one of the default responses it is set with. If you're not using Dialogflow, the Action SDK will say your webhook isn't responding and will close the conversation.
There is currently no way to send a reply, and then send another reply without the user saying something first.
One workaround might be to have the default response be something like "I'm looking that information up. Ask me again in a few seconds." When your lookup finally completes, cache the information so when/if the user asks the question again, you can return it more quickly.
Depending how long it takes, you may also wish to register a dynamic reprompt. This will send an event to your webhook if the user doesn't say anything. In a situation like this, they may say nothing for a few seconds, but that may be long enough for you to have computed the reply. So after a few seconds of silence you can suddenly announce "I've figured it out, the answer you were looking for is..." or something similar. This has some limitations - you can only reprompt twice like this before Google sends you a final reprompt and closes the conversation.
Although the platform does support notifications, these are still in developer preview and don't work with all devices. They also don't quite continue the conversation (it doesn't just start talking) - they just send a notification to a phone that there is a message and that they can restart the conversation. Depending on your use case, this may be useful combined with the above.
Update
The Media Response includes a feature that we can take advantage of to handle this. Similar to the dynamic reprompt method above, you'll get a call automatically when the media you're playing ends. So you can play a short "hold music" and your webhook will be called when it is finished. You can then either give the result or say you're still working on it and play more hold music.
I am currently creating an app which should allow me to measure the time I take to do 50 pushups and save it to the database.
Currently when I am calling my app and saying "start" I create a timestamp and save it to the database. When I am finished I have to call my App again and say "stop" so it gets the last timestamp and calculates the difference.
Is there a better way to do this? It just feels so unnatural if you have to start the app twice. As far as I know there is no way to edit the "no-speak-timeout".
Thanks!
Not really. Keeping the microphone open indefinitely isn't possible, and would be a bad idea. While it might make some sense in this case, the potential for abuse is pretty high.
Users can setup a shortcut, so they could just say "Hey Google, start" and "Hey Google, stop" as shortcuts to the full phrase that would trigger your action, but the Assistant would still go through the entire routine when replying. (ie - it would say "Ok, getting pushup master" and the chirp before your action would reply.)
I'm trying to implement a basic but flexible "event queue" so that my web app can go run subs asynchronously. The way I have working for me now is the app writes a record to an "event queue" table in my database with info on what to do and when to fire. Then I have a daemon script that queries that table periodically and if something needs to be done, it fires it off.
I'd like to start moving towards watchers using something like AnyEvent or EV so I'm not hitting my database so often, but try as I might, I can't find good info on "best practices" for setting something like this up. AnyEvent's documentation is pretty good, but it seems to assume you know how your events should be passed around...which I don't.
What should my watcher be watching? A file? If so, what should be in that file? I don't need to send a whole bunch of data around, I just basically need something that says, "go off and run this sub right now"
I would greatly appreciate someone pointing me in the right direction.
EDIT:
It's been requested that I be more specific: The events I'm trying to fire are various. Sometimes it's an email that needs sending, sometimes it's some DB work, sometimes I just need an action to be delayed for a few hours or days. In all cases, I have some sort of backend script to handle the action, I just need a way for my frontend (web app) to tell my backend, "hey I need you to go do this in x minutes" or "I need you to do this now"
You might look at Mojolicious which is built to be non-blocking and respond asynchronously. It even uses EV internally if you have it installed. To get started read the doc for Mojolicious::Lite and then the Guides (in order) from here: http://mojolicio.us/perldoc
So what is it that you are actually trying to do? Until you describe what it is you actually need, I can't help you any further that that.
There are some CPAN modules in order to run asynchronous tasks via message queues. Examples:
Queue::DBI
POE::Component::MessageQueue
Any::MQ
Let's say, Tiny Tower. On this iPhone game, you can have shops in your tower. You can suspend or turn off the iPhone, but when you return to the game, you will be reported about the shop winnings during your time away.
There are also push notifications when a building is complete etc.
I fear I do not understand how that works, exactly. I'm not asking for the exact solution, I just need to know where to begin researching. One idea I had some time ago was like calculate the amount of seconds the user was away (current time minus the time when you left) and then calculate shop processing for every one of these seconds. But I'm not sure of that.
A better way would be to calculate before you close the app.
Figure out what time it is, then calculate when in the future certain tasks will be completed. This way, you can schedule push notifications to the server ahead of time.
If you calculate after you have re-opened the app, and you can't run processes with the app closed, how will it know when to push?
Take a look at this article about push notifications to understand a little bit better how they work.
http://blog.boxedice.com/2009/07/10/how-to-build-an-apple-push-notification-provider-server-tutorial/
For offline games you add temporal logic to your items and recalculate when game is launched. For online games you retrieve game state from the server, which is constantly recalculating for all users, even disconnected ones.
Game most probably does not actually process in the background (most apps are not allowed to do anything while in background). When you relaunch the game, it calculates how much time has passed, and then processes all the events that would have happened in the meantime.
Additionally, as Paul.s mentioned in comments below, as well as other people in other answers have suggested, on iOS4 you can use local push notifications scheduled before close.
It is either server side execution of the game or if it is a game of chance or something like Farmville where it's determined by time duration.
If you were to make a server and/or game like this then you would need to decide which route to take.
If it will be something where the user has good days and sometimes bad days then you'll need a lot more server power. however, if it's something like time based then you would be able to tell the last time they were logged in and the next time that they should be awarded. you can also take this idea and for each variable that you store, you store how long it takes to be complete and the start time. Then you would do a simple If then o see if the item is ready. The same thing can work for a number of visitors. Where you have 10 visitors per item per hour. If you have two items then each hour you will receive 20 visitors.