We are having a problem where saying things like "what is the weather" (something Google Assistant recognizes and is not in our intents) exits our action. We solved this with a fallback on the server/fulfillment side when we used Dialogflow, but now we switched over to Actions Builder and the problem is back.
How can we prevent it from closing our action?
This sounds like it may be related to recent announcements that, in some cases, phrases that don't match a specific Intent may cause your Action to close so the Assistant can handle the phrase instead. This will probably happen when the System NO_MATCH Intent gets matched, although Google has been vague on this point.
The workaround that they appear to have suggested is to create an Intent that can handle "free form text" or "any" input and route that input to your handler using this method. This means that one of your Intents will handle it, rather than falling back to NO_MATCH.
This involves:
Creating a new Type (I usually call it "Any") that accepts Free Form Text
Creating an Intent (which I have named "matchAny") that accepts values of this type through its training phrases (or even just one phrase that accepts a value of this type)
In your Scene, add this as an Intent that can be matched, and then set the handler for your webhook when it does.
Related
There have been triggering problems with my action since a few days ago. The queries that should have been handled by my action were routed to Google Assistant main flow. This happens on both Android Phone, and Google Home.
Steps to repro:
Speak: OK Google, talk to Tinker Doodle.
Assistant: Welcome to Tinker Doodle, what can I do for you?
Speak: Available commands.
Assistant: (Abruptly end Tinker Doodle conversation, list general commands on Assistant.)
I'd expect Assistant to stay in Tinker Doodle conversation, and feed the input to my action.
This makes Tinker Doodle almost unusable. Can you help with this?
I configured the NO_MATCH system intent to call my webhook, since I use my own NLP.
This worked well on Android Phone and Google Home, until a few days ago. There is no problem running in simulator on Action Builder.
Here are the screenshots of the main scene and NO_MATCH intent from Action Builder.
It isn't clear, but this sounds like it may be related to recent announcements that, in some cases, phrases that don't match a specific Intent may cause your Action to close so the Assistant can handle the phrase instead.
Even besides this, handling things with NO_MATCH is generally undesirable, since that will only happen three times in a row before the Action is forcibly closed.
Instead, you should create an Intent that can handle "any" input and route that input to your handler using this method. That involves:
Creating a new Type (I usually call it "Any") that accepts Free form text
Creating an Intent (which I have named "matchAny") that accepts values of this type through its training phrases (or even just one phrase that accepts a value of this type)
In your Scene, add this as an Intent that can be matched, and then set the handler for your webhook when it does.
Rather than using no_match, you can employ the design that the custom-nlu sample uses:
Have a 'Main' scene that tries to match on a user_utterance intent:
Then the user_utterance matches on everything using the any data type:
When you go to the Simulator, any query should match your intent explicitly and then, as part of the sample, it will echo your response:
I am developing action for assistant. I have intent in dialogflow that is fired correctly in simulator but does not get fired in a real device rather fallback intent is triggered ?
What puzzles me more is the intent works fine with one email id but does not work with another email id on the same device ?
I highly doubt the issue arising from language preferences.
It is really difficult to diagnose issues like this with only generic information. To really help, we'd need to see specifics of the Intent and examples where it doesn't get triggered where you expect it to. But a few things to consider:
If the sample phrase uses homonyms like "to/two/too" or "four/for", it can be picked up incorrectly.
You don't indicate if this is spoken or typed where you have the problem. You may want to look at the entries at https://myactivity.google.com/ to see how it hears what you're saying.
Check the Dialogflow "History" section to see if it provides any guidance on what it is getting and why it is choosing the fallback intent.
In the everyday front-end development I often use DOM as a global event bus that is accessible to every part of my client-side application.
But there is one "feature" in it, that can be considered harmful, in my opinion: any listener can prevent propagation of an event emitted via this "bus".
So, I'm wondering, when this feature can be helpful. Is it wise to allow one listener to "disable" all the other? What if that listener does not have all information needed to make right decision about such action?
Upd
This is not a question about "what is bubbling and capturing", or "how Event.stopPropagation actually works".
This is question about "Is this good solution, to allow any subscriber to affect an event flow"?
We need (I am talking about current usage in JS) stopPropagation() when we want to prevent listeners to interfere with each other. However, it is not mandatory to do so.
Actual reasons to avoid stopPropagation:
Using it usually means that you are aware of code waiting for the same event, and interfering with what the current listener does. If it is the case, then there may (see below) be a design problem here. We try to avoid managing a single thing at multiple different places.
There may be other listeners waiting for the same type of event, while not interfering with what the current listener does. In this case, stopPropagation() may become a problem.
But let's say that you put a magic listener on a container-element, fired on every click to perform some magic. The magic listener only knows about magic, not about the document (at least not before its magic). It does one thing. In this case, it is a good design choice to leave it knowing only magic.
If one day you need to prevent clicks in a particular zone from firing this magic, as it is bad to expose document-specific distinctions to the magic listener, then it is wise to prevent propagation elsewhere.
An even better solution though might be (I think) to have a single listener which decides if it needs to call the magic function or not, instead of the magic function being a stoppable listener. This way you keep a clean logic while exposing nothing.
To provide (I am talking about API design) a way for subscribers to affect the flow is not wrong; it depends on the needs behing this feature. It might be useful to the developers using it. For example, stopPropagation has been (and is) quite useful for lots of people.
Some systems implement a continueX method instead of stopX. In JavaScript, it is very useful when the callees may perform some asynchronous processing like an AJA* request. However, it is not appliable to the DOM, as the DOM needs results in time. I see stopPropagation as a clever design choice for the DOM API.
When designing an application's back-end you will often need to abstract the systems that do things from the systems that actually do them.
There are elements of this in the CQRS and PubSub design patterns.
By way of example:
A new user submits a registration form
Your application receives that data and pushes out a message saying “hey i have some new user data, please do something with this”
A listener / handler / service grabs the data and processes it
(please let me know if that makes no sense)
In my applications I would usually:
Fire a new Event that a Listener is set up to process Event::fire('user.new', $data)
Create a new Command with the data, which is bound to a CommandHandler new NewUserCommand($data)
Call a method in a Service and pass in the data UserService::newUser($data)
While these are nearly exactly the same, I am just wondering - how do you go about deciding which one to use when you are creating the architecture of your applications?
Fire a new Event that a Listener is set up to process
Event::fire('user.new', $data)
Event pattern implies that there could be many handlers, subscribing to the same event and those handlers are disconnected form the sender. Also event handlers usually do not return information to the sender (because there can be actually many handlers and there is a confusion about whose information to return).
So, this is not your case.
Create a new Command with the data, which is bound to a CommandHandler
new NewUserCommand($data)
Commands are an extended way to perform some operation. They can be dispatched, pipelined, queued etc. If you don't need all that capabilities, why to complicate things?
Call a method in a Service and pass in the data
UserService::newUser($data)
Well, this is the most suitable thing for your case, isn't it?
While these are nearly exactly the same, I
am just wondering - how do you go about deciding which one to use when
you are creating the architecture of your applications?
Easy. From many solutions choose only those, which:
metaphorically suitable (do not use events, where your logic does not look like an event)
the simplest (do not go too deep into the depths of programming theories and methods. Always choose solution, that lowers your project development complexity)
When to use command over event?
Command: when I have some single isolated action with few dependencies which must be called from different application parts. The closest analogue is some editor command, which is accessible both from toolbar and menu.
Event: when I have several (at least in perspective) dependent actions, which may be called before/after some other action is executed. For example, if you have a number of services, you can use events to perform cache invalidation for them. Service, that changes a particular object emits "IChangedObject" event. Other services subscribe to such events and respond to them invalidating their cache.
No offense, but I may be asking a strange question. I am a beginner, learning advanced OOP, and confused about a few concepts. Coming to the point. It may be ridiculous. But can someone tell me exactly and correctly what does callback literary mean? And how it differs from a proxy class in C++ which we use for information hiding. Apologies in advance, if I missused the terminology.
From Wikipedia:
A callback is a reference to executable code, or a piece of executable code, that is passed as an argument to other code.
As for proxy classes, see this question.
It's two different things. An instance of a proxy class can be used as callback, but that's about the only relation I can see between them.
The idea of a call back is to start some action then do something else until the action completes.
An example from the real world is to telephone the plumber for a repair. The plumber says they are currently at a work site and unable to see their schedule for the next day right now. However the plumber says that they will be in the office later and will be able to check their schedule. The plumber then promises to give you a call back once they are in the office and able to check the schedule. You could then either sit down next to the telephone and wait for the return telephone call (blocking call back) or read a book or paint the house until the plumber calls back (deferred call back).
In C, a callback function is a function body that is specified as a callback. The address of the function, a function pointer, is provided to the function being called to perform some kind of action. When the action is completed the callback function is invoked to do something, usually some form of cleanup and/or notification.
Normally a callback is used when a function is called to start some action and then returns immediately to the caller before the action completes and its result is known. The callback is used as a way to notify the result of the action when the started action is completed.
Another form of callback is to register a function for an event so that when the event happens, the function will be called to do something. So you might specify a callback for when a mouse click event is received.
A proxy class is a class that acts as an interface for a class. You could think of a proxy class as being similar to a stunt double who does the dangerous things for an actor. Or a proxy for a share holder's meeting is a person or organization who stands in for the actual share holder to perform specific duties for the share holder.
A callback is not a proxy though a callback may be used by a proxy as part of the functionality required to do its proxy duties.