google action conversation exit: not waiting for user response - actions-on-google

I am trying to seek user feedback at the end of a google action session using actions sdk.
As per the Actions documentation (https://developers.google.com/actions/assistant/conversation-exits), I have set the cancel intent
"conversations" : {
...
"inDialogIntents": [
{
"name": "actions.intent.CANCEL"
},
...
and in my functions code I am calling a SimpleResponse as below:
app.intent('actions.intent.CANCEL', (conv, input) => {
conv.close(new SimpleResponse({
speech: 'Kindly rate between 1 and 5,
text: 'Rate between 1 and 5'
}));
});
When the user says goodbye, the above code gets called. The speech is heard and text displayed but the conversation immediately exits with an earcon.
The documentation mentions that the system will wait for 2 seconds before exiting but it seems to do so immediately. Is there a way to get this working? Thanks

It's not quite clear to me what you'd like to achieve. First of all, as long as you're using conv.close() method, you are ending the conversation. If you want to keep the mic open, you need to use conv.ask() method. But I'm not sure id you can use conv.ask() with actions.intent.CANCEL, because that event is there to get the user out, not to keep the conversation going. But I'm not %100 sure, you need to try it.
If what you're trying to achieve is something like this:
User: cancel
System: How would you rate our interaction?
User: Good.
earcon
Then, in my humble opinion, you probably shouldn't (and as I said you probably can't) do it. The docs clearly state that the purpose for custom exit behavior is:
to cleanup your fulfillment logic and respond to the user one last time.
Also, the docs doesn't say the system will wait for the user response for 2 second. It says the execution of the request (the time out for your fulfillment) is 2 seconds. Plus; if a user is canceling mid-conversation, chances are that the interaction was unsuccessful anyway. I'd rather create feedback dialog turns that are connected to the fallback intents and happy path(s).
Still, try to use conv.ask() instead and let me know if that works. (And please let me know by commenting.) Either case, though, I'd consider getting the feedback some other way.

Related

How to get "Area under aircraft unsuitable for landing" message?

When I initiate auto-landing in the DJI Fly app I sometimes get the following message, especially under bad lighting conditions:
Now, in my own code, when I call DJIFlightController.startLandingWithCompletion, the drone would not land and the completion block gets executed without any error.
My question is, how can I intercept the equivalent to DJIs error message as shown above? What code is relevant for that?
EDIT 1:
I am also checking if a landing confirmation is needed with the following code:
func observeConfirmLanding() {
guard let confirmLandingKey = DJIFlightControllerKey(param: DJIFlightControllerParamConfirmLanding) else { return }
DJISDKManager.keyManager()?.startListeningForChanges(on: confirmLandingKey, withListener: self) { (oldValue: DJIKeyedValue?, newValue: DJIKeyedValue?) in
DispatchQueue.main.async {
if let oldBoolValue = oldValue?.boolValue,
let newBoolValue = newValue?.boolValue,
oldBoolValue != newBoolValue {
self.landingConfirmationNeeded = newBoolValue
self.logger.debug("Landing confirmation is needed")
}
}
}
}
It never enters the closure.
As I understood the landing confirmation might be needed at a height of 0.3m, but in my case, the landing process gets interrupted at different heights that are more than 0.3m, e.g. already at 2m or 1.5m
EDIT 2:
I have changed the surface below the drone in my basement by adding a bright carpet with a distinct pattern. This improves the whole stability of the drone AND even more important: The drone just lands without being interrupted. I do not get the warning message in the DJI Fly app any more.
I check for isLandingConfirmation the way Brien suggests in his comment, I finally get true when testing this in the simulator.
extension FlightControllerObserver: DJIFlightControllerDelegate {
func flightController(_ fc: DJIFlightController, didUpdate state: DJIFlightControllerState) {
if (landingConfirmationNeeded != state.isLandingConfirmationNeeded) {
landingConfirmationNeeded = state.isLandingConfirmationNeeded
}
}
But, when I test this in my basement (flight mode "OPTI") and outside (flight mode "GPS") the drone just lands without waiting for any confirmation.
While I learned a lot, it is still a miracle to me which class in the DJI Mobile SDK is responsible for "throwing" that warning message.
If the completion handler completes without any error you might need to check if isLandingConfirmationNeeded in DJIFlightControllerState is set to true. If thats the case then you will need to implement the function confirmLandingWithCompletion.
Sounds relevant to your experience looking at the documentation
(void)confirmLandingWithCompletion:(DJICompletionBlock)completion Confirms continuation of landing action. When the clearance between
the aircraft and the ground is less than 0.3m, the aircraft will pause
landing and wait for user's confirmation. Can use
isLandingConfirmationNeeded in DJIFlightControllerState to check if
confirmation is needed. It is supported by flight controller firmware
3.2.0.0 and above.
The landingProtectionState property of the DJIVisionControlState class could be a good place to look for the cause of that error message. One of the potential states that sounds relevant is
DJIVisionLandingProtectionStateNotSafeToLand -> Landing area is not flat
enough to be considered safe for landing. The aircraft should be moved
to an area that is more flat and an auto-land should be attempted
again or the user should land the aircraft manually.
Also within a section of DJI's documentation there is a section on an article about flight control that talks about landing protection and forcing a landing. I couldn't see any functions in the SDK to force a landing.
You should be aware of that the fly app does not use the sdk internally. It uses the middlelayer directly.
You often get different behaivor when using the SDK compared to the app. Some functions are not available at all.
I usually disable it completly, I want it to land when I say so :-)
(exit_landing_ground_not_smooth_enable g_config.landing.exit_landing_ground_not_smooth_enable)

So I've mad a hug command but I would like it so it wouldnt # the person being hugged

So I've made a hug command that goes like <3hugs #thisperson (<3 is my prefix) and it will come out as #thisotherperson hugs #thisperson. And I would like it not to # the person getting hugged. because I want it so that if the bot gets hugged it responds. However because of the # it goes on a loop (which I fixed) but it says the response twice. I hope that made sense. Also, I am very new to coding and making a bot :p
I've tried using different terms, but ultimately i dont know what exactly i should use and i cant find it anywhere.
case 'hug':
if(!args[1]){
message.reply('who is this hug for?')
}else{
message.channel.send(`${message.author} huggies you, ${member} !!!!!`);
}
break;
bot.on('message', msg=> {
if (msg.isMentioned(bot.user)) {
msg.channel.sendMessage('AWWWWWWW!! THANKIES!! Love you too!!');
}
}); //... this is the code i use for the bots response
So I expected that if perhaps the bot gets chosen to be hugged in the <3randhug then it would have its own response. and it works fine, because the bot only gets # once. However, when a person choses to hug the bot it gets # twice.
Like
Sofira: <3 hug #cloudbot
Bot: Awwwwwww
Bot:#Sofira huggies you #cloudbot
Bot: awwwwwww
Alright, so you want the second "awwww" to not happen, right? Is there a way you can compare two different message authors? Like making the "awwww" block conditional. As an example, making it so that instead of just replying with "awwww" to every message that mentions it, making it only reply with awww to a member other than itself mentioning it. Also, without a conditional statement like that, even just a message like "#CloudBot" will still cause the whole "aww" response.

Dialogflow, Google Assistant: Getting error "MalformedResponse 'final_response' must be set"

I have three intents, "Cold Exposure", "Poisoning" and "Frostbite". Each intent has suggestion chips to move to the next intent, i.e. the "Cold Exposure" shows a chip of "Poisoning" and "Poisoning" shows a suggestion chip of "Frostbite".
All are follow up intents of the Default Welcome Intent, so all have the "Default Welcome Intent- followup" input context.
My problem is, when I call Cold Exposure and then call Poisoning, there's no problem. However, when I call Cold Exposure and then Poisoning, and then Frostbite, I get an error "MalformedResponse 'final_response' must be set." . Im not able to call any three intents back to back. I really dont know why this is happening.Im using v2 API.
This is the only error I have in my program, so it would be great if this could be solved quick.This is a screenshot of my intents.
What is the lifespan of the "Default Welcome Intent- followup" output context in the Default Welcome Intent?
By default, when you create followup Intents, the output context lifespan set in the root Intent is 2. Each action decrements this count and the context disappears when the count reaches 0.
Try increasing the lifespan (in the grey circle next to the output context name) to something like 10 (or any other number you see fit) and remove it manually when needed in later intents (by setting it as output context with a lifespan of 0).
Florent.
I actually wouldn't have expected that the followup intents would work the way you're trying. They're all followups to the original intent, rather than to each other. So it could be that the lifespan of the original intent's Context has expired by the third one. In this case, it would revert to the Fallback Intent.
But the reason for the error message itself is that you're not sending back a reply. If you're using a fulfillment, it means it isn't sending a reply. If you're not, it could be that the "Frostbite" Intent doesn't have a reply set or that your Fallback Intent doesn't have a reply set.

Moving from file-based tracing session to real time session

I need to log trace events during boot so I configure an AutoLogger with all the required providers. But when my service/process starts I want to switch to real-time mode so that the file doesn't explode.
I'm using TraceEvent and I can't figure out how to do this move correctly and atomically.
The first thing I tried:
const int timeToWait = 5000;
using (var tes = new TraceEventSession("TEMPSESSIONNAME", #"c:\temp\TEMPSESSIONNAME.etl") { StopOnDispose = false })
{
tes.EnableProvider(ProviderExtensions.ProviderName<MicrosoftWindowsKernelProcess>());
Thread.Sleep(timeToWait);
}
using (var tes = new TraceEventSession("TEMPSESSIONNAME", TraceEventSessionOptions.Attach))
{
Thread.Sleep(timeToWait);
tes.SetFileName(null);
Thread.Sleep(timeToWait);
Console.WriteLine("Done");
}
Here I wanted to make that I can transfer the session to real-time mode. But instead, the file I got contained events from a 15s period instead of just 10s.
The same happens if I use new TraceEventSession("TEMPSESSIONNAME", #"c:\temp\TEMPSESSIONNAME.etl", TraceEventSessionOptions.Create) instead.
It seems that the following will cause the file to stop being written to:
using (var tes = new TraceEventSession("TEMPSESSIONNAME"))
{
tes.EnableProvider(ProviderExtensions.ProviderName<MicrosoftWindowsKernelProcess>());
Thread.Sleep(timeToWait);
}
But here I must reenable all the providers and according to the documentation "if the session already existed it is closed and reopened (thus orphans are cleaned up on next use)". I don't understand the last part about orphans. Obviously some events might occur in the time between closing, opening and subscribing on the events. Does this mean I will lose these events or will I get the later?
I also found the following in the documentation of the library:
In real time mode, events are buffered and there is at least a second or so delay (typically 3 sec) between the firing of the event and the reception by the session (to allow events to be delivered in efficient clumps of many events)
Does this make the above code alright (well, unless the improbable happens and for some reason my thread is delayed for more than a second between creating the real-time session and starting processing the events)?
I could close the session and create a new different one but then I think I'd miss some events. Or I could open a new session and then close the file-based one but then I might get duplicate events.
I couldn't find online any examples of moving from a file-based trace to a real-time trace.
I managed to contact the author of TraceEvent and this is the answer I got:
Re the exception of the 'auto-closing and restarting' feature, it is really questions about the OS (TraceEvent simply calls the underlying OS API). Just FYI, the deal about orphans is that it is EASY for your process to exit but leave a session going. This MAY be what you want, but often it is not, and so to make the common case 'just work' if you do Create (which is the default), it will close a session if it already existed (since you asked for a new one).
Experimentation of course is the touchstone of 'truth' but I would frankly expecting unusual combinations to just work is generally NOT true.
My recommendation is to keep it simple. You need to open a new session and close the original one. Yes, you will end up with duplicates, but you CAN filter them out (after all they are IDENTICAL timestamps).
The other possibility is use SetFileName in its intended way (from one file to another). This certainly solves your problem of file size growth, and often is a good way to deal with other scenarios (after all you can start up you processing and start deleting files even as new files are being generated).

Timeline actions render incorrect verb tense for actions that end in the future

I am publishing actions for events to the timeline ("Dave attended...", "Dave is attending...") with start_time = {now}; end_time = {time of the event}
My intent is that the action will render as "Dave is attending..." up until the event takes place, and then "Dave attended..." once the event is over.
It seems like when I perform multiple actions, the tense is correctly chosen as "is attending". (This is the UI where the large app icon is used, and multiple actions are listed next to it.)
However, when I've only performed one action, FB renders uses the past tense verb. (This is the inline UI, using the small app icon inline with the action)
Am I doing something conceptually wrong, or is this just a bug in FB's rendering? Has anyone else seen this and found a fix/workaround?
Reposting my answer from here as it may also be useful to you.
If your start time is now, the easiest way is to specify "expires_in" as a POST variable. This is an optional parameter and will denote the duration (in seconds) for which your action should remain in the present tense.
From the documentation:
expires_in (integer)
The number of seconds before this action is considered “old”. From the
time the action until expires_in seconds have elapsed, the action is
considered “present tense”, and afterwards, it is considered “past
tense”.
expires_in is a shortcut for specifying end_time when it’s
more convenient to provide a delta in seconds between when an action
started and when it ends. For example, when a user starts watching a
movie, when you post a watch action, expires_in should be the length
of the movie in seconds.