Alexa sometimes not understanding city name - alexa

In my app, user has to tell the current city. My intent request is
{
"slots": [
{
"name": "cityName",
"type": "AMAZON.US_CITY"
}
],
"intent": "cityIntent"
}
And my utterances are
cityIntent my city is {cityName}
cityIntent my favorite city is {cityName}
cityIntent {cityName}
cityIntent change city to {cityName}
now when I am saying Alexa change city to Mumbai or My city is Miami, it is working fine but when alexa ask for the city name and I am replying with only city name like Mumbai Or Miami, it won't work. It calls for stopIntent

Amazon recently created a new slot type AMAZON.SearchQuery which would perfectly suit your problem.

Related

InvalidSlotTypeLiteral: Slot type "AMAZON.LITERAL" for slot "Text" in intent "RawText" is not valid

AMAZON.LITERAL is deprecated as of October 22, 2018. Older skills built with AMAZON.LITERAL.
What is the alternative to AMAZON.LITERAL, I want each and every word spoken by user from Alexa device in my endpoint API.
I have created custom slots, but my endpoint is not called everytime.
Anyone have solution to this?
You will not get the entire user input through any inbuilt slots or intents. The closest one to your requirement that I can think of is AMAZON.SearchQuery.
AMAZON.SearchQuery
AMAZON.SearchQuery is a phrase-type slot that lets you capture less-predictable input that makes up the search query. You can use phrase slots when you cannot predict all possible values the user might say, or when there may not be an identifiable pattern that can be captured by a custom slot. The intended use of this slot is to capture short messages, comments, search queries, and other short free-form text, not the entire user spoken utterance.
Ex:
{
"intents": [
{
"name": "SearchIntent",
"slots": [
{
"name": "Query",
"type": "AMAZON.SearchQuery"
},
{
"name": "CityList",
"type": "AMAZON.US_CITY"
}
],
"samples": [
"search for {Query} near me",
"find out {Query}",
"search for {Query}",
"give me details about {CityList}"
]
}
]
}
You cannot add sample intent utterances consisting of only phrase type slots.
That means, you cannot give something like this:
{
"name": "QueryIntent",
"slots": [
{
"name": "query",
"type": "AMAZON.SearchQuery"
}
],
"samples": [
"{query}" // utterance with only phrase-type slot
]
}
More on AMAZON.SearchQuery here
Alexa will always will fire a POST request to your skill's endpoint with a payload whenever there is a user interaction.

How to add validation on a slot value in alexa skill

I have a single intent in my skill NoteMyDetail which has three required slots: name, age, gender.
I have various utterances like "note my details", "note my name as {name}" etc.
So if I say "note my details" it one by one asks for all the values and if I say "note my name as Joe" it asks for only the age and the gender.
Now the issue I am facing is how to add validations for these slots because when Alexa asks: "what is your age" and I reply my name is Joe or any gibberish it sends a "?" in the slot value.
How do I make sure that the value is a number only for age?
EDIT: So I used the code of the link: https://gist.github.com/stormbytes/7ee3a05aa03c0ada0621dde746f2a6f9#file-index-js-L31
I have the slots as required, so it asks for all the values and then checks for the value which disrupts the flow, so I made the slot values as not mandatory and checked if the value if defined/undefined. I am getting the following response in the simulator but it says "There was a problem with the requested skill's response"
{
"body": {
"version": "1.0",
"response": {
"outputSpeech": {
"type": "SSML",
"ssml": "<speak> Sorry I did not get the age, please say it again </speak>"
},
"directives": [
{
"type": "Dialog.ElicitSlot",
"slotToElicit": "ageValue"
}
],
"reprompt": {
"outputSpeech": {
"type": "SSML",
"ssml": "<speak> Please tell me your age </speak>"
}
},
"shouldEndSession": false
},
"sessionAttributes": {},
"userAgent": "ask-nodejs/1.0.25 Node/v6.10.3"
}
}
This is a typical case where you can use a recently released feature called Slot Validation. All you have to do is go to the page where you defined your slot as required and click on the Validations tab:
and add a validation rule. In your case where you're dealing with age, most probably and AMAZON.Number, you can set up two rules, one for the lower limit of the age (e.g. 0) and another one for the top limit (e.g. 100). Take a look at my example using a numeric slot called ownedMiles:
Once you do that anything that is not a number within the range defined by the validation rules will cause the provided prompt in the validation to be spoken and Alexa will try to collect the value again.

Alexa is picking only US cities for city intent

I am developing an app for the weather where the user has to respond with the city name when alexa ask for. My city intent read like this
{
"slots": [
{
"name": "cityName",
"type": "AMAZON.US_CITY"
}
],
"intent": "cityIntent"
}
When user says only city name like San Francisco, Chicago or New York, it processed but if user is giving another city name like Mumbai, London, Manchester, it won't pick it up and directly go for stop intent. But if I am saying Change My City To Mumbai, then it is processing the city.
And Changed the AMAZON.US_CITY to AMAZON.GB_CITY too but it didn't work for me.

How can Alexa take a slot-only utterance?

I'm trying to write my first Alexa skill, but the application flow is a bit confusing, even reading all the documentation about dialogue delegation etc etc. I'd really love a bit of advice.
The Flow I'm Pursuing
"Alexa, start Movietime Quiz."
Welcome to Movietime Quiz. Before we begin, what team are you on: red or blue?
"Blue."
Blue was always the best team. Question 1: which of these films was not directed by Alfred Hitchcock? A: Vertigo, B: Rope, C: Happy Gilmore.
"C."
Correct! 10 points to the blue team. Question 2...
This is a boiled-down example to illustrate my problem in the shortest, clearest way, before you wonder why teams need to be involved in this.
My Instinct/Naive Approach
Have the initial launch-request handler say welcome-and-what-team, and then have two intents. The first would obviously be AnswerQuestionIntent, which listens for "A", "B", "C" or "D." The second would be SetTeamIntent, which listens for "red" or "blue."
I'd have an array with ~100 trivia questions. When the game starts, set a session attribute 'currentQuestion' to 0. In AnswerQuestionIntent, after handling the user's correct/incorrect response, increment that number, and if it's at 9, end the game; if not, ask a random question.
My Problem
I can't actually figure out how to have Alexa use a single slot as an utterance. I mean, I'd want to have a 'team' slot type (values 'red' and 'blue') and an 'answer' slot type (values 'A', 'B', 'C', and 'D'). SetTeamIntent should be activated by the utterance {team} and AnswerQuestionIntent by {answer}, but the developer.amazon.com skill builder gives me 'Bad Request' errors when I try to set that.
I tried looking at the SDK examples on GitHub, but I'm a bit lost because I've been using the GUI skill builder while learning and am not sure exactly how it maps -- not well enough to read the solution, anyway.
There is two different ways to handle this.
1. ElicitSlot Directive WITH Dialog Model
After you launch your skill and trigger an intent you can respond with a elicitslot directive.
Interaction Model: You define a slot and an intent, for example {team} and {answer} in PlayGameIntent. Provide utterances for the intent to get triggered, for example "start a game".
Skill: After triggering the PlayGameIntent. Return a response with a elicit slot directive. Something like the following.
{
"version": "1.0",
"sessionAttributes": {},
"response": {
"outputSpeech": {
"type": "PlainText",
"text": "What team are you on? Blue or Red? "
},
"shouldEndSession": false,
"directives": [
{
"type": "Dialog.ElicitSlot",
"slotToElicit": "team",
"updatedIntent": {
"name": "PlayGameIntent",
"confirmationStatus": "NONE",
"slots": {
"team": {
"name": "team",
"confirmationStatus": "NONE"
},
"answer": {
"name": "answer",
"confirmationStatus": "NONE"
}
}
}
}
]
}
}
The User can now provide an answer for the slot {team} and Alexa sends another IntentRequest for PlayGameIntent. You reelicit as many times as you need until your game is finished.
2. Custom Intents WITHOUT Dialog Model
Without using the Dialog Model you have no restriction with only-slot-utterances. You can build your intent schema as you described. If you leave the Skill Builder Beta you automatically disable the Dialog Model for your Interaction Model.
You can then build an intent schema with sample utterances like this:
AnswerQuestionIntent {answer}
SetTeamIntent {team}

How do i extract the original date value passed from the user input

Context:
The Watson Conversation bot has a node that gets triggered by three input entities from the user, this works fine, but i want the reply from the bot to be
"Checking if you have a lecture tomorrow. Give me a moment"
then there's a query in the background building up the answer that gets replied later to the user.
the strong word tomorrow is an #sys-date entity, but i want it to reply to the user what he/she said instead of the date, because the bot can check no both weeks months ect, all valid date formats, and the reply would look much better if i could use the original text from the user.
This kind of origin retrieval will be used for other entities aswell when i get it working.
You can use the context variable in the case, and if you want to get specific data, you can use regex to extract the user input:
Example all user input
"date": "<? input.text?>"
or for exactly what the user input, ex: "this week"
"date": "<?#sys-date.literal?>"
Etc..
Use the variable with the .literal, see my complete example:
{
"context": {
"date": "<?#sys-date.literal?>"
},
"output": {
"text": {
"values": [
"Checking if you have a lecture $date. Give me a moment."
],
"selection_policy": "sequential"
}
}
}
Documentation examples
:

Resources