0
votes

I'm building Alexa skill that plays audios. An audio has a title, speakers and other properties.

Problem: I want to add search functionality in my skill, so that user may play audio on base of title or speaker's name etc. How can i achieve this?

How can a user search on base of some custom string (speaker, title) & that string is passed to my skill?, where i'll write logic to search that audio.

I know about custom intents and slots, but i don't know how they will work in my case.

Please guide. I just need some starting point. Thanks.

2

2 Answers

3
votes

Yes - it's custom slots that you need to look at.

Your intents.json

{
  "intents": [
    {
      "intent": "GetAudio",
      "slots": [
        {
          "name": "Query",
          "type": "QUERY"
        },
      ]
    },
  ],
  ...
}

Your defined Utterances

Your utterances might then include things like:

GetAudio search for {Query}
GetAudio find audio matching {Query}

Processing requests in your skill

When your skill receives the intent, it will get an IntentRequest full of any slots you've defined. So if you've defined a custom slot of Query (and ideally populated with example searches to improve the matching) as above, you might receive something like:

{
  "type": "IntentRequest",
    ...
  "intent": {
    "name": "GetAudio",
    "slots": {
      "Query": {
        "name": "Query",
        "value": "jimi hendrix"
      }
    }
  }
}

so it's then easy to retrieve the value field and use your internal logic to search.

Hope that helps.

0
votes

You do it by defining a custom slot of type AMAZON.SearchQuery. All details here