Handle No Match input with custom logic in Confirmation Intent using Actions SDK - actions-on-google

When I use the Confirmation Helper Intent on an Actions SDK project, it works as it's supposed to. But I want to handle the case when the user's input doesn't mean either yes or no (a No Match situation). Currently Assistant automatically re-prompts the user in this situation.
Actions SDK provides the user's actual input when a confirmation is granted or denied. But is there any way to know what the user said in a No Match situation?
For example, let's say, in a Confirmation prompt, the user says: "I just need some eggs. Just give me some eggs". This would cause Assistant to show the same prompt to the user again. It happens automatically and I have no way of accessing what the user actually said. If I want to do something when the user says "I just need some eggs" I can't do it because I can't access what the user is saying. Moreover, I haven't seen any Intent getting fired in this situation.
So, how can I handle No Match situations with custom logic instead of giving the default re-prompt to the user?

The easiest way is to not use the confirmation helper and just create Intents that handle "yes" or "no" equivalents yourself.

Related

Main differences between a Smart Home action and a DialogFlow action

I'm just trying to figure out the main differences between these two types of actions. I mean a action that's use DialogFlow seems to be more conversational and more customizable. How does the Smart Home action handle the conversation? Is that a standard conversation based on the target device type?
When to create a Smart Home action and when to use DialogFlow?
To understand the difference, you need to understand the difference between a smart home action and a conversational action.
Conversational Actions
This is where the user initiates a conversation with "talk to X". Your action gets a WELCOME event. Then the user says more things and your action needs to process the user query and provide a text-based response.
Smart Home Actions
With the smart home integration, the user just gives a command directly. "Turn on my lights," for example, without precluding that with a "talk to" statement. Another big difference is that Google processes the user's query directly. Your smart home action does not get the user's text. Instead, there's a JSON request that specifies the user's intent.
The text that comes back is generated from Google as well, with parameters from your integration. Saying "turn on my lights" will result in "Ok, turning on lamp" or "Sorry, your lamp is offline" depending on what response your fulfillment sends.
There are a number of device types supported out of the box, as well as many traits. Traits specify the types of things that a device can do, such as turning on/off, or changing color. The traits are not explicitly tied to type, eg. you could change the color of a vacuum.
When to use each
If you're building or integrating a device that is meant to work with the Google Assistant, I'd suggest you look at smart home first. It will give users a better experience in being able to directly send queries, and it will make it easier for you to build fulfillment as the requests are structured already.
However, if it will not work for your application, you would want to look at Dialogflow, which will give you a greater level of flexibility in what the user can say.

Required parameters - Either/Or

I created an "intent" that I want to collect some contact information from. I want either their phone number or email address. As most users don't want to give both, I want to make it required that they share one of the other.
Is there a way to do this from the web app? Is there a way to accomplish this thru fulfillment code? or is there any other way to achieve this?
The either/or (or better put the if/else) logic can be achieved via follow up intents like this:
Create an intent and ask your user if they rather give you their phone or their email
Create a follow up intent for when the user replies with 'email' and another follow up intent for when the user replies with 'phone'. At the 'Responses' in each intent, ask for the user's email or address accordingly and then follow up the conversation as you'd do with any other intents.
To create follow up intents, hover over an intent at the intents page and click at the 'Add follow up intent' option.
If there isn't a screen input, consider that it may be difficult for the user to input their emails so make sure you do appropriate checks that it is a valid email format and of course ask your users for confirmation (ex. the submitted email is xyz#app.com. Shall I proceed?)
In a given intent, you can enable "use webhook for slot-filling" to have Dialogflow call your webhook each time the intent is matched.
https://dialogflow.com/docs/fulfillment#slot_filling
In your fulfillment code, you can check the presence of either parameter and respond appropriately if neither is provided.

Is it possible to save a custom variable for each user on their account?

I just got starte with programming a Facebook app. I already wrote an app for the VZ-Network, and there they have something called 'Persistant Storage'. Basically its an environment where you can save custom data on each user account. With your app you can read this data from the current user as well as from the users friends. Now I want to port my app to Facebook and my problem is that I didn't find such functionality here yet.
For now I would like to finish and launch this as soon as possible, so it would be nice if I could c&p as much of the code as possible.
Since the data is contains information about participation, at some point I would like to use the Facebook event object. But I was wondering if that could cause problems since it would require to create those events publically in order to use them in my app. Couldn't that lead to legal problems when I create such events with those who actually host the events in the real world? Would I have to ask the hosts to create those events, could I automate this process, or in case they don't have a Facebook account ask them to approve that the app creates the event for them?
I also need to know in what events the users friends participate, so I can't simply save the information on my server, since I don't have the friend info there.
In any case, it seems much easier to me to simply use a list of EventIDs on each user account to check whether or not the user participates in an event.

When a Facebook user sends the Send dialog within an application, can the application track the recipients?

When users open a Send dialog (e.g. http://www.facebook.com/dialog/send?app_id=123050457758183&name=People%20Argue%20Just%20to%20Win&link=http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html&redirect_uri=http://www.example.com/response) they can add or remove people from the To: line.
Is there a way for the application to track who was in the To: line if and when the user actually pushes Send?
No.
At least not currently...
If you look at the official documentation: https://developers.facebook.com/docs/reference/dialogs/send/ then you can see that this type of dialog does not expect a callback function as a parameter, and since there's no callback function then you have no way of knowing who and/or how many recipients were, and even if the dialog is closed/canceled/sent.
What you can do, though seems very complicated and well, a headache, is to use the outbox connection of the User object in the graph api (http://developers.facebook.com/docs/reference/api/user/).
I've never used that before, but I guess that you can (if you ask for the read_mailbox permission) check the user messages before and after the dialog, and see what changed.

How do I get a user's email address (with permission) on iPhone?

Typing on iPhone is tedious; I'd like to prompt my users for their email address without requiring them to actually type it.
Ideally they'd receive a dialog saying: "This app would like to use your email address. Don't Allow / Allow"
If the user tapped "Allow," it would auto-fill their email address (the one they have configured in Mail.app) in a text field.
Is this possible?
Nope. But you can load up the contact picker interface and ask the user to select themselves from it-- that's much more friendly than making them type it in.
More info here:
http://developer.apple.com/iphone/library/documentation/ContactData/Conceptual/AddressBookProgrammingGuideforiPhone/200-QuickStart/QuickStart.html
Yes it is possible, have a look at ABGetMe for iOS. Note that you would have to write the allow/don’t allow dialog yourself. Also, make sure to read and understand the Limitations section of the README.