API.AI with google assistant - phone number capture problems - dialogflow-es

We are trying to capture a phone number. Actually many other numbers, like amounts, zip, etc. We are using Google Home.
The below urls are JSON payloads we received on the fulfillment side. The entity name is TheNumber.
One JSON is when we setup the entity as #sys.number the other JSON when it was #sys.phone-number.
https://s3.amazonaws.com/xapp-bela/gh/number-test.json
https://s3.amazonaws.com/xapp-bela/gh/phone-number-test.json
The first problem is that the google assistant is really struggling to recognize number sequences, like phone numbers or zip codes. But even when it gets it right (according to the originalRequest in the JSON payload), the entity still has the wrong value when it arrives to the fulfillment side.
I guess my question is what am I doing wrong? Is anybody seeing the same problems?

Not sure this will help since this is more about talking to the Google Home device but.... I too was having a similar issue with a long number. If you use #sys.number-sequence as part of your Intent's context, this will allow you to recite much longer numbers without the device interrupting you. In your NodeJS code, you can grab the argument for that number-sequence for use in your Google Home agent.
if (assistant.getArgument('number-sequence') != null) { <do something> }

Related

How to redirect to another intent within a Google Action (Google Assistant Action)

Currently I'm creating an Action for the Google Assistant.
In this Action, I ask the user to provide its phone number. After this, another intent will repeat the phone number given, and asks if it's correct. If the user responds with 'no', I would like to redirect the user back to the first intent, so it can provide its phone number again. It should be a kind of loop.
(I'm working in a local environment, so only the intents are created within Dialogflow.)
I tried to apply contexts for this case, but in someway it won't succeed.
Thank you guys!
Remember that Intents represent what the user has said, and not what you are doing with that data. So saying that "another intent will repeat the phone number" suggests that you're making some things more complicated.
A better design is likely to have the Intent that collected the data to several things:
Repeat the phone number back
Prompt if this is correct
Set a content indicating you have prompted for confirmation
You can then have another Intent handle the "yes" or "no" statements responding to this prompt. The user may say other things, remember, including giving a correction to the phone number.
See also these articles (based on a StackOverflow question and answer) on designing a conversation and the Dialogflow Intents based on that conversation:
Thinking for Voice: Design conversations, not logic
Conversation to Code (Part 1)

RichResponse VS basicCard order

I'm facing a quite annoying issue with the Actions On Google SDK.
I want to send to the user these things in this order :
A basic card
A text
A suggestion chip
I simply did this :
let richResponse = assistant.buildRichResponse();
richResponse.addBasicCard( ... );
richResponse.addSimpleResponse( ... );
richResponse.addSuggestions( ... );
Problem is, no matter the order set in my code, google will always send the simple response before the card.
If i log the JSON before sending it, the card is indeed AFTER the message.
I tried to simply switch them in the JSON before sending it but then the assistant simply crashes.
All in all, i see no option to achieve what i want :/
If i could send a 1 item carousel i wouldn't need all that, but it's apparently impossible to send such carousel because the assistant also crashes.
If i could add buttons with JSON payload instead of external URL in BasicCard i could also workaround all these issues, but that's not possible either... I feel quite stuck.
Anyone has a workaround ?
Regards
The RichResponse object requires that the first item in the response be a SimpleResponse object, so you need some text first.
However, you are allowed to have two SimpleResponse objects, so you can try adding a SimpleResponse, the card, another SimpleResponse, and then the suggestions.
It isn't clear how being able to have just one option would let you work around this (although I agree). You would still need a SimpleResponse that appears before the option.
It isn't clear what you mean by "buttons with JSON". In this sense, suggestion chips work exactly the same way options do - they send something back to your webhook (options send the tag, while the suggestion chips send their contents).

How to send multiple statements in google assistant app?

I am creating a Google Assistant app for telling quotes, I am currently using Api.ai with ApiAi NodeJs webhook. I wanted that my response should be in this way:
Innovation is the only way to win.
By Steve Jobs
Want one more?
Note that all the three lines are different lines. I know it is possible if I just use api.ai's ux without webhook (using multiple Simple Response) but I cannot figure out how to do it when combined with webhook.
I tried:
assistant.ask("Innovation is the only way to win.");
assistant.ask("By Steve Jobs");
assistant.ask("Want one more?");
But it seems to speak only the first sentence. I also tried by replace it with:
assistant.tell("Innovation is the only way to win.");
assistant.tell("By Steve Jobs");
assistant.ask("Want one more?");
But it exits just after the first statement. How to do it?
Both ask() and tell() take their parameters and send back a response. The only difference is that ask() keeps the conversation going, expecting the user to say something back, while tell() indicates the conversation is over. If you think of this in terms of a web server, both ask() and tell() send back the equivalent of a page and then close the connection, but ask() has included a form on the page, while tell() has not.
Both of them can take a RichResponse object, which may include one or two strings or SimpleResponse objects which will be rendered as chat bubbles. You can't do three, however, at least not according to the documentation. So it sounds like your best bet will be to include one SimpleResponse with the quote and attribution, and the second with the prompt for another.
This also sounds like a case where you want the audio to be different than the displayed text. In this case, you'd want to build the SimpleResponse so it has both speech fields and displayText fields.
That might look something like this (tho I haven't tested the code):
var simpleResponse = {
speech: 'Steve Jobs said "Innovation is the only way to win."',
displayText: '"Innovation is the only way to win." -- Steve Jobs'
};
var richResponse = assistant.buildRichResponse();
richResponse.addSimpleResponse(simpleResponse);
richResponse.addSimpleResponse('Do you want another?');
assistant.ask( richResponse );
This will also let you do things like add cards in the middle of these two blurbs that could, for example, contain a picture of the person in question. To do this, you'd call the richResponse.addBasicCard() method with a BasicCard object. This might even be better visually than including the quote attribution on a second line.
As for design - keep in mind that you're designing for a wide range of devices. Trying to focus on the line formatting when you have display modes that are different (and sometimes non-existent) is of questionable design. Don't try to focus on what the conversation will look like, instead you should focus on how much the conversation feels like a conversation your user will have with another person. Remember that voice is the primary means of this conversation with visual intended to supplement that conversation, not rule it.
From what I can gather from the documentation, .tell and .ask both close the mic. Try putting all of your statements into one string. As far as I can tell, .ask doesn't actually affect the tone of the speech; it just tells Assistant to wait for input.
assistant.ask("Innovation is the only way to win. By Steve Jobs. Want one more?");

Sending specific words to webhook

I'm trying to make an agent that can give me details about movies.
For example, the user says "Tell me about (movie-name)", which sends a post request to my API with the (movie-name) which then returns the response.
However, I don't understand how to grab the movie name from the user's speech without creating a movieName entity with a list of all the movies out there. I just want to grab the next word the user says after "tell me about" and store it as a parameter. How do I go about achieving that?
Yes, you must create a movieName entity, but you do not need to create a list of all movies. Maybe you are experienced with Alexa which requires a list of suggested values, but in api.ai you don't need to do that.
I find that api.ai is not very good at figuring out which words are part of a free-form entity like movieName, but hopefully adding enough user expressions will help it with that.
edit: the entity I was thinking of is '#sys.any' but maybe it would be better to use a list of movie names with the 'automated expansion' feature. I haven't tried that, but it sounds like the way that Alexa's custom slots work, which is actually a lot more flexible (just using the list as a guideline) then people seem to think.

Parse text of a Received SmsTool3 & eventhandler

I am searching this forum(and others) and I can't find how exactly the eventhandler of the SMSTools works. How does it know when it's receiving or sending in order to take an action? Think is better to explain what I want.
I want to use the eventhandler in this scenario:
I am using a IDS which is sending information by SMS via smstools. Everything is ok by now, I am receiving what I need.
The problem is that when the smstools is receiving an SMS, I want to check if it's from the correct phone number (mine for example or a list of numbers would be better).
If it's the correct number, I want to see the text (the text will pe simple, like: yes or no) and take an action depending on it.
I will really appreciate any answer.

Resources