Editors' Note: The Gadgets Skill API is now the Echo Buttons Skill API. The interface names and underlying functionality are unchanged.
lexa customers love a good trivia game. During family game nights, players who have the answers get to show off their knowledge, while other players get to learn something new. With the launch of Echo Buttons, you have an opportunity to turn voice-first trivia games into engaging multiplayer experiences.
The new Echo Buttons trivia template shows you how to build trivia games with the Gadgets Skill API (beta). All you have to do is provide the trivia facts and plug them into the easy-to-use template. And if you’ve already submitted a voice-first game skill, you can use the trivia template as an example of how to incorporate Echo Buttons with your existing skill.
When developing any Echo Button game, you have to implement logic for discovering and associating Echo Buttons with players. This logic is referred to as “roll call.” In addition, you have to implement question-and-answer game logic. The Echo Buttons trivia template provides a solid foundation for both of these requirements.
The first step to build a trivia game using the new template is to select a theme for your game. Once identified, you will need to pull together your own list of trivia questions. With this template, it's easy to get started building your own trivia skill. Many customizations will not require code changes.
The questions used during the game are loaded by the skill from an array found in the file called questions.js, located in lambda/custom/config. Each question consists of an object with the following properties:
Index – The ordinal index of the question in the collection of question
Question – The text of the question (this is what Alexa asks players)
Answers – An array of multiple answers that Alexa offers contestants to choose from
questions: [
{
index: 1,
question: 'What is the name for a group of lions?',
answers: ['pack', 'pride', 'den', 'frat'],
correct_answer: 'pride'
},
{
index: 2,
question: 'What type of animal is a seahorse?',
answers: ['crustacean', 'arachnid', 'fish', 'shell'],
correct_answer: 'fish'
},
When adding or updating questions and answers, you must compile a list of all values in each of the answers arrays for all questions and add each one to a custom slot in the interaction model called answers. This custom slot is mapped to two intents: AnswerOnlyIntent, which contains only the slot by itself in order to maximize the accuracy of the model; and AnswerQuestionIntent, which provides recognition of more complex utterances that users may include with their answers.
For example:
AnswerQuestionIntent is it {answers}
AnswerQuestionIntent the answer is {answers}
AnswerQuestionIntent I think it is {answers}
See the interaction model file at models/en-US.json for a complete example that you can further customize.
After you’ve selected your theme and created your trivia questions, you can choose to customize additional GAME_OPTIONS parameters that can be found in the settings.js file located under lambda/custom/config. This is how you tailor your game experience. For example, you may want your game to present questions in order of difficulty, you may want to give players a single chance to answer each question, or you want the game to be head-to-head vs. multiplayer. Below are a few options you can use to tailor your game experience:
As mentioned earlier, roll call is important for your skill to assign Echo Buttons to specific players. The Echo Buttons trivia template provides options to handle roll call that do not require writing any code. While the template does the heavy lifting, you can easily customize it by providing your own user interface elements such as speech prompts or visual cues.
All the user interface elements used by the skill, including during roll call and the actual game play, are defined in a file called uiprompts.js, located in lambda/custom/dialog. Identified by a key, each element is defined as an object with properties such as outputSpeech, reprompt, displayTitle and displayText, that consist of corresponding content for Alexa to use as output speech or display text. Because each parameter is defined as an array, you can easily add variety to your skill by providing multiple sample variations for each prompt.
Other ways to customize the user experience are to change the audio and visual cues used during roll call. These can all be found as configurable properties defined in the settings.js file, located in lambda/custom/config. The Echo Buttons trivia template uses an audio clip that is played during roll call named ROLL_CALL_WAITING_AUDIO. The light animations and colors used on the buttons during the roll call process can all be customized by updating the corresponding animations found in the ANIMATIONS map in the settings.js file.
While the template simplifies building a trivia game skill, you should still consider all the best practices for building for voice as well as the additional considerations when building skills for Echo Buttons. Before you submit your skill for certification, make sure to update the skill interaction model, the UI prompts, and the skill details to reflect the name of your skill.
Follow the steps below to start building today: