Overview

2 Building a call and response skill on Alexa

This chapter walks you through building a simple call-and-response Alexa skill using the Alexa Skills Kit (ASK) SDK for Node.js. It frames the core architecture as two halves: the interaction model that teaches Alexa what users can say, and the fulfillment that decides how Alexa responds. Using a “Sleep Tracker” example, you learn to design a concise, memorable invocation name, guide users with natural phrasing, and keep the experience lightweight and useful, while getting familiar with serverless options and built-in testing tools.

On the interaction model side, you define a Custom skill with an invocation name, intents, slots, and sample utterances. The chapter shows how to turn real user phrasing into robust utterance sets, why “Wizard of Oz” testing helps you capture natural language, and how to lean on built-in slot types (for example, numbers) while creating custom ones when needed (such as a Quality type for sleep descriptions). It emphasizes coverage without overfitting, the diminishing returns of massive utterance lists, and practical rules for memorable invocation names, locale considerations, and the save/build cycle that trains Alexa’s NLU.

For fulfillment, you compare hosting your own endpoint with using AWS Lambda, then implement the Lambda-based approach with the ASK SDK’s request handlers (canHandle/handle) and responseBuilder. You build the WellRestedIntent: validate and parse the NumberOfHours slot, keep the mic open with a reprompt when data is missing, and optionally adjust results based on a SleepQuality slot mapped to “good” or “bad” lists. Throughout, the chapter stresses VUI principles—handle what you know, be explicit about what you used to decide, and avoid guessing when inputs are unclear—plus practical testing and logging guidance so you can iterate quickly toward a friendly, reliable voice experience.

Figure 2.1. Toward creating skill metadata
developer console skill create
Figure 2.2. Setting up the new skill
dev console create new skill
Figure 2.3. The interaction model
skill invocation intent slot
Figure 2.4. The interaction model with utterances
skill invocation intent slot utterance
Figure 2.5. An intent will have many sample utterances
relationship early early
Figure 2.6. Sample utterances provide the training to map request to intent
utterance intent mappings
Figure 2.7. Slots allow for a multitude of values in a single place in the utterance
slots
Figure 2.8. We place slots to capture variable information in utterances
relationship early
Figure 2.9. Relationship between slots and the interaction models
relationship
Figure 2.10. Slots, intents, and utterances combine to complete an action
intent utterance slot mapping
Figure 2.11. Information flows from user through device and Alexa to the fulfillment and back
info flow

 Summary

  • Craft intents to represent what users want to do, slots for variable information, and sample utterances for what they might say.
  • Do not consider a slot as an enum, but as a biasing toward specific values
  • Use the Alexa Skills Kit (ASK) Node.js SDK to handle and respond to Alexa requests
  • Design skills defensively to handle unexpected user requests

FAQ

What is a call-and-response Alexa skill?A call-and-response skill is a single-turn interaction: the user asks a question or issues a command, Alexa replies once, and the session ends. It’s ideal for tasks that don’t need a multi-step conversation.
What are the two main parts of an Alexa skill and what do they do?- Interaction model: Defines how users talk to the skill (invocation name, intents, slots, and sample utterances) and is configured in the Alexa Developer Console. - Fulfillment: The code that handles requests and returns speech responses, typically running on AWS Lambda (or a secure self-hosted endpoint).
What makes a good invocation name?It must be two or more words and in the same language as the skill. Choose a short, easy-to-pronounce, memorable phrase, ideally aligned with the skill’s name (for discovery). Alexa allows duplicate invocation names; it prefers the one a user enabled.
What are intents and sample utterances, and how many utterances should I add?- Intents represent actions users want (e.g., WellRestedIntent). - Sample utterances are example phrases that map to a single intent. They don’t need to match user speech exactly—Alexa’s NLU generalizes from them. Provide plenty of realistic variations for better recognition, but avoid unlikely phrasing to prevent confusing the model (diminishing returns apply).
What are slots and slot types, and when should I use built-in vs. custom types?Slots capture variable data (e.g., a number of hours or a quality). Slot types describe expected values and bias recognition. Use built-in types whenever possible (e.g., AMAZON.NUMBER, AMAZON.US_FIRST_NAME, AMAZON.PostalAddress). Create custom types for domain-specific vocabularies (e.g., a Quality type with “good,” “poorly,” “fantastic”). Types guide recognition but aren’t strict enums.
How is the Sleep Tracker interaction model structured?- Intent: WellRestedIntent. - Slots: NumberOfHours (AMAZON.NUMBER) and SleepQuality (custom type, e.g., “good,” “bad,” “not at all,” “great”). - Sample utterances: Variations such as “How well rested will I be if I sleep for {NumberOfHours} hours,” “How tired will I be after {NumberOfHours} hours,” and versions that include last night’s {SleepQuality}.
How do I implement fulfillment with the Alexa Skills Kit SDK for Node.js?Create index.js, import ask-sdk-core, and define request handlers with canHandle and handle. Use responseBuilder (e.g., responseBuilder.speak(...)) to create replies and export the Lambda handler with Alexa.SkillBuilders.custom().addRequestHandlers(...).lambda(). The SDK routes requests to the first handler whose canHandle returns true.
Should I host my own endpoint or use AWS Lambda?- Self-hosted: More control and easier integration with existing systems, but you manage servers, SSL, and request verification. - AWS Lambda: No server management, auto-scaling, generous free tier, and simpler setup for most skills. For first skills, Lambda (and “hosted skills” in the Console) is typically the best choice.
How should I validate and handle missing or misheard slot values?Parse and validate slot values (e.g., convert AMAZON.NUMBER from string to integer and check it’s valid). Log slot contents for insight. If required values are missing/invalid, ask again and keep the mic open using responseBuilder.reprompt(...). Be transparent about what you understood. In the example, sleep quality words are grouped (good/bad) to adjust the hour count by ±1; unknown descriptors are safely ignored.
How can I test and debug my skill without an Echo device?Use the Test tab in the Alexa Developer Console (speak, type, or send raw JSON), Echosim.io, or the Alexa mobile app. Inspect request/response payloads in the Console. For hosted skills/Lambda, view CloudWatch logs to see console.log output and errors. Remember to Build your model after changes before testing.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Voice Applications for Alexa and Google Assistant ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Voice Applications for Alexa and Google Assistant ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Voice Applications for Alexa and Google Assistant ebook for free