Developing a skill on Alexa is definitely fun. Isn’t it? That’s because Alexa not only makes the life of the user easier but also its developer. It provides many features for developers so that we can concentrate more on the backend part and not filling the slots.
Now before proceeding further, I assume that you have the basic knowledge like what are intents, utterances, slots, etc. If not please check out this article.
In my previous blog, I spoke about how to handle dates on Alexa, where we used an in-built AMAZON.Month slot type to pick the month from the user. Imagine that there is no in-built slot type for a month. What will you do now to pick the month from the user? That’s where the custom slots come in.
In the above diagram, you can see that we have left the month slot unfilled. In order to add a custom slot click the Add button that is highlighted.
Enter the appropriate slot name and click the “Create custom slot type” button.
Now add all the 12 months inside the value. There will be an ID field that you can use to map it with a number. SYNONYMS can be used as alternative words. For example, the user can say “Jan” or “First-month” month insert of “January” every time. In those cases, add “Jan” and “First month” in SYNONYMS.
Lambda / Backend
Now in the lambda, you need to get the slot value of the month as usual. You can also use the ID field to get the number in the number format that you mentioned early. Handled appropriately as you need. And that’s all you need to do, to get the custom slot.
Take a look at the official documentation of Alexa for the best practices for sample utterances and custom slot types. Happy programming!!