To Capture Multiple Sentences:
Use this hack created by my colleague Bryan Colligan.
How it works
The hack uses slot type CONTENT_LIST
with "value": "all"
to capture any word. By creating sample utterances which include multiple capture all slots for example "{WordI} {WordII} {WordIII} {WordIV} {WordV} {WordVI} {WordVII} {WordVIII} {WordIX}"
you can capture sentences of varying length with relative ease.
Note: In my experience Amazon's "Search Query" is limited to 5-6 words.
Warning: Amazon's transcriptions are pretty bad, so don't be surprised if what you capture is somewhat unreadable. This shortcoming is likely one reason Amazon does not reveal its transcripts. Google is much further ahead in Voice to Text. I'm sure in the future Amazon will release the transcripts when they feel more comfortable with their technology.
The code
The following code will concatenate multiple slots. It can be placed in your lambda function.
let querySentance = '';
let wordSlots = ["WordI", "WordII", "WordIII", "WordIV", "WordV", "WordVI", "WordVII", "WordVIII", "WordIX", "WordX", "WordXI", "WordXII", "WordXIII", "WordXIV", "WordXV", "WordXVI", "WordXVII", "WordXVIII", "WordIXX", "WordXX", "WordXXI", "WordXXII", "WordXXIII", "WordXXIV", "WordXXV", "WordXXVI", "WordXXVII", "WordXXVIII", "WordIXXX", "WordXXX",];
wordSlots.forEach((word)=>{
let slot = this.event.request.intent.slots[word];
if (slot !== undefined && slot.value !== '' && slot.value !== '?' && slot.value !== null && slot.value !== undefined){
querySentance = querySentance+' '+slot.value;
}
});
The following Interaction Model uses CONTENT_LIST
and "value": "all"
to capture any word.
{
"interactionModel": {
"languageModel": {
"invocationName": "alpha voice",
"intents": [
{
"name": "AMAZON.CancelIntent",
"samples": [
"cancel"
]
},
{
"name": "AMAZON.HelpIntent",
"samples": [
"help"
]
},
{
"name": "AMAZON.StopIntent",
"samples": [
"stop"
]
},
{
"name": "OzIntent",
"slots": [
{
"name": "Query",
"type": "AMAZONSearchQuery"
},
{
"name": "WordI",
"type": "CONTENT_LIST"
},
{
"name": "WordII",
"type": "CONTENT_LIST"
},
{
"name": "WordIII",
"type": "CONTENT_LIST"
},
{
"name": "WordIV",
"type": "CONTENT_LIST"
},
{
"name": "WordV",
"type": "CONTENT_LIST"
},
{
"name": "WordVI",
"type": "CONTENT_LIST"
},
{
"name": "WordVII",
"type": "CONTENT_LIST"
},
{
"name": "WordVIII",
"type": "CONTENT_LIST"
},
{
"name": "WordIX",
"type": "CONTENT_LIST"
},
{
"name": "WordX",
"type": "CONTENT_LIST"
},
{
"name": "WordXI",
"type": "CONTENT_LIST"
},
{
"name": "WordXII",
"type": "CONTENT_LIST"
},
{
"name": "WordXIII",
"type": "CONTENT_LIST"
},
{
"name": "WordXIV",
"type": "CONTENT_LIST"
},
{
"name": "WordXV",
"type": "CONTENT_LIST"
},
{
"name": "WordXVI",
"type": "CONTENT_LIST"
},
{
"name": "WordXVII",
"type": "CONTENT_LIST"
},
{
"name": "WordXVIII",
"type": "CONTENT_LIST"
},
{
"name": "WordIXX",
"type": "CONTENT_LIST"
},
{
"name": "WordXX",
"type": "CONTENT_LIST"
},
{
"name": "WordXXI",
"type": "CONTENT_LIST"
},
{
"name": "WordXXII",
"type": "CONTENT_LIST"
},
{
"name": "WordXXIII",
"type": "CONTENT_LIST"
},
{
"name": "WordXXIV",
"type": "CONTENT_LIST"
},
{
"name": "WordXXV",
"type": "CONTENT_LIST"
},
{
"name": "WordXXVI",
"type": "CONTENT_LIST"
},
{
"name": "WordXXVII",
"type": "CONTENT_LIST"
},
{
"name": "WordXXVIII",
"type": "CONTENT_LIST"
},
{
"name": "WordIXXX",
"type": "CONTENT_LIST"
},
{
"name": "WordXXX",
"type": "CONTENT_LIST"
}
],
"samples": [
"{WordI}",
"{WordI} {WordII}",
"{WordI} {WordII} {WordIII}",
"{WordI} {WordII} {WordIII} {WordIV}",
"{WordI} {WordII} {WordIII} {WordIV} {WordV}",
"{WordI} {WordII} {WordIII} {WordIV} {WordV} {WordVI}",
"{WordI} {WordII} {WordIII} {WordIV} {WordV} {WordVI} {WordVII}",
"{WordI} {WordII} {WordIII} {WordIV} {WordV} {WordVI} {WordVII} {WordVIII}",
"{WordI} {WordII} {WordIII} {WordIV} {WordV} {WordVI} {WordVII} {WordVIII} {WordIX}",
"{WordI} {WordII} {WordIII} {WordIV} {WordV} {WordVI} {WordVII} {WordVIII} {WordIX} {WordX}",
"{WordI} {WordII} {WordIII} {WordIV} {WordV} {WordVI} {WordVII} {WordVIII} {WordIX} {WordX} {WordXI}",
"{WordI} {WordII} {WordIII} {WordIV} {WordV} {WordVI} {WordVII} {WordVIII} {WordIX} {WordX} {WordXI} {WordXII}",
"{WordI} {WordII} {WordIII} {WordIV} {WordV} {WordVI} {WordVII} {WordVIII} {WordIX} {WordX} {WordXI} {WordXII} {WordXIII}",
"{WordI} {WordII} {WordIII} {WordIV} {WordV} {WordVI} {WordVII} {WordVIII} {WordIX} {WordX} {WordXI} {WordXII} {WordXIII} {WordXIV}",
"{WordI} {WordII} {WordIII} {WordIV} {WordV} {WordVI} {WordVII} {WordVIII} {WordIX} {WordX} {WordXI} {WordXII} {WordXIII} {WordXIV} {WordXV}",
"{WordI} {WordII} {WordIII} {WordIV} {WordV} {WordVI} {WordVII} {WordVIII} {WordIX} {WordX} {WordXI} {WordXII} {WordXIII} {WordXIV} {WordXV} {WordXVI}",
"{WordI} {WordII} {WordIII} {WordIV} {WordV} {WordVI} {WordVII} {WordVIII} {WordIX} {WordX} {WordXI} {WordXII} {WordXIII} {WordXIV} {WordXV} {WordXVI} {WordXVII}",
"{WordI} {WordII} {WordIII} {WordIV} {WordV} {WordVI} {WordVII} {WordVIII} {WordIX} {WordX} {WordXI} {WordXII} {WordXIII} {WordXIV} {WordXV} {WordXVI} {WordXVII} {WordXVIII}",
"{WordI} {WordII} {WordIII} {WordIV} {WordV} {WordVI} {WordVII} {WordVIII} {WordIX} {WordX} {WordXI} {WordXII} {WordXIII} {WordXIV} {WordXV} {WordXVI} {WordXVII} {WordXVIII} {WordIXX}",
"{WordI} {WordII} {WordIII} {WordIV} {WordV} {WordVI} {WordVII} {WordVIII} {WordIX} {WordX} {WordXI} {WordXII} {WordXIII} {WordXIV} {WordXV} {WordXVI} {WordXVII} {WordXVIII} {WordIXX} {WordXX}",
"{WordI} {WordII} {WordIII} {WordIV} {WordV} {WordVI} {WordVII} {WordVIII} {WordIX} {WordX} {WordXI} {WordXII} {WordXIII} {WordXIV} {WordXV} {WordXVI} {WordXVII} {WordXVIII} {WordIXX} {WordXX} {WordXXI}",
"{WordI} {WordII} {WordIII} {WordIV} {WordV} {WordVI} {WordVII} {WordVIII} {WordIX} {WordX} {WordXI} {WordXII} {WordXIII} {WordXIV} {WordXV} {WordXVI} {WordXVII} {WordXVIII} {WordIXX} {WordXX} {WordXXI} {WordXXII}",
"{WordI} {WordII} {WordIII} {WordIV} {WordV} {WordVI} {WordVII} {WordVIII} {WordIX} {WordX} {WordXI} {WordXII} {WordXIII} {WordXIV} {WordXV} {WordXVI} {WordXVII} {WordXVIII} {WordIXX} {WordXX} {WordXXI} {WordXXII} {WordXXIII}",
"{WordI} {WordII} {WordIII} {WordIV} {WordV} {WordVI} {WordVII} {WordVIII} {WordIX} {WordX} {WordXI} {WordXII} {WordXIII} {WordXIV} {WordXV} {WordXVI} {WordXVII} {WordXVIII} {WordIXX} {WordXX} {WordXXI} {WordXXII} {WordXXIII} {WordXXIV}",
"{WordI} {WordII} {WordIII} {WordIV} {WordV} {WordVI} {WordVII} {WordVIII} {WordIX} {WordX} {WordXI} {WordXII} {WordXIII} {WordXIV} {WordXV} {WordXVI} {WordXVII} {WordXVIII} {WordIXX} {WordXX} {WordXXI} {WordXXII} {WordXXIII} {WordXXIV} {WordXXV}",
"{WordI} {WordII} {WordIII} {WordIV} {WordV} {WordVI} {WordVII} {WordVIII} {WordIX} {WordX} {WordXI} {WordXII} {WordXIII} {WordXIV} {WordXV} {WordXVI} {WordXVII} {WordXVIII} {WordIXX} {WordXX} {WordXXI} {WordXXII} {WordXXIII} {WordXXIV} {WordXXV} {WordXXVI}",
"{WordI} {WordII} {WordIII} {WordIV} {WordV} {WordVI} {WordVII} {WordVIII} {WordIX} {WordX} {WordXI} {WordXII} {WordXIII} {WordXIV} {WordXV} {WordXVI} {WordXVII} {WordXVIII} {WordIXX} {WordXX} {WordXXI} {WordXXII} {WordXXIII} {WordXXIV} {WordXXV} {WordXXVI} {WordXXVII}",
"{WordI} {WordII} {WordIII} {WordIV} {WordV} {WordVI} {WordVII} {WordVIII} {WordIX} {WordX} {WordXI} {WordXII} {WordXIII} {WordXIV} {WordXV} {WordXVI} {WordXVII} {WordXVIII} {WordIXX} {WordXX} {WordXXI} {WordXXII} {WordXXIII} {WordXXIV} {WordXXV} {WordXXVI} {WordXXVII} {WordXXVIII}",
"{WordI} {WordII} {WordIII} {WordIV} {WordV} {WordVI} {WordVII} {WordVIII} {WordIX} {WordX} {WordXI} {WordXII} {WordXIII} {WordXIV} {WordXV} {WordXVI} {WordXVII} {WordXVIII} {WordIXX} {WordXX} {WordXXI} {WordXXII} {WordXXIII} {WordXXIV} {WordXXV} {WordXXVI} {WordXXVII} {WordXXVIII} {WordIXXX}",
"{WordI} {WordII} {WordIII} {WordIV} {WordV} {WordVI} {WordVII} {WordVIII} {WordIX} {WordX} {WordXI} {WordXII} {WordXIII} {WordXIV} {WordXV} {WordXVI} {WordXVII} {WordXVIII} {WordIXX} {WordXX} {WordXXI} {WordXXII} {WordXXIII} {WordXXIV} {WordXXV} {WordXXVI} {WordXXVII} {WordXXVIII} {WordIXXX} {WordXXX}"
]
},
{
"name": "AMAZON.NavigateHomeIntent",
"samples": [
"navigate home"
]
}
],
"types": [
{
"name": "AMAZONSearchQuery",
"values": [
{
"name": {
"value": "all"
}
}
]
},
{
"name": "CONTENT_LIST",
"values": [
{
"name": {
"value": "all"
}
}
]
}
]
}
}
}
Note: I use this code as a capture all for my skill. It's the only intent. If you're looking to have other intents so that this intent can detect utterances that fall through I'd recommend experimenting. Create an intent with defined utterances and see if Amazon will pick it before falling back on this free form capture.
Please comment below if you have success and I'll update the answer.