Alexa Blogs Alexa Developer Blogs /blogs/alexa/feed/entries/atom 2019-06-17T14:00:00+00:00 Apache Roller /blogs/alexa/post/93069e48-9baa-4dab-b51f-f761d5e7b1e7/getting-started-with-the-cake-walk-course-adding-memory-to-the-cake-walk-skill-to-remember-the-customer-s-birthday Getting Started with the Cake Walk Course: Adding Memory to the Cake Walk Skill to Remember the Customer’s Birthday Jennifer King 2019-06-17T14:00:00+00:00 2019-06-17T14:00:00+00:00 <p><img alt="" src="https://m.media-amazon.com/images/G/01/DeveloperBlogs/AlexaBlogs/default/blog_design-guide_954x240.png._CB464487126_.png" style="height:480px; width:1908px" /></p> <p>In part 3 of my blog series about our new training course called Cake Walk, I cover how we added memory to Cake Walk to create a more engaging voice experience.</p> <p><img alt="" src="https://m.media-amazon.com/images/G/01/DeveloperBlogs/AlexaBlogs/default/blog_design-guide_954x240.png._CB464487126_.png" style="height:480px; width:1908px" /></p> <p><em><strong>Editor’s Note:</strong> We </em><a href="https://developer.amazon.com/blogs/alexa/post/7e3376cf-97d7-41d6-86a6-afcdf1ca1379/new-alexa-skills-training-course-build-your-first-alexa-skill-with-cake-walk"><em>recently launched</em></a><em> a new training course called </em><a href="https://developer.amazon.com/alexa-skills-kit/courses/cake-walk"><em>Cake Walk: Build an Engaging Alexa Skill</em></a><em>. The course is a self-paced, skill-building course that offers guidance on how to build a high-quality skill from start to finish. In this 4-part blog series, we’re going to dive deep into the coding modules within the course. You can read part 1 on designing the voice user interface for Cake Walk </em><a href="https://developer.amazon.com/blogs/alexa/post/f26e61af-82c5-426c-91f7-ed46e581dc48/getting-started-with-the-cake-walk-course-designing-the-voice-user-interface-vui-for-your-alexa-skill"><em>here</em></a><em>. Part 2 covers </em><a href="https://developer.amazon.com/blogs/alexa/post/c4293154-968b-4707-a5c9-018b91d2846d/getting-started-with-the-cake-walk-course-using-auto-delegation-to-collect-slots-turn-by-turn">how to use slot delegation</a><em> to collect slots turn by turn. </em></p> <p>In my <a href="https://developer.amazon.com/blogs/alexa/post/f26e61af-82c5-426c-91f7-ed46e581dc48/getting-started-with-the-cake-walk-course-designing-the-voice-user-interface-vui-for-your-alexa-skill">previous post on designing the Cake Walk skill</a>, I did a deep dive on <a href="https://developer.amazon.com/alexa-skills-kit/situational-design">situational design</a>. Instead of a flow chart, my colleague and I focused on the conversation and used situational design. This helped us focus the experience and enabled us to build a useful, simple, and sticky skill. We determined that we would need a way to remember our customer’s birthday. Shared context and <a href="https://developer.amazon.com/blogs/alexa/post/d10485af-a1d0-4071-bbab-e467d3447f83/build-for-memory-keep-track-of-important-information-when-designing-conversational-alexa-skills">memory</a> are paramount to natural, conversational interactions. The shared context changes over time based on past interactions. Once two people get to know one another, they don’t need to keep reintroducing themselves as if they never met before. When designing your skill, you should make sure to give your skill some memory. Your customers will appreciate that the skill doesn’t ask for the same information over and over. The reduced friction may lead to a better customer experience and customer retention. In part 3 of our Cake Walk series, I cover <a href="https://developer.amazon.com/blogs/alexa/post/d10485af-a1d0-4071-bbab-e467d3447f83/build-for-memory-keep-track-of-important-information-when-designing-conversational-alexa-skills">how we added memory</a> to Cake Walk to create a more engaging voice experience.</p> <h2>Birthday Unknown vs. Known</h2> <p>Let’s quickly review our design. We have two situations based on the customer’s birthday: unknown and known. If the birthday is unknown, we must ask for it. If the birthday is known, we use it to calculate the number of days until their next one, unless it’s their birthday. In that case, we wish them a happy birthday.</p> <p><img alt="" src="https://m.media-amazon.com/images/G/01/DeveloperBlogs/AlexaBlogs/default/cake_walk_memoery.png._CB443673905_.png" /></p> <h2>Where to Store the Birthday Data</h2> <p>Alexa skills are stateless and don’t automatically remember information between requests. We have to file the birthday away somewhere. If we don’t, sadly we’ll immediate forget it after we send back a response. The next time our customer uses our skill, the birthday is yet again unknown. To our customer’s chagrin, we’ll have ask for it again. This is less than ideal. We could use <a href="https://developer.amazon.com/docs/custom-skills/manage-skill-session-and-session-attributes.html">session attributes</a>, which are passed back and forth between our skill and the Alexa service via the request and the response. Doing so will allow us to remember their birthday a little longer. Sadly, however, this solution is not perfect. Session attributes are forgotten as soon as the session ends as the skill quits. This means we need something a little more permanent. Two great places where you can store information are <a href="https://aws.amazon.com/s3/">Amazon S3</a> and <a href="https://aws.amazon.com/dynamodb/">DynamoDB</a>. If you’re using your own AWS account to host your skill, you’ll most likely want to use DynamoDB, which is a key-value and document database. If you’re using Alexa-hosted skills, which is what I used to build the Cake Walk skill, you only have Amazon S3 at your disposal. Wherever you choose to save their birthday, the code to read, write, and delete it stays the same. The only difference is how you set things up.</p> <p>Let’s take a look at how to set up Amazon S3 and DynamoDB with the <a href="https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs">Alexa Skills Kit (ASK) Software Development Kit (SDK) for Node.js</a></p> <h3>Setting Up the Persistence Adapter</h3> <p>Before we are able to save, we need to configure a persistence adapter. A persistence adapter is an object that is configured to the storage service we want to connect to and operate on its data using persistent attributes. We can use the persistence adapter to access our storage service, which wires it into the SDK so we can use the same code to read, write and delete data from whatever service we are connected to. Once we configure our persistence adapter, we will register it with the SDK and our <strong>skillBuilder</strong> using the <strong>withPersistenceAdapter</strong> function.</p> <h4>Amazon S3</h4> <p>When using Alexa-hosted skills, the service sets up your skill’s AWS Lambda function. It does not include the S3 persistence adapter, so you’ll have to update your <strong>package.json</strong> file. You’ll need to add <strong>“ask-sdk-s3-persistence-adapter”: “^2.0.0”</strong> the <strong>dependencies</strong>. Upon doing so, your <strong>package.json</strong> file will look like:</p> <p><strong>package.json</strong></p> <pre> <code>{ &quot;name&quot;: &quot;cake-walk&quot;, &quot;version&quot;: &quot;0.9.0&quot;, &quot;description&quot;: &quot;alexa utility for quickly building skills&quot;, &quot;main&quot;: &quot;index.js&quot;, &quot;scripts&quot;: { &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot; }, &quot;author&quot;: &quot;Amazon Alexa&quot;, &quot;license&quot;: &quot;ISC&quot;, &quot;dependencies&quot;: { &quot;ask-sdk-core&quot;: &quot;^2.0.7&quot;, &quot;ask-sdk-model&quot;: &quot;^1.4.1&quot;, &quot;aws-sdk&quot;: &quot;^2.326.0&quot;, &quot;ask-sdk-s3-persistence-adapter&quot;: &quot;^2.0.0&quot; } }</code></pre> <p>Once you’ve updated the <strong>package.json</strong>, you’ll need to click on the <strong>deploy</strong> button to have the Alexa service install the <strong>ask-sdk-s3-persistence-adapter</strong>. To use the adapter in your code, you’ll need to load the module into your <strong>index.js</strong> file. To do so you, use the <strong>require</strong> keyword:</p> <pre> <code>const persistenceAdapter = require('ask-sdk-s3-persistence-adapter');</code></pre> <p>You can put this anywhere in your file as long as it appears before you use it. It’s a standard practice to load your modules at the top of your files, so I recommend that you put it there.</p> <p>Next, we need to use the module to create an S3 persistence adapter. The constructor takes in an object. <strong>bucketName</strong> is the name of the bucket that we want our <strong>s3PersistenceAdapter</strong> to connect to. Since we used Alexa-hosted, a bucket was created for us. We can access the name of that bucket with the <strong>S3_PERSISTENCE_BUCKET</strong> environment variable. You can access environment variables from <strong>process.env</strong>. To access the name of our bucket you would use, <strong>process.env.S3_PERSISTENCE_BUCKET</strong>. Below we are using the S3 persistence adapter and passing it the bucket name we want to connect to.</p> <pre> <code>const s3PersistenceAdapter = new persistenceAdapter.S3PersistenceAdapter({ bucketName: process.env.S3_PERSISTENCE_BUCKET });</code></pre> <p>Lastly, we register our adapter using <strong>withPersistenceAdapter</strong>:</p> <pre> <code>.withPersistenceAdapter( s3PersistenceAdapter )</code></pre> <p>Let’s zoom out and take a look at our <strong>SkillBuilder</strong>:</p> <p><strong>index.js</strong></p> <pre> <code>// top of the file const persistenceAdapter = require('ask-sdk-s3-persistence-adapter'); // ... // continued at the bottom of the file const s3PersistenceAdapter = new persistenceAdapter.S3PersistenceAdapter({ bucketName:process.env.S3_PERSISTENCE_BUCKET }); exports.handler = Alexa.SkillBuilders.custom() .withPersistenceAdapter(s3PersistenceAdapter) .addRequestHandlers( HasBirthdayLaunchRequestHandler, LaunchRequestHandler, CaptureBirthdayIntentHandler, HelpIntentHandler, CancelAndStopIntentHandler, SessionEndedRequestHandler, IntentReflectorHandler ) // make sure IntentReflectorHandler is last so it doesn't override your custom intent handlers .addErrorHandlers(ErrorHandler) .lambda();</code></pre> <p>Now that we understand how to set up the S3 persistence adapter with Alexa-hosted skills, let’s take a look at how we’d set up the DynamoDB adapter.</p> <h4>Amazon DynamoDB</h4> <p>The configuration process for DynamoDB is similar and takes 4 steps.</p> <p>1. Update the <strong>package.json</strong> with a new module dependency</p> <pre> <code> &quot;ask-sdk-s3-persistence-adapter&quot;: &quot;^2.0.0&quot;</code></pre> <p>2. Import the module into your <strong>index.js</strong> file</p> <pre> <code>const ddbAdapter = require('ask-sdk-dynamodb-persistence-adapter');</code></pre> <p>3. Create a DynamoDB persistence adapter</p> <pre> <code> const ddbTableName = 'cake-walk'; const ddbPersistenceAdapter = new dbdAdapter.DynamoDbPersistenceAdapter({ tableName: tableName, createTable: true, });</code></pre> <p>4. Register it with your <strong>SkillBuilder</strong></p> <pre> <code>.withPersistenceAdapter(ddbPersistenceAdapter)</code></pre> <p>Let’s zoom in to see what the <strong>package.json</strong> and <strong>index.js</strong> file will look like:</p> <p><strong>package.json</strong></p> <pre> <code>{ &quot;name&quot;: &quot;cake-walk&quot;, &quot;version&quot;: &quot;0.9.0&quot;, &quot;description&quot;: &quot;alexa utility for quickly building skills&quot;, &quot;main&quot;: &quot;index.js&quot;, &quot;scripts&quot;: { &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot; }, &quot;author&quot;: &quot;Amazon Alexa&quot;, &quot;license&quot;: &quot;ISC&quot;, &quot;dependencies&quot;: { &quot;ask-sdk-core&quot;: &quot;^2.0.7&quot;, &quot;ask-sdk-model&quot;: &quot;^1.4.1&quot;, &quot;aws-sdk&quot;: &quot;^2.326.0&quot;, &quot;ask-sdk-dynamodb-persistence-adapter&quot;: &quot;^2.0.0&quot; } }</code></pre> <p><strong>index.js</strong></p> <pre> <code>// top of the file const ddbAdapter = require('ask-sdk-dynamodb-persistence-adapter'); const ddbTableName = 'cake-walk'; // ... // continued at the bottom of the file const ddbPersistenceAdapter = new ddbAdapter.DynamoDbPersistenceAdapter({ tableName: tableName, createTable: true, }); exports.handler = Alexa.SkillBuilders.custom() .withPersistenceAdapter(ddbPersistenceAdapter) .addRequestHandlers( HasBirthdayLaunchRequestHandler, LaunchRequestHandler, CaptureBirthdayIntentHandler, HelpIntentHandler, CancelAndStopIntentHandler, SessionEndedRequestHandler, IntentReflectorHandler ) // make sure IntentReflectorHandler is last so it doesn't override your custom intent handlers .addErrorHandlers(ErrorHandler) .lambda(); </code></pre> <p>Now that we understand how to configure the S3 and DynamoDB persistence adapters, we can move onto using Persistent Attributes to read and write the birthday.</p> <h2>Using Persistent Attributes to Store Data</h2> <p>Let’s start with writing data. We’ll use the <strong>AttributesManager</strong> to interact with our persistent attributes.</p> <pre> <code>const attributesManager = handlerInput.attributesManager;</code></pre> <p>We’ll then use the <strong>setPersistentAttributes</strong> to set the attributes that we want to save. In this case, we’ll be saving the <strong>month</strong>, <strong>day</strong>, and <strong>year</strong> slot values.</p> <p>Let’s create the object to store our attributes. We’ll call it <strong>birthdayAttributes</strong>. We’ll map our slot values that we collected into a dictionary:</p> <pre> <code>const birthdayAttributes = { &quot;year&quot;: year, &quot;month&quot;: month, &quot;day&quot;: day };</code></pre> <p>If the customer said their birthday was “November seventh nineteen eighty three,” then the data would look like:</p> <pre> <code>{ &quot;year&quot;: &quot;1983&quot;, &quot;month&quot;: &quot;11&quot;, &quot;day&quot;: &quot;7&quot; }</code></pre> <p>To save the data to our storage service we pass <strong>birthdayAttributes</strong> to <strong>setPersistentAttributes</strong> and then call <strong>savePersistentAttributes</strong>.</p> <pre> <code>attributesManager.setPersistentAttributes(birthdayAttributes); attributesManager.savePersistentAttributes(); </code></pre> <p>Now that we understand how to save the birthday, let’s take a look at how we recall their birthday.</p> <h3>Using Persistent Attributes to Read Data</h3> <p>Reading information is even easier. We’ll use the <strong>AttributesManager</strong>, but this time we only need to call one function: <strong>getPersistentAttributes</strong>. The function is asynchronous, so you’ll want to use the <strong>async/await</strong> keywords.</p> <pre> <code>async handle(handlerInput) { const attributesManager = handlerInput.attributesManager; const persistentAttributes = await attributesManager.getPersistentAttributes() || {}; console.log(&quot;year&quot;, persistentAttributes.year); console.log(&quot;month&quot;, persistentAttributes.month); console.log(&quot;day&quot;, persistentAttributes.day); //... }</code></pre> <p>If it’s the first time the customer has opened the skill, there won’t be a record of it in the storage service. This will cause our code to throw an error if we try to access an attribute of a null value so we set persistentAttributes to an “OR” expression:</p> <pre> <code>const persistentAttributes = await attributesManager.getPersistentAttributes() || {}; </code></pre> <p>This means that <strong>persistentAttributes</strong> will never be null. It will either be a birthday record or and empty object. The empty object will indicate that the birthday is unknown and our skill won’t crash if we call <strong>persistentAttributes.year</strong>. Instead it will return undefined.</p> <p>Now that we’re able to read and write the birthday to our storage service, our customers will be thankful that we don’t have to ask for it every time they start the skill.</p> <p>To this point, we’ve been very focused on the design of our voice user interface, but now we need take a moment and think about our back end. Our skill’s behavior changes based upon the situation. The SDK uses handlers to service the requests that come to our skill. When someone launches the skill we get a <strong>LaunchRequest</strong>. If the birthday is <strong>unknown,</strong> we need to ask for it. If the birthday is <strong>known</strong> we have to calculate the number of days until their next birthday. This means we’re going to need two handlers that can handle a launch request: one for unknown, one for known.</p> <p>We already have a <strong>LaunchRequest</strong> handler, so we’ll need to create one more that handles the case when the birthday is known. We’ll call it <strong>HasBirthdayLaunchRequestHandler</strong>. Our handler’s <strong>canHandle</strong> function needs to read the birthday from our storage service and return true if it exists. The <strong>handle</strong> function needs to read from our storage service and return true if it exists. Both functions need access to the same data. While we can have both functions read the data, there’s a slight delay in doing so which will affect performance. It can also potentially cost us a lot of money to read information over and over.</p> <p>What we need is a way to load the data once per session and make that data available to all of the handlers in our skill. We can use the <strong>AttributesManager</strong> to accomplish that. So how do we load the data only once? We could try to lazy load it. That would require us to:</p> <ol> <li>Check to see if we’ve already loaded and use it if it has been loaded</li> <li>Go fetch it if it’s not loaded</li> </ol> <p>This would be great, but then we have duplicate a bunch of code whenever we want to access the birthday. If only there was something that ran before our handlers that could handle fetching the birthday only once per session. Turns out there is! We can use a request interceptor.</p> <h3>How to Read Once per Session</h3> <p>There are two types of <strong>interceptors</strong>.</p> <ol> <li><strong>Request</strong> - Intercept the request for processing prior to handler execution</li> <li><strong>Response</strong> - Intercept the response after handler execution before sending it to the Alexa service</li> </ol> <p>Like handlers you can define more than one. Let’s take a look at how we would define an interceptor to read our birthday from our storage service once per session.</p> <p>First we need to create an interceptor and then register it. There are two registration functions: One to register <strong>request</strong> interceptors and another to register <strong>response</strong> interceptors. Interceptors must define a function called <strong>process</strong>. The code in this function will be executed.</p> <pre> <code>const someInterceptor = { process(handlerInput) { // code ... } }</code></pre> <p>To register our <strong>request</strong> interceptor, we need to pass it to <strong>addRequestInterceptors</strong>. Since our interceptor loads our customer’s birthday we named it, <strong>LoadBirthdayInterceptor</strong>.</p> <p>If we have a birthday record in the session store, we’ll get it and use the <strong>AttributesManager</strong> to store them into the session attributes.</p> <pre> <code>const sessionAttributes = await attributesManager.getPersistentAttributes() || {};</code></pre> <p>We want to make sure that we have properly received the <strong>month</strong>, <strong>day</strong>, and <strong>year</strong> values from our session store. We use the ternary operator, ‘?’ to define an in-line if-else statement. For each attribute, we check to see if we have a non-null value if not we default to 0.</p> <pre> <code>const year = sessionAttributes.hasOwnProperty('year') ? sessionAttributes.year : 0; const month = sessionAttributes.hasOwnProperty('month') ? sessionAttributes.month : 0; const day = sessionAttributes.hasOwnProperty('day') ? sessionAttributes.day : 0; We only want to set the sessionAttributes if we have all non-zero values for month, day, and year. if (year &amp;&amp; month &amp;&amp; day) { attributesManager.setSessionAttributes(sessionAttributes); }</code></pre> <p>Zooming out our handler looks like:</p> <pre> <code>const LoadBirthdayInterceptor = { async process(handlerInput) { const attributesManager = handlerInput.attributesManager; const sessionAttributes = await attributesManager.getPersistentAttributes() || {}; const year = sessionAttributes.hasOwnProperty('year') ? sessionAttributes.year : 0; const month = sessionAttributes.hasOwnProperty('month') ? sessionAttributes.month : 0; const day = sessionAttributes.hasOwnProperty('day') ? sessionAttributes.day : 0; if (year &amp;&amp; month &amp;&amp; day) { attributesManager.setSessionAttributes(sessionAttributes); } } } </code></pre> <p>To register the handler we would use <strong>addRequestInterceptors</strong>. Let’s take a look at our <strong>SkillBuilders</strong>:</p> <pre> <code>exports.handler = Alexa.SkillBuilders.custom() .withPersistenceAdapter(ddbPersistenceAdapter) .addRequestHandlers( HasBirthdayLaunchRequestHandler, LaunchRequestHandler, CaptureBirthdayIntentHandler, HelpIntentHandler, CancelAndStopIntentHandler, SessionEndedRequestHandler, IntentReflectorHandler ) // make sure IntentReflectorHandler is last so it doesn't override your custom intent handlers .addRequestInterceptors( LoadBirthdayInterceptor ) .addErrorHandlers(ErrorHandler) .lambda(); </code></pre> <h2>Conclusion</h2> <p>At this point, the Cake Walk skill can remember and recall our customer’s birthday. This goes a long way to making the experience feel more natural and personal. We’ve also fulfilled a major portion of our design. The last step is to check if it’s their birthday. If so, we need to wish them a happy birthday. If not, we need to count down the days.</p> <p>When you design your own skills and you determine that there’s some data that your skill needs to be able to recall, use persistent attributes to save it. Your skill will no longer need to repeatedly ask your customer for the same information over and over. Let’s keep the conversation going. If you have any questions or comments about memory and cake walk reach out to me on Twitter @SleepyDeveloper.</p> <p>Stay tuned for the next post in this series to learn how to use the Alexa Settings API to look up the customer’s time zone. We’ll need it to accurately compute the number of days until their next birthday.</p> <h2>Related Content</h2> <ul> <li><a href="https://developer.amazon.com/blogs/alexa/post/7e3376cf-97d7-41d6-86a6-afcdf1ca1379/new-alexa-skills-training-course-build-your-first-alexa-skill-with-cake-walk">New Alexa Skills Training Course: Build an Engaging Alexa Skill with Cake Walk</a></li> <li><a href="https://developer.amazon.com/blogs/alexa/post/f26e61af-82c5-426c-91f7-ed46e581dc48/getting-started-with-the-cake-walk-course-designing-the-voice-user-interface-vui-for-your-alexa-skill">Getting Started with the Cake Walk Course: Designing the Voice User Interface (VUI) for Your Alexa Skill</a></li> <li><a href="https://developer.amazon.com/blogs/alexa/post/c4293154-968b-4707-a5c9-018b91d2846d/getting-started-with-the-cake-walk-course-using-auto-delegation-to-collect-slots-turn-by-turn">Getting Started with the Cake Walk Course: Using Auto-Delegation to Collect Slots Turn by Turn</a></li> <li><a href="http://alexa.design/cakewalk">Cake Walk: Build an Engaging Alexa Skill</a></li> <li><a href="https://github.com/alexa/skill-sample-nodejs-first-skill" target="_blank">Cake Walk: Source Code</a></li> </ul> /blogs/alexa/post/4ca2108a-4938-45a4-abc0-7565199670fc/amazon-expands-dash-replenishment-service-with-new-devices-in-france-italy-and-spain1 Amazon Expands Dash Replenishment Service with New Devices in France, Italy, and Spain Apollo Chu 2019-06-17T04:00:00+00:00 2019-06-17T06:46:25+00:00 <p>Amazon has expanded&nbsp;the Dash Replenishment Service in France, Italy, and Spain with new connected devices from Philips, Epson, Bosch, Siemens, Neff, Gaggenau, Haier, Candy, Hoover, and Coway.</p> <p>Today, Amazon expands the Dash Replenishment Service in France, Italy, and Spain with new connected devices from Philips, Epson, Bosch, Siemens, Neff, Gaggenau, Haier, Candy, Hoover, and Coway.</p> <p>Dash Replenishment Service helps ensure customers never run out of consumable goods by enabling hardware devices with the technology to order physical goods from Amazon when supplies are running low. Amazon provides an API for device makers to integrate Dash Replenishment into their hardware products. With Dash Replenishment, device makers are able to leverage Amazon's authentication and payment systems, customer service, and fulfillment network—giving their customers access to Amazon's low prices, great selection, and reliable delivery. Globally, Amazon is working with top appliance manufacturers like GE Appliances, LG, Whirlpool, Samsung, HP, Brother, and more, to integrate the Dash Replenishment technology into connected devices.</p> <p>Using Dash Replenishment Service, device makers can increase customer satisfaction and engagement by providing replacement products designed and manufactured specifically for devices enabled with Dash Replenishment. Integrating Dash Replenishment Service into connected devices is simple, requiring minimal changes to product design and no complex technical skills. For example, the sensor in a Dash Replenishment enabled printer can automatically determine the ink usage level and re-order a new ink cartridge the moment it’s running low.</p> <p>Additional details can be found on the Amazon developer website <a href="https://developer.amazon.com/dash-replenishment-service" target="_blank">here</a>.</p> /blogs/alexa/post/173b7c30-dcd4-483b-a4b1-8c7d798546a7/what-s-new-in-the-alexa-skills-kit-may-2019-release-roundup What's New in the Alexa Skills Kit: May 2019 Release Roundup Leo Ohannesian 2019-06-15T03:05:59+00:00 2019-06-15T03:05:59+00:00 <p><img alt="Intent-history_blog.png" src="https://m.media-amazon.com/images/G/01/DeveloperBlogs/AlexaBlogs/default/Intent-history_blog.png._CB460678784_.png?t=true" /></p> <p>What's new in the Alexa Skills Kit for May 2019? Read our release roundup blog to find out.</p> <p><em><strong>Editor's Note: </strong>Our monthly release roundup series showcases the latest in Alexa Skills Kit developer tools and features that can make your skills easier to manage, simpler to deploy, and more engaging for your customers. Build with these new capabilities to enable your Alexa skills to drive brand or revenue objectives.</em></p> <p>In this roundup post we share details about the new things released for skill developers last month, including the release of the Spanish voice model for the US&nbsp;and several other features&nbsp;that can help make you be more productive or build more engaging skills. Check out the entire livestream for more information from Alexa evangelists and code samples.</p> <p><iframe allowfullscreen="" frameborder="0" height="315" src="https://www.youtube.com/embed/EWXV6k4EmEo" width="560"></iframe></p> <h2>1. Alexa Skills Kit expands to include Spanish in the US</h2> <p>Now you can create Spanish-speaking skills for US customers with the new Spanish-for-US voice model. Skills that you publish now using the new voice model will be available to customers when Alexa launches with Spanish language support in the US later this year. <a href="https://developer.amazon.com/blogs/alexa/post/3c0adda8-3733-4083-9378-e63903f3e993/alexa-skills-kit-expands-to-include-spanish-in-the-us?&amp;sc_category=Owned&amp;sc_channel=BG&amp;sc_campaign=roundup&amp;sc_content_category=Int&amp;sc_country=WW" target="_blank">Check out the announcement here</a> or <a href="https://developer.amazon.com/fr/blogs/alexa/post/3cea1fe4-0f94-4ea7-948e-0b647018cb6c/how-to-update-your-alexa-skills-for-us-spanish?&amp;sc_category=Owned&amp;sc_channel=BG&amp;sc_campaign=roundup&amp;sc_content_category=Int&amp;sc_country=WW" target="_blank">read about how to update your Alexa skill for US Spanish here.</a></p> <ul> </ul> <h2>2. Enhance the smart home camera experience with person detection</h2> <p>You can use the new Alexa.EventDetectionSensor interface in the Smart Home Skill API to tell Alexa when your smart home camera detects the presence of a person. Once you’ve implemented the capability, customers can use person detection as a trigger for other actions, such as turning on the house lights. You can also enable customers to view the last person detected by saying, “Alexa, show the most recent person detected at the front door.” The new capability is available in the US today. <a href="https://developer.amazon.com/docs/device-apis/alexa-eventdetectionsensor.html?&amp;sc_category=Owned&amp;sc_channel=BG&amp;sc_campaign=roundup&amp;sc_content_category=SH&amp;sc_country=WW" target="_blank">Read about it in our docs</a>.&nbsp;</p> <h2>3. Quickly test your voice UI with SMAPI quick builds</h2> <p>Save time and start testing early: We are excited to announce the launch of quick builds, which enable you to start testing your skill with sample utterances on average 67% quicker than before. This is done by introducing a new intermediate build state called Quick Build through SMAPI or the ASK CLI. Read about <a href="https://developer.amazon.com/docs/custom-skills/create-the-interaction-model-for-your-skill.html?&amp;sc_category=Owned&amp;sc_channel=BG&amp;sc_campaign=roundup&amp;sc_content_category=Productivity&amp;sc_country=WW#build-and-save" target="_blank">building your model</a> and <a href="https://developer.amazon.com/docs/smapi/skill-operations.html?&amp;sc_category=Owned&amp;sc_channel=BG&amp;sc_campaign=roundup&amp;sc_content_category=Productivity&amp;sc_country=WW#get-skill-status" target="_blank">getting your skill status</a> in our docs.&nbsp;</p> <h2>4. Simulate a multi-turn conversation with the ASK CLI</h2> <p>Now available: Test multi-turn conversations using the the CLI, SMAPI,&nbsp;or the ASK plugin for Visual Studio Code.&nbsp;Use this new testing capability to improve your skill conversations and deliver a better customer experience. <a href="https://developer.amazon.com/docs/smapi/ask-cli-command-reference.html?&amp;sc_category=Owned&amp;sc_channel=BG&amp;sc_campaign=roundup&amp;sc_content_category=Productivity&amp;sc_country=WW#dialog-command" target="_blank">Learn about simulating a multi-turn conversation in our docs.&nbsp;</a></p> <p>&nbsp;</p> <p>As always, we can't wait to see what you build. As a reminder, learn how to get the most out of the tech docs by visiting the <a href="https://developer.amazon.com/docs/ask-overviews/latest-tips-documentation.html" target="_blank">Latest Tips page.</a></p> /blogs/alexa/post/b7bf617e-31e4-439c-a93e-6f0d09fe7a23/build-premium-experiences-for-kid-skills-in-the-us-preview Build Premium Experiences for Kid Skills in the US (Preview) Metty Fisseha 2019-06-14T17:56:41+00:00 2019-06-14T18:15:55+00:00 <p><img alt="" src="https://m.media-amazon.com/images/G/01/DeveloperBlogs/AlexaBlogs/default/blog_kids-isp_954x240.png._CB443646252_.png?t=true" style="height:480px; width:1908px" /></p> <p>As part of this preview, developers can build premium kid skills for the US Alexa Skills Store using in-skill purchasing (ISP).</p> <p><img alt="blog_kids-isp_954x240.png" src="https://m.media-amazon.com/images/G/01/DeveloperBlogs/AlexaBlogs/default/blog_kids-isp_954x240.png._CB443646252_.png?t=true" /></p> <p>Alexa developers have already created thousands of kid skills that provide fun and educational experiences for families, such as a skill that <a href="https://www.amazon.com/Gimlet-Media-Chompers/dp/B079WCGTKX/ref=sr_1_1?keywords=B079WCGTKX&amp;qid=1560532142&amp;s=gateway&amp;sr=8-1">encourages kids to brush their teeth</a> and one that <a href="https://www.amazon.com/dp/B078RGPMY6">teaches kids how to run their own lemonade stand</a> business. Today, we are excited to announce a preview of new tools that developers can use to build kid skills with in-skill purchasing (ISP) for the US Alexa Skills Store. With ISP, you can further enrich these kid skill experiences, offering premium content in the form of one-time purchases or subscriptions for families to enjoy across over 100 million Alexa-enabled devices.</p> <p>ISP for kid skills is supported by new tools powered by Alexa, including APIs to help you create premium kid skills, as well as purchase controls that help account holders manage them. If you are interested in building a kid skill with ISP, fill out <a href="https://alexa.design/kid-survey">this form</a> telling us about your use case and we will notify you if your application has been selected.</p> <h2><a></a><a>How It Works: Purchasing Controls for Premium Kid Skills</a></h2> <p>By default, when a customer is offered premium content in a kid skill and agrees to purchase, the account holder will receive an SMS or email requesting they approve or decline the transaction within 24 hours. If approved, the purchase will be completed, and the customer will have access to the premium content. If declined, the purchase will not be completed, and the customer will have access only to the skill’s free content. If the purchase request is neither approved nor declined within 24 hours, the request is canceled.&nbsp; Account holders who want to allow purchases to be made in kid skills but do not wish to receive these approval requests can disable them in the Alexa app, allowing purchases to be made in kid skills without the request for approval.</p> <p>Customers can opt out from voice purchasing in kid skills, which will disable voice discovery of premium content in kid skills, by disabling the feature in the Alexa app. To manage these settings, open the Alexa App and navigate to Settings -&gt; Alexa Account -&gt; Voice Purchasing -&gt; Kid Skills Purchasing.</p> <h2><a></a><a>Amazon FreeTime and Amazon FreeTime Unlimited Offer a Curated Skill Experience</a></h2> <p>FreeTime on Alexa customers will not receive offers to purchase premium content within skills. And for FreeTime Unlimited subscribers, many of these premium experiences will already be available automatically as part of their subscription at no additional cost. See <a href="https://www.amazon.com/b?ie=UTF8&amp;node=17738015011">here</a> for a full list of premium kid skills included in the FreeTime Unlimited experience.</p> <p>If you have a kid skill that offers a best-in-class customer experience, and think it could be eligible to be included in FreeTime Unlimited, send an email to <a href="mailto:freetime-skills@amazon.com">freetime-skills@amazon.com</a> for consideration.</p> <h2><a></a><a>New Tools for Building a Premium Kids Skill</a></h2> <p>As part of this preview, you can build a premium kid skill using the tools that currently exist: the <a href="https://www.youtube.com/watch?v=JuGBomjSt90">Alexa Skills Kit Command-Line Interface (ASK CLI)</a> to write your own code, or the <a href="https://developer.amazon.com/blogs/alexa/post/8019524b-6a98-4b7e-9995-c5d583696905/add-in-skill-purchasing-directly-from-the-alexa-developer-console">Alexa Developer Console</a> to click through step-by-step instructions. However, we have built three new tools for kid skills specifically, to help you implement a thoughtful premium experience that is tailored to the controls set by the account holder:</p> <ul> <li>An extension to the current getInSkillProducts API to see if a product is PURCHASABLE, whether the account holder approved the purchase, or NOT_PURCHASABLE, pending authorization OR rejected three times in the past 30 days, which will suppress offers for that product over the next 30 days.</li> <li>A new inSKillProductsTransactions endpoint for transaction-level information, including when the request went into PENDING status and if a previous purchase request was denied. This endpoint is available only for kid skills.</li> <li>A new endpoint to get the purchase control setting for an account, to determine if the account holder has ENABLED or DISABLED voice purchasing for kids skills.</li> </ul> <p><em>Note that you must use the upsell API for when adding ISP to kid skills. Consumable products and Amazon Pay for Alexa Skills are not available for kid skills at this time. </em></p> <h2><a></a><a>Premium Kid Skill Experiences Available Today</a></h2> <p>Developers have already implemented ISP in their kid skills across a variety of fun and educational experiences, including:</p> <p><a href="https://www.amazon.com/dp/B078H9R4P3"><strong>Kids Court (Pretzel Labs)</strong></a>:<strong> </strong>This skill teaches kids about the judicial system by allowing them to take their naughty friends, siblings or parents to Kids Court for a ruling from the Honorable Judge Lexy. Customers will learn how to articulate themselves clearly while presenting their case to Judge Lexy. Customers can play the judge in other kids’ trials once a day for free, or purchase the Supreme Court premium pack, which allows them to take as many cases as they want to judge.</p> <p><strong><a href="https://smile.amazon.com/gp/product/B07L1N278F">You Choose Superman Adventures (Capstone)</a></strong>: This skill entertains kids with an action-packed, interactive adventure with America’s favorite super hero, Superman. Customers will help Superman protect the citizens of Earth and Metropolis, and defeat the evil plans of the most cunning and powerful super-villains. Customers get the first story, Metropolis Mayhem, for free and then can purchase additional stories including Apokolips Invasion, Metallo Attacks!, and Superman Day Disaster.</p> <p><strong><a href="https://www.amazon.com/Universatile-Travel-Quest/dp/B078WPHCLT/">Travel Quest (Universatile)</a></strong>: This skill delights kids by taking them on a tour around the world, stopping at various countries and teaching them about the culture, history and landmarks. Each country includes ten destinations, 20 questions and 20 fun facts sure to provide hours of entertainment and education. Customers can access 6 countries for free, or can purchase additional themed country packs, such as the “Mediterranean Cruise Pack”, which provide more countries to travel to and learn about.</p> <p><a href="https://www.amazon.com/gp/product/B07HK3XHSW"><strong>Animal Sounds (LC Publishing)</strong></a>: This skill takes kids on a journey across the seven continents and into the vast oceans to learn about animals of different shapes and sizes. All customers will hear the animal sounds, while customers with a screen-enabled device are able to see the animals they’re learning about. Customers can access the continental pack for free, which contains some animal sounds to choose from, or can purchase the mega pack, which grants access to all of the continents plus an Oceanic pack of additional unique sounds. The mega pack also enables customers to use their Echo Buttons to request a new animal sound.</p> <p><strong><a href="https://www.amazon.com/dp/B07KPPMFVN">Master Swords (Touchpress)</a></strong>: This skill teaches kids how to spell through a fun, captivating game. The mission is to retrieve their Uncle’s stolen swords from grubby gremlins, hideous orcs, wicked tongued witches and a number of other fantastical creatures by using words as their weapon. As kids spell words correctly, they advance to higher levels and get closer to retrieving the swords. Customers can access the first kingdom and one sword for free, or can purchase the premium experience which allows them to access four kingdoms with the opportunity to collect up to seven swords across 1,000+ words to spell.</p> <p>We encourage you to engage with these premium kid skills to get a sense of how different developers are building delightful premium experiences for the family. In addition to the above skills, which are live today, we will soon be launching premium kid skills from names that families know and love such as Ghostbusters (Sony) and more. Stay tuned to the <a href="https://www.amazon.com/alexa-skills/b?ie=UTF8&amp;node=13727921011">Alexa Skill Store</a> for updates on these skill launches.</p> <h2><a></a><a>Learn More and Apply for the ISP for Kid Skills Preview</a></h2> <p>Check out the resources below to learn more about how to build premium kids skills. You can also apply to participate in the ISP for kid skills preview, by filling out a short form <a href="https://alexa.design/kid-survey">here</a>. We will notify you if your application is selected.</p> <ul> <li><a href="https://www.youtube.com/watch?v=ShkSbRM-1BQ&amp;feature=youtu.be">Webinar: How to Build Engaging Kid Skills for Alexa</a></li> <li><a href="https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/alexa-skills-kit/guide/BuildingStellarKidSkills_asV1?aliId=eyJpIjoieGxTanZQc1wva3NZUDRYaTciLCJ0IjoiVTBBaXBFXC9EVmdVZlwvN3VVeEFnUGR3PT0ifQ%253D%253D">Guide: 6 Tips for Building Stellar Kid Skills</a></li> <li><a href="https://developer.amazon.com/de/blogs/alexa/post/38e7a87d-2ba2-465a-b038-65ac9576027d/10-more-tips-for-building-stellar-alexa-skills-for-kids">Blog: 10 More Tips for Building Stellar Alexa Skills for Kids</a></li> <li><a href="https://developer.amazon.com/blogs/alexa/post/7ffad993-15bf-42b2-9ffb-4e82a5d7cebe/kid-skills-alexa-skills-certification">Blog: Certification Tips for Alexa Kid Skills</a></li> <li><a href="https://m.media-amazon.com/images/G/01/mobile-apps/dex/alexa/design-assets/ASKMakeMoneyGuide20190325.pdf?aliId=eyJpIjoiSkVvVlFieUpyMjFxY25XMSIsInQiOiJ4U1RleXZSWlNjZHJqXC9UY3lnQUNGUT09In0%253D">Guide: Make Money with Your Alexa Skills</a></li> <li><a href="https://developer.amazon.com/blogs/alexa/post/8019524b-6a98-4b7e-9995-c5d583696905/add-in-skill-purchasing-directly-from-the-alexa-developer-console">Blog: Add In-Skill Purchasing (ISP) Directly from the Alexa Developer Console</a></li> </ul> /blogs/alexa/post/184e2a15-6929-4528-b9d1-0880da6379f1/troubleshoot-skills-beta-testing ベータテストの実施にあたってよく見られる問題 Nahoko Hirabayashi 2019-06-14T07:49:50+00:00 2019-06-14T08:22:59+00:00 <p>Alexaスキルのベータテストツールとは、本番環境にリリースする前にスキルをベータ版としてテストするために使用するツールです。今回は、ベータテストの管理者がスキルのテスト実施者(ベータテスター)にテストの実施を依頼する際によくみられる問題2例と解決策をご紹介します。</p> <p>Alexaスキルのベータテスト機能とは、本番環境にリリースする前にスキルをベータ版としてテストするために使用するツールです。ベータテストの管理者は、他のユーザーを招待してスキルをテストしてもらい、フィードバックを受け取ることができます。<a href="https://developer.amazon.com/ja/docs/custom-skills/skills-beta-testing-for-alexa-skills.html#set-up-a-beta-test-for-a-skill">ベータテストツールのセットアップ方法</a>はこちらを参照してください。</p> <p>今回は、ベータテストの管理者がスキルのテスト実施者(ベータテスター)にテストの実施を依頼する際によくみられる問題2例と解決策をご紹介します。</p> <p>&nbsp;</p> <h3><strong>ケース</strong>1:&nbsp;&nbsp;<strong>ベータテスターに招待メールが届かない</strong></h3> <p>ベータテストのスキル管理者は、次の点をベータテスターに確認してください。</p> <ul> <li>招待メールが迷惑メールフォルダに入っていないか</li> <li>ベータテストに登録されているEメールアドレスに誤りがないか</li> <li>テストを実施しようとしているAlexa対応デバイスにログインしているアカウントおよびアマゾンのお買い物用のアカウントが、ベータテストに登録されているEメールアドレスと異なっていないか</li> </ul> <p>&nbsp;</p> <p>上記の点に問題がない場合、スキル管理者は以下の手順を試してください。</p> <h4>&lt;解決策1&gt; ベータテスターにリマインダーを送信する</h4> <p>1. <a href="https://developer.amazon.com/ja">開発者コンソール</a>にログイン</p> <p>2. スキル一覧の「ベータテストの管理」欄に移動し、ベータテストを展開表示</p> <p>3. 「リマインダーを送信」をクリック</p> <h4>&lt;解決策2&gt; 管理者のEメールアカウントからベータテスターに招待用URLリンクを送信する</h4> <p>1. <a href="https://developer.amazon.com/ja">開発者コンソール</a> &gt; スキル一覧の「ベータテストの管理」欄に移動</p> <p>2. ベータテストを展開表示</p> <p>3. 招待用URLをコピーし、管理者のEメールアカウントからベータテスターに直接送信</p> <pre> <code>注: 日本語スキルの場合、Webブラウザで招待URLにアクセスすると、USのAlexaアプリにリンクされるので、スマホ版(アプリ名:Amazon Alexa)を使用してください。また、あらかじめ日本のアカウントでAlexaアプリにログインしておかないとUSのAlexaアプリにリンクされてしまうので注意しましょう。</code></pre> <h3>&nbsp;</h3> <h3><strong>ケース</strong>2:&nbsp;&nbsp;<strong>スキルを起動できない</strong></h3> <p>招待メールを受信後、スキルを起動できない場合は、ベータテスターが使用するAlexa対応デバイスの設定言語とスキルの言語モデルが一致しているかを確認してください。</p> <p>スキルを使用するには、Alexa対応デバイスの設定言語とスキルの言語モデルが一致する必要があります。例えば、日本語のAlexaスキルをテストするには、日本語版のAlexa対応デバイス・アカウントでないとテストが実施できません。</p> <p>ベータテスターはAlexaアプリにログインして、ホスト名がalexa.amazon.co.jpと表示されているか確認してください。</p> <p>1. Alexaアプリ <a href="https://alexa.amazon.co.jp/">https://alexa.amazon.co.jp</a> にログイン</p> <p>2. 設定タブをクリック</p> <p>3. 一般&gt;Alexaアプリのバージョンをクリック</p> <p>Alexaアプリにログインできないか、またはドメイン名がalexa.amazon.comと表示されている場合は、USのアカウントが作成されてしまっている可能性があります。詳細は「<a href="https://developer.amazon.com/ja/blogs/alexa/post/9f852a38-3a44-48bd-b78f-22050269d7c7/hamaridokoro">Alexa 開発者アカウント作成時のハマりどころ</a>」を参照してください。</p> <p>&nbsp;</p> <p>今回ご紹介したベータテストツールについての詳細は、技術資料の「<a href="https://developer.amazon.com/ja/docs/custom-skills/skills-beta-testing-for-alexa-skills.html">Alexaスキルのベータテストを行う</a>」でもご確認いただけます。</p> /blogs/alexa/post/32f8381b-1b30-4f42-bbcd-4dfad6605eb5/active-learning-algorithmically-selecting-training-data-to-improve-alexa-s-natural-language-understanding Active Learning: Algorithmically Selecting Training Data to Improve Alexa’s Natural-Language Understanding Larry Hardesty 2019-06-13T13:00:00+00:00 2019-06-13T13:23:05+00:00 <p>New approach to &quot;active learning&quot;, or automatically selecting training examples for machine learning, improves the performance of natural-language-understanding system by 7% to 9%.</p> <p>Alexa’s ability to respond to customer requests is largely the result of machine learning models trained on annotated data. The models are fed sample texts such as “Play the Prince song 1999” or “Play River by Joni Mitchell”. In each text, labels are attached to particular words — SongName for “1999” and “River”, for instance, and ArtistName for Prince and Joni Mitchell. By analyzing annotated data, the system learns to classify unannotated data on its own.</p> <p>Regularly retraining Alexa’s models on new data improves their performance. But annotation is expensive, so we would like to annotate only the most informative training examples — the ones that will yield the greatest reduction in Alexa’s error rate. Selecting those examples automatically is known as <em>active learning</em>.</p> <p>Last week, at the annual&nbsp;meeting of the North American Chapter of the Association for Computational Linguistics (NAACL), we presented a <a href="https://arxiv.org/pdf/1810.03450.pdf" target="_blank">new approach</a> to active learning that, in experiments, improved the accuracy of machine learning models by 7% to 9%, relative to training on randomly selected examples.</p> <p>We compared our technique to four other active-learning strategies and showed gains across the board. Our new approach is 1% to 3.5% better than the best-performing approach previously reported. In addition to extensive testing with previously annotated data (in which the labels were suppressed to simulate unannotated data), we conducted a smaller trial with unlabeled data and human annotators and found that our results held, with improvements of 4% to 9% relative to the baseline machine learning models.</p> <p>The goal of active learning is to canvass as many candidate examples as possible to find those with the most informational value. Consequently, the selection mechanism must be efficient. The classical way to select examples is to use a simple linear classifier, which assigns every word in a sentence a weight. The sum of the weights yields a score, and a score greater than zero indicates that the sentence belongs to a particular category.</p> <p>For instance, if the classifier is trying to determine whether a sentence belongs to the category <em>music</em>, it would probably assign the word “play” a positive weight, because music requests frequently begin with the word “play”. But it might assign the word “video” a negative weight, because that’s a word that frequently denotes the customer’s desire to play a video, and the video category is distinct from the music category.&nbsp;</p> <p>Such weights are learned from training examples. During training, the linear classifier is optimized using a <em>loss function</em>, which measures the distance between its performance and perfect classification of the training data.</p> <p>Typically, in active learning, examples are selected for annotation if they receive scores close to zero — whether positive or negative — which means that they are near the decision boundary of the linear classifier. The hypothesis is that hard-to-classify examples are the ones that a model will profit from most.</p> <p>Researchers have also investigated committee-based methods, in which linear models are learned using several different loss functions. Some loss functions emphasize getting the aggregate statistics right across training examples; others emphasize getting the right binary classification for any given example; still others impose particularly harsh penalties for giving the wrong answer with high confidence; and so on.<br /> <img alt="active_learning.jpg" src="https://m.media-amazon.com/images/G/01/DeveloperBlogs/AlexaBlogs/default/active_learning.jpg._CB443745932_.jpg?t=true" style="display:block; height:412px; margin-left:auto; margin-right:auto; width:350px" /></p> <p style="text-align:center"><sub><em>A graph showing how different loss functions (black lines) divide training data in different ways. Easily classified examples (red and green X’s) are less informative than examples that fall closer to classification boundaries (grey X’s).&nbsp;</em></sub></p> <p>Traditional committee-based methods also select low-scoring examples, but they add another criterion: at least one of the models must disagree with the others in its classification. Again, the assumption is that hard-to-classify examples will be the most informative.</p> <p>In our experiments, we explored a variant on the committee-based approach. First, we tried selecting low-scoring examples on which the majority of linear models have scores greater than zero. Because this majority positive filter includes examples with all-positive scores, it yields a larger pool of candidates than the filter that enforces dissent. To select the most informative examples from that pool, we experimented with several different re-ranking strategies.</p> <p>Most importantly, we used a conditional-random-field (CRF) model to do the re-ranking. Where the linear models classify requests only according to domain — such as music, weather, smart home, and so on — the CRF models classify the individual words of the request as belonging to categories such as ArtistName or SongName.&nbsp;</p> <p>If the CRF easily classifies the words of a request, the score increases; if the CRF struggles, the score decreases. (Again, low-scoring requests are preferentially selected for annotation.) Adding the CRF classifier does not significantly reduce the efficiency of the algorithm because we execute the re-ranking only on examples where the majority of models agreed.&nbsp;</p> <p>For re-ranking, we add the committee scores and then take the absolute value of the sum. This permits individual models on the committee to provide high-confidence classifications, so long as strong positive scores are offset by strong negative scores.</p> <p>The committee approaches reported in the literature enforced dissent among the models; interestingly, using the criterion of majority scores greater than zero yielded better results, even without the CRF. With the CRF, however, the error rate shrank by an additional 1% to 2%.</p> <p><em>Stan Peshterliev is a senior applied scientist in the Alexa AI Natural Understanding group.</em></p> <p><a href="https://arxiv.org/pdf/1810.03450.pdf" target="_blank"><strong>Paper</strong></a>: “Active Learning for New Domains in Natural Language Understanding”</p> <p><a href="https://developer.amazon.com/alexa/science" target="_blank"><strong>Alexa science</strong></a></p> <p><strong>Acknowledgments</strong>: John Kearney, Abhyuday Jagannatha, Imre Kiss, Spyros Matsoukas</p> <p><strong>Related</strong>:</p> <ul> <li><a href="https://developer.amazon.com/blogs/alexa/post/9e8392c6-5476-4a34-a2d8-c4e479677954/new-speech-recognition-experiments-demonstrate-how-machine-learning-can-scale" target="_blank">New Speech Recognition Experiments Demonstrate How Machine Learning Can Scale</a></li> <li><a href="https://developer.amazon.com/blogs/alexa/post/e5f41b49-0b4d-4aef-9b90-2bb7f68c0705/to-correct-imbalances-in-training-data-don-t-oversample-cluster" target="_blank">To Correct Imbalances in Training Data, Don’t Oversample: Cluster</a></li> <li><a href="https://developer.amazon.com/blogs/alexa/post/6355a6b0-a27d-4baa-94a3-a7b1d74c0afd/leveraging-unannotated-data-to-bootstrap-new-functions-more-quickly">Leveraging Unannotated Data to Bootstrap Alexa Functions More Quickly</a></li> <li><a href="https://developer.amazon.com/blogs/alexa/post/3ac41587-f262-4fec-be60-2df2f64b9af9/the-role-of-context-in-redefining-human-computer-interaction" target="_blank">The Role of Context in Redefining Human-Computer Interaction</a></li> <li><a href="https://developer.amazon.com/blogs/alexa/post/7dde86fa-0a4f-4984-82d1-7a7d1282fb0c/machine-translation-accelerates-how-alexa-learns-new-languages" target="_blank">Machine Translation Accelerates How Alexa Learns New Languages</a></li> </ul> /blogs/alexa/post/6dd2ece8-7dcb-4380-9b25-193916b00938/how-to-make-an-api-request-from-your-alexa-skill-using-python How to Make an API Request from Your Alexa Skill Using Python Jennifer King 2019-06-12T14:00:00+00:00 2019-06-12T14:00:00+00:00 <p>In this example skill, we look at one of the most popular methods you can use to call an external API through your Alexa skill using the “Requests” library in Python.</p> <p style="margin-left:0in; margin-right:0in">As we <a href="https://developer.amazon.com/alexa/voice-design">design and create Alexa skills</a> with increasing complexity and capabilities, the need arises to have skills interact with remote APIs and web servers. Many services we consume are accessible via an API, such as weather forecasts, geolocation services, Twitter feeds, and so on. At some point, every developer will run into a situation where they’ll need to access data by making HTTP requests to an API. HTTP requests allow you to fetch data from a remote source. It could be an API, a website, or something else.</p> <p style="margin-left:0in; margin-right:0in">Making HTTP requests is a core functionality for modern languages, and when it comes to Python there are a fair amount of solutions to this problem, both built into the language and by the developer community. In this example skill, we look at one of the most popular methods you can use to call an external API through your Alexa skill using the “Requests” library in Python.</p> <h2>Understanding the Voice Interaction</h2> <p style="margin-left:0in; margin-right:0in">To make it simple, we’re going to use a fact skill as our base. In this example, our customers will interact with the skill by asking for a fact about a number. Let’s take a look at a simple interaction between our skill and our customer:</p> <p style="margin-left:30.0pt; margin-right:0in"><strong><em>Customer: </em></strong><em>Alexa, ask number facts to give me a fact about seven.</em></p> <p style="margin-left:30.0pt; margin-right:0in"><strong><em>Alexa:</em></strong><em> Seven is the number of main stars in the constellations of the Big Dipper and Orion.</em></p> <p style="margin-left:0in; margin-right:0in">When our customer says, “give me a fact about seven” the <strong>GetNumberFactIntent</strong> is triggered and the <strong>number</strong> slot is set to ‘7’. Our skill code makes an http get request to <a href="http://numbersapi.com/" target="_blank">numbersapi.com</a> to get a random fact about the number ‘7’. You can test out the API by typing: http://numbersapi.com/7 into your browser.</p> <h2>Understanding the Hard-Coded Facts</h2> <p style="margin-left:0in; margin-right:0in">When we first built our number facts skill, we hardcoded our facts straight into the code. Let’s take a moment to understand how the code works before we update our code to get the facts from <a href="http://numbersapi.com/" target="_blank">numbersapi.com.</a></p> <p style="margin-left:0in; margin-right:0in">First, we defined an object called <strong>number_facts</strong>. It functions as a lookup table. Take a moment to look through the table:</p> <pre> <code>number_facts = { &quot;1&quot;: &quot;is the number of moons orbiting the earth.&quot;, &quot;2&quot;: &quot;is the number of stars in a binary star system (a stellar system consisting of two stars orbiting around their center of mass).&quot;, &quot;3&quot;: &quot;is the number of consecutive successful attempts in a hat trick in sports.&quot;, &quot;4&quot;: &quot;is the number of movements in a symphony.&quot;, &quot;5&quot;: &quot;is the number of basic tastes (sweet, salty, sour, bitter, and umami).&quot;, &quot;6&quot;: &quot;is the number of fundamental flight instruments lumped together on a cockpit display.&quot;, &quot;7&quot;: &quot;is the number of main stars in the constellations of the Big Dipper and Orion.&quot;, &quot;8&quot;: &quot;is the number of bits in a byte.&quot;, &quot;9&quot;: &quot;is the number of innings in a regulation, non-tied game of baseball.&quot;, &quot;10&quot;: &quot;is the number of hydrogen atoms in butane, a hydrocarbon.&quot;, &quot;11&quot;: &quot;is the number of players in a football team.&quot; }</code></pre> <p style="margin-left:0in; margin-right:0in">If our customer asked for a fact about ‘7’, we can pass it to <strong>number_facts</strong> to get the fact. The code to do that would look like:</p> <pre> <code>number_facts[&quot;7&quot;]</code></pre> <p style="margin-left:0in; margin-right:0in">Since we don’t want to hardcode the number 7, let’s take a look at how we’d look up the fact for our number slot.</p> <pre> <code>the_number = handlerInput.requestEnvelope.request.intent.slots.number.value the_fact = number_facts[the_number]</code></pre> <p style="margin-left:0in; margin-right:0in">Below is the sample code for GetNumberFactHandler before we make any updates:</p> <pre> <code>class GetNumberFactHandler(AbstractRequestHandler): &quot;&quot;&quot;Handler for get number fact intent.&quot;&quot;&quot; def can_handle(self, handler_input): # type: (HandlerInput) -&gt; bool return (is_request_type(&quot;LaunchRequest&quot;)(handler_input) or is_intent_name(&quot;GetNumberFactIntent&quot;)(handler_input)) def handle(self, handler_input): # type: (HandlerInput) -&gt; Response logger.info(&quot;In GetNumberFactHandler&quot;) # to enable randint, add &quot;from random import randint&quot; at start of file the_number = None if is_request_type(&quot;IntentRequest&quot;)(handler_input): the_number = handler_input.request_envelope.request.intent.slots[&quot;number&quot;].value if the_number is None: the_number = str(randint(1,11)) the_fact = the_number + &quot; &quot; + number_facts[the_number] speech = the_number + &quot; &quot; + the_fact + &quot; Would you like to hear another fact?&quot; handler_input.response_builder.speak(speech).ask(speech) return handler_input.response_builder.response</code></pre> <p style="margin-left:0in; margin-right:0in">We simply access the <strong>number</strong> slot and look up the fact using the <strong>number_facts</strong> object and then have our skill tell the user the fact by returning a response using the <strong>response_builder</strong>.</p> <h2>Using the “Requests” Library</h2> <p>Now that we understand the basics of this fact skill, let’s look at how to access information outside of our skill, by using the requests library to access facts from <a href="http://numbersapi.com/" target="_blank">numbersapi.com</a></p> <p style="margin-left:0in; margin-right:0in">The requests library is the de facto standard for making HTTP requests in Python. It abstracts the complexities of making requests behind a beautiful, simple API so that you can focus on utilizing data and interacting with services in your skill.</p> <p style="margin-left:0in; margin-right:0in">Let’s see how we’ve modified the code to use the “requests” library to call our API.</p> <p style="margin-left:0in; margin-right:0in"><strong>Step 1: Included the requests library in our skill using the import statement.</strong></p> <pre> <code> import requests</code></pre> <p style="margin-left:0in; margin-right:0in"><strong>Step 2: Call the requests.get method from within your intent(GetNumberFactIntent) to send a query (number requested by the user) to the API, and respond back with the result.</strong></p> <pre> <code>class GetNumberFactHandler(AbstractRequestHandler): &quot;&quot;&quot;Handler for get number fact intent.&quot;&quot;&quot; def can_handle(self, handler_input): # type: (HandlerInput) -&gt; bool return (is_request_type(&quot;LaunchRequest&quot;)(handler_input) or is_intent_name(&quot;GetNumberFactIntent&quot;)(handler_input)) def handle(self, handler_input): # type: (HandlerInput) -&gt; Response logger.info(&quot;In GetNumberFactHandler&quot;) the_number = None if is_request_type(&quot;IntentRequest&quot;)(handler_input): the_number = handler_input.request_envelope.request.intent.slots[&quot;number&quot;].value if the_number is None: the_number = str(randint(1,11)) url = &quot;http://numbersapi.com/&quot; + the_number response = requests.get(url) if response.status_code == 200: the_fact = response.text else: the_fact = &quot;I had trouble getting a fact about &quot; + the_number + &quot;.&quot;; speech = the_fact + &quot; Would you like to hear another fact?&quot; handler_input.response_builder.speak(speech).ask(speech) return handler_input.response_builder.response </code></pre> <p style="margin-left:0in; margin-right:0in">As you can see, the “requests” module makes it super simple for us to call our API. All we had to do was specify the URL for the API to be called, and the response is made available to us inside the text property, which we can then use as part of our response. If the response is JSON, you can use the json property instead.</p> <p style="margin-left:0in; margin-right:0in">Whenever calling an API you will want to include error checking. I chose to check the response code to ensure it was a success code (200). You might choose to use a try-except block.</p> <p style="margin-left:0in; margin-right:0in">If you didn’t edit your skill code in the Lambda console, the next step would be to zip up your lambda_function.py file along with other modules to create a deployment package and upload it to your Lambda function. To learn more about how to do that, read <a href="https://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html" target="_blank">AWS Lambda Deployment Package in Python</a>.</p> <div style="border-bottom:none windowtext 1.0pt; padding:0in 0in 3.0pt 0in"> <h2>More Resources</h2> <ul> <li><a href="https://developer.amazon.com/post/Tx1UE9W1NQ0GYII/Publishing-Your-Skill-Code-to-Lambda-via-the-Command-Line-Interface">Publishing Your Skill Code to Lambda via the Command Line Interface</a></li> <li><a href="https://developer.amazon.com/docs/smapi/quick-start-alexa-skills-kit-command-line-interface.html">Quick Start Alexa Skills Kit Command Line Interface (ASK CLI)</a></li> <li><a href="https://github.com/alexa/alexa-skills-kit-sdk-for-python">Alexa Skills Kit SDK for Python</a></li> <li><a href="https://aws.amazon.com/sdk-for-python/" target="_blank">AWS SDK for Python</a></li> <li><a href="https://www.npmjs.com/package/request">Requests Library for Python</a></li> <li><a href="https://developer.amazon.com/docs/custom-skills/send-the-user-a-progressive-response.html">Send the User a Progressive Response</a></li> <li><a href="https://developer.amazon.com/blogs/alexa/post/28368692-a0b9-4579-b129-e6793bef7848/alexa-skill-recipe-update-making-http-requests-to-get-data-from-an-external-api-using-the-ask-software-development-kit-for-node-js-version-2">Alexa Skill Recipe Update: Making HTTP Requests to Get Data from an External API Using the ASK Software Development Kit for Node.js Version 2</a></li> </ul> </div> /blogs/alexa/post/6e4350d9-cbae-4279-8c64-813a9e4522af/build-a-strong-language-model-to-get-the-most-out-of-dynamic-entities Build a Strong Language Model to Get the Most Out of Dynamic Entities Jennifer King 2019-06-11T14:00:00+00:00 2019-06-11T14:00:00+00:00 <p><img alt="" src="https://m.media-amazon.com/images/G/01/DeveloperBlogs/AlexaBlogs/default/NLU-slot_blog.png._CB459321176_.png?t=true" style="height:480px; width:1908px" /></p> <p>We recently launched dynamic entities, which can help you personalize Alexa skill experiences by adapting your interaction model at run time without edits, builds, or re-certification. Here are some use cases where you can leverage dynamic entities.</p> <p><img alt="" src="https://m.media-amazon.com/images/G/01/DeveloperBlogs/AlexaBlogs/default/NLU-slot_blog.png._CB459321176_.png?t=true" style="height:480px; width:1908px" /></p> <p>We recently launched <a href="https://developer.amazon.com/blogs/alexa/post/db4c0ed5-5a05-4037-a3a7-3fe5c29dcb65/use-dynamic-entities-to-create-personalized-voice-experiences">dynamic entities, </a>which can help you personalize Alexa skill experiences by adapting your interaction model at run time without edits, builds, or re-certification. Given dynamic entities offer a new <a href="https://developer.amazon.com/docs/custom-skills/define-synonyms-and-ids-for-slot-type-values-entity-resolution.html#intentrequest-changes">authority</a> source, custom slot values, and a new directive, there's a lot to take in. But where do dynamic entities really shine and how can you best leverage them? I'm excited to share a few use cases where you can leverage dynamic entities to personalize and improve the user experience of your Alexa skill.</p> <h2>Building the Foundation: The Static Language Model</h2> <p>Before you get started with dynamic entities, you'll need a solid foundation in the form of your language model. Just simply throwing all of your slot values into dynamic entities and leaving a skeleton in your static model is going to leave you hearing error messages and failures. Your language model defines the interactions Alexa expects to fulfill with your skill and dynamic entities only exist for a short duration. If you leave your static language model empty, then there isn't much for Alexa to train against and therefore you'll hear more error instances where nothing quite matches. Let's take a look at an example.</p> <p>A trivia skill has an intent to handle user guesses and answers called AnswerIntent. The intent accepts a single slot type of ANSWER. This skill surfaces new questions weekly and dynamic entities will allow me to fill in answers at run time. This is exactly what I was hoping for so I only load a single value in the ANSWER slot since I intend to update so frequently. My static catalog looks something like this:</p> <pre> <code>{ &quot;name&quot;: &quot;ANSWER&quot;, &quot;values&quot;: [ { &quot;name&quot;: { &quot;value&quot;: &quot;pizza&quot; } } ] } </code></pre> <p>Except in testing, none of my responses are routing to the AnswerIntent. The single value I provided is successful, but I can't consistently resolve answers for trivia questions.</p> <p><strong>Define a variety of slot values to reflect the dynamic values you are uploading</strong>. If you have a small set of sample utterances and slots values, then there isn't much for Alexa to train against and you'll see more instances of mismatched intents. My skill is a master of “pizza” but not much else.</p> <p>Instead of that single value, I loaded the ANSWER slot type in my language model with three weeks worth of slot values of a variety of lengths (one word, two word, and three word) and suddenly my AnswerIntent is capturing responses more consistently.</p> <p><strong>Aim to have only one single word intent.</strong> These are intents where there is only a single slot value as the sample utterance.</p> <pre> <code>{ &quot;name&quot;: &quot;AnswerOnlyIntent&quot;, &quot;slots&quot;: [ { &quot;name&quot;: &quot;answer&quot;, &quot;type&quot;: &quot;ANSWER&quot; } ], &quot;samples&quot;: [ &quot;{answer}&quot; ] } </code></pre> <p>Combine sessionAttributes for the the state the user is at in the skill, dynamic entities, and the intent context to determine where to route the user. For my trivia example, I allow users to select a trivia round by number that slots to the SelectRound intent. Both AnswerIntent and SelectRound intent potentially accept numbers as valid slot values. To avoid confusion with my ANSWER slot type, once a user starts a game I can store a state in the sessionAttributes to indicate a game is in progress and route number answers to the AnswerIntent handler rather than the SelectRound handler.</p> <p><strong>Use slot-based grammars where you find yourself otherwise creating similar or overlapping intents. </strong>My trivia skill allows users to select a category. Rather than have an intent for each category I can use a CATEGORY slot type to reflect the user's choice. Slot-based grammars allows me to simplify repeating phrases in my utterances such as “who,” “what,” “when,” and “where.”</p> <p>For a generic example: The InformationIntent includes utterances: &quot;{interrogative} did {event} take place?&quot;, &quot;{interrogative} is {event}&quot;, and &quot;{interrogative} {event}&quot;</p> <ol> <li>Interrogative: &quot;What,&quot; &quot;Where,&quot; &quot;Why,&quot; &quot;How,&quot; &quot;When&quot;</li> <li>Event: &quot;Burning Man,&quot; &quot;The Great Depression,&quot; &quot;Pax Romana,&quot; etc.</li> </ol> <p><strong>Static slot values customize and train a model, dynamic slot values customize a point in time interaction</strong>. Dynamic entities only exist at runtime and only for a portion of an interaction. Keeping with the trivia skill example, one week I have a category of “Trees” and want to capture “fur” as a synonym for “fir tree”. I can have that synonym only exist dynamically so that when I pivot to a “Fabrics” category the “fur” value isn't trying to route to a tree.</p> <p>However, I want “fur” and “fir” to exist as values for my ANSWER slot type for future trivia interactions. Adding those values to my static model ensures the model is trained to expect these types of answers.</p> <h2>Use Case: Frequent Content Updates</h2> <p>Now that I have a good foundation in my language model to start building against, let's look at how to get the most out of dynamic entities for my trivia skill.</p> <p>Fresh and frequently updated content keeps users coming back to a skill. There is both the allure of the unknown in the form of “What is coming this week?” as well as the idea that the interaction can't be exhausted in the short term. However, any change to the language model means going through certification. This ensures that the experience is consistent and reliable for users across releases, but certification also takes time. As exciting as trees are, I doubt my players really want to answer the same tree trivia questions for weeks on end.</p> <p>To create a good balance of dynamic and static content for this use case:</p> <ol> <li><strong>Narrow the acceptable results</strong> - My ANSWER slot type has 150 values, but my dynamic entities only use the acceptable answers for that round.<br /> <br /> <em>Question: The name of the fabric chiffon comes from a French word that translates as which of the following?</em><br /> <em>A. Cloth B. Veil C. Transparent D. Delicate</em><br /> <br /> My dynamic entities would include values for “cloth,” “veil,” “transparent,” and “delicate” for this question. Keep in mind dynamic entities only support 100 values so skills that leverage large dynamic answer sets are not good candidates for this method. An example being a slot type for Books in which over 100 book titles are acceptable answers.<br /> &nbsp;</li> <li><strong>Leverage the AMAZON.Fallback intent and the static catalog for incorrect answers</strong> - In the fabric category example, my static ANSWER slot type has at least 146 values that a user could say but are incorrect (150 less the four valid answer choices). This doesn't mean load a slot with hundreds of incorrect values as you might find that intent triggering for everything, but it makes the static catalog a second source for possible utterances.<br /> <br /> My trivia skill right now has slot values for trees, fabric, and colors. In testing I say “banana” and the skill simply doesn't respond. Digging into the logs I notice that nothing is triggered. “Bananas” is out of the scope of my language model. If I want to catch that phrase because I expect users might say “banana” often then I could add it to the AMAZON.Fallback intent and flag the answer as incorrect.<br /> <br /> Combining the static slot values with the AMAZON.Fallback intent and state management can help me to keep users in the skill by handling wrong answers as something other than errors.<br /> &nbsp;</li> <li><strong>Update synonyms dynamically</strong> <strong>to cover misrecognitions</strong> - We've all had it happen. A skill goes live and users start to throw all manner of phrases at it. Sometimes speech is rushed and words just don't come out right. In the short term my hands are tied, I can't update the language model and in some cases I don't want these minor errors to end up as permanent features. The solution is dynamic synonyms on slot values.<br /> <br /> My fabric category is live. I'm looking at the <strong>Intent History</strong> in the developer console and a lot of users are saying “would” for the AnswerIntent. A little further testing and I realize that “wool” is being misheard as “would.” I don't use utterances with “would” anywhere else in the skill and I could add “would” as a synonym for “wool” but the fabric category is only around for a short period of time and my users are affected now. I can quickly update my dynamic entities for that question to add the synonym, test in my development environment to confirm, and then quickly push the fix live. My users are getting their trivia points and, once the fashion category retires, I don't have to worry about conflicting utterances if I ever need “would” in another part of the skill.</li> </ol> <p>For the frequent content updater, dynamic entities are a great way to supplement the static language model and increase the chances of matching user utterances to the intended result rather than a possible result in a sea of slightly correct answers.</p> <h2>Use Case: State-Specific Content</h2> <p>A use case that <a href="https://developer.amazon.com/blogs/alexa/post/db4c0ed5-5a05-4037-a3a7-3fe5c29dcb65/use-dynamic-entities-to-create-personalized-voice-experiences">our previous blog</a> touched on was using dynamic entities for personalization. Two forms of personalization are user specific and state specific:</p> <ol> <li><strong>Narrow results to the user's preference</strong> - For my example, I have a skill with multiplayer chess as a core feature. Players can add other users to a friends list and select their preferred opponent when the EnterGameLobby intent is triggered.<br /> <br /> Now I certainly don't want to add all these usernames to my slot values. New accounts are created every day and there is no way I can keep up with demand. I also don't want to bulk load these users as dynamic entities. If the skill becomes popular, I will quickly pass the 100 value limit and putting the skill through certification every day is not ideal. Through combining generic slots my skill gets all usernames, but I want to surface the friends list first. This is the easy part. After a user triggers the EnterGameLobby intent to prepare to pair with another player, I can load all of the usernames in their friends list as dynamic slot values. That way if they ask to play with their friend “BlueOranges,” I won't accidentally match them with player “BlueOrange” who is valid player, but not the one they asked for.<br /> &nbsp;</li> <li><strong>Categorize similar values based on the user state </strong>- State specific content means altering slot values based on where a user is at in a skill.<br /> <br /> Let's pivot to another genre: groceries. A user wants milk from the fictional brand Plain. Plain has a large catalog of dairy based products. I could asks for brand and item type individually. However, item type also includes other non-dairy items because I am serving more than one brand. To solve for this, when a user supplies the brand name Plain, I dynamically load the Plain catalog and treat items in the static catalog as incorrect choices. This also works in reverse where when users ask for “cheese” I only load brands that sell cheese. With this setup I have fewer false positives. Keep in mind that dynamic entities last for 30 minutes. Make sure you use the CLEAR updateBehavior to remove unneeded or conflicting dynamic values before the next part of the dialog.</li> </ol> <p>There are many more ways to leverage dynamic entities with other features in Alexa to create language models and experiences that are tailored to your users and their usage. The key takeaways are to build a language model that is robust and to not look at dynamic entities as a way to replace the language model but as a way to augment it.</p> <h2>Related Content</h2> <ul> <li><a href="https://developer.amazon.com/blogs/alexa/post/db4c0ed5-5a05-4037-a3a7-3fe5c29dcb65/use-dynamic-entities-to-create-personalized-voice-experiences">Use Dynamic Entities to Create Personalized Voice Experiences</a></li> <li><a href="https://developer.amazon.com/docs/custom-skills/use-dynamic-entities-for-customized-interactions.html">Technical Documentation: Dynamic Entities</a></li> <li><a href="https://developer.amazon.com/blogs/alexa/post/144d52ad-25d7-4aa6-a155-9aeeca0406df/tailor-your-alexa-skill-responses-to-deliver-personalized-voice-experiences">Hear It from a Skill Builder: Tailor Your Alexa Skill Responses to Deliver Personalized Voice Experiences</a></li> </ul> /blogs/alexa/post/11b51c0b-9794-48bf-81c1-ecadf63fede3/adapting-alexa-to-regional-language-variations Adapting Alexa to Regional Language Variations Larry Hardesty 2019-06-11T13:00:00+00:00 2019-06-11T13:49:16+00:00 <p>Natural-language-understanding system that includes both&nbsp;a generic model for a language and several locale-specific models improves accuracy by an average of 59% over individual locale-specific models.</p> <p>As Alexa expands into new countries, she usually has to be trained on new languages. But sometimes, she has to be re-trained on languages she’s already learned. British English, American English, and Indian English, for instance, are different enough that for each of them, we trained a new machine learning model from scratch.</p> <p>Ideally, we wouldn’t have to do that. When Alexa moves into a new country and encounters a language she’s already familiar with, she should be able to take advantage of her previous experience. That’s the idea behind a new <a href="https://arxiv.org/pdf/1905.00924.pdf" target="_blank">machine learning system</a> that my colleagues and I presented last week&nbsp;at the annual meeting of the North American Chapter of the Association for Computational Linguistics.</p> <p>Our system is a domain classifier, which determines the topic of a customer’s request, such as music, weather, or sports. It can also identify requests as “<a href="https://developer.amazon.com/blogs/alexa/post/ddc28801-8806-4f04-a338-8fc10e0cad28/learning-to-recognize-the-irrelevant" target="_blank">out of domain</a>”, which is important to prevent the mishandling of unintentional or garbled speech.</p> <p>The domain classifier is a multi-task model, which means that it’s trained to perform several tasks simultaneously. One of those tasks is to learn a general statistical model for a particular language, which captures consistencies across regions. Its other tasks are to learn several different locale-specific models for the same language. It bases its domain classifications on the outputs of both the general and the locale-specific models.&nbsp;</p> <p>In experiments in which we trained our model on four different variants of English, it showed accuracy improvements of 18%, 43%, 116%, and 57% versus models trained on each variant individually.</p> <p><img alt="Locale-agnostic_architecture.png" src="https://m.media-amazon.com/images/G/01/DeveloperBlogs/AlexaBlogs/default/Locale-agnostic_architecture.png._CB462220682_.png?t=true" style="display:block; height:333px; margin-left:auto; margin-right:auto; width:550px" /></p> <p style="text-align:center"><sub><em>Our new domain classifier includes both a locale-agnostic component (the &quot;shared encoder&quot;) and locale-specific components (the </em>k&nbsp;<em>location encoders). The outputs of both are combined as inputs to a bank of locale-specific classifiers (top).</em><em>&nbsp;</em></sub><br /> &nbsp;</p> <p>One reason multi-task training for domain classification is challenging is that requests to the same domain could look wildly different in different locales. Requests to the restaurant domain, for instance, would feature much different restaurant names in Mumbai than they would in London, even though customers are requesting the same services — address information, menu information, reservations, and so on.</p> <p>In such cases, relying on a single locale-specific classifier, trained on data unique to that locale, would probably yield better results than pooling the outputs of several locale-specific classifiers. In other cases, however, where requests are more uniform across locales, the outputs of several different locale-specific models could reinforce each other, improving accuracy.</p> <p>To strike a balance between these two types of cases, we use an attention mechanism, which gives different emphases — or weights — to the outputs of different locale-specific models, depending on the input. Ideally, in cases like the restaurant example, in which input data is very locale-dependent, the attention mechanism would assign almost of all of its weight to a single locale-specific model, ignoring the outputs of the other locale-specific models.</p> <p>In advance, we can identify domains that should receive this kind of treatment, because their input data is highly locale dependent. But at run time, our system doesn’t know which domain a request is intended for. Answering that question is precisely what it’s trying to do.</p> <p>We resolve this conundrum by modifying the training mechanism. At training time, we <em>do</em> know which domain each input is intended for, because the training data is labeled. During training, we evaluate the system not only on how accurately it classifies domains but also on how consistently the attention mechanism prioritizes the right locale-specific model when it receives locale-dependent data.</p> <p>The outputs of the locale-specific models are combined into a single vector, with heavily weighted outputs contributing more to the vector’s final values than lower-weighted outputs. That vector is concatenated with the output of the locale-independent model, and the combined vector passes to another network layer for domain classification.</p> <p>We evaluated this architecture using English-language data from the U.S., the U.K., India, and Canada. We trained our multi-task model on all four data sets and compared its performance to that of locale-specific models trained separately on the same data sets. That’s the experiment that yielded the accuracy improvements reported above.</p> <p>We also conducted one more experiment, in which we used adversarial training to enforce the neutrality of the locale-independent model. That is, during training, in addition to evaluating the system’s performance on domain classification accuracy and routing of locale-dependent data, we also evaluated it on how <em>badly</em> the locale-independent model predicted locales.</p> <p>This was an attempt to force the locale-independent model to extract only those characteristics of the data that were consistent across locales. In general, however, this hurt the system’s overall performance. The one exception was on the U.K. data set, where adversarial training conferred a slight performance boost. In ongoing work, we’re trying to determine the reason for that improvement.&nbsp;</p> <p><em>Young-Bum Kim is an Amazon science leader in the Alexa AI organization.</em></p> <p><a href="https://arxiv.org/pdf/1905.00924.pdf" target="_blank"><strong>Paper</strong></a>: “Locale-agnostic Universal Domain Classification Model in Spoken Language Understanding”</p> <p><a href="https://developer.amazon.com/alexa/science" target="_blank"><strong>Alexa science</strong></a></p> <p><strong>Acknowledgments</strong>: Jihwan Lee, Ruhi Sarikaya</p> <p><strong>Related</strong>:</p> <ul> <li><a href="https://developer.amazon.com/blogs/alexa/post/45276f8f-83e7-4446-855f-0bb0d5019f07/training-a-machine-learning-model-in-english-improves-its-performance-in-japanese" target="_blank">Training a Machine Learning Model in English Improves Its Performance in Japanese</a></li> <li><a href="https://developer.amazon.com/blogs/alexa/post/0535b1ff-d810-4933-a197-841bfb3fa894/cross-lingual-transfer-learning-for-bootstrapping-ai-systems-reduces-new-language-data-requirements" target="_blank">Cross-Lingual Transfer Learning for Bootstrapping AI Systems Reduces New-Language Data Requirements</a></li> <li><a href="https://developer.amazon.com/blogs/alexa/post/6355a6b0-a27d-4baa-94a3-a7b1d74c0afd/leveraging-unannotated-data-to-bootstrap-new-functions-more-quickly" target="_blank">Leveraging Unannotated Data to Bootstrap Alexa Functions More Quickly</a></li> <li><a href="https://developer.amazon.com/blogs/alexa/post/ddc28801-8806-4f04-a338-8fc10e0cad28/learning-to-recognize-the-irrelevant">Learning to Recognize the Irrelevant</a><br /> &nbsp;</li> </ul> /blogs/alexa/post/c43838d3-a9a8-4024-b28d-131743714bbf/how-to-make-isp-skill-faq-jp Alexaスキル開発トレーニングシリーズ: スキル内課金に関するFAQ Chisato Hiroki 2019-06-11T04:34:42+00:00 2019-06-11T04:34:42+00:00 <p><a href="https://developer.amazon.com/ja/blogs/alexa/post/096dc4fa-6bc0-4896-b7c9-ff8ae72070bc/how-to-make-isp-skill-in-jp">前回の記事</a>ではスキル内課金の開発手順を紹介しました。開発を進める中で様々な疑問も出てくるかと思います。そのような際に参考になるよう、今回の記事ではスキル内課金に関するFAQを紹介します。下記以外のFAQについては<a href="https://developer.amazon.com/ja/docs/in-skill-purchase/isp-faqs.html">こちら</a>のドキュメントや「<a href="https://developer.amazon.com/ja/blogs/alexa/post/146a56df-8d18-4261-928c-f92e6b12f480/">スキル内課金のベストプラクティス</a>」の記事も参考にしてください。</p> <p>&nbsp;</p> <p><a href="https://developer.amazon.com/ja/blogs/alexa/post/096dc4fa-6bc0-4896-b7c9-ff8ae72070bc/how-to-make-isp-skill-in-jp">前回の記事</a>ではスキル内課金の開発手順を紹介しました。開発を進める中で様々な疑問も出てくるかと思います。そのような際に参考になるよう、今回の記事ではスキル内課金に関するFAQを紹介します。下記以外のFAQについては<a href="https://developer.amazon.com/ja/docs/in-skill-purchase/isp-faqs.html">こちら</a>のドキュメントや「<a href="https://developer.amazon.com/ja/blogs/alexa/post/146a56df-8d18-4261-928c-f92e6b12f480/">スキル内課金のベストプラクティス</a>」の記事も参考にしてください。</p> <p>&nbsp;</p> <p><strong>Q.) ユーザはスキル内課金にPINコードを設定できますか?</strong></p> <p>A.) はい、Alexaアプリの「設定 → Alexaアカウント → 音声ショッピング」から確認コードをオンにして登録してください。</p> <p>&nbsp;</p> <p><strong>Q.) Alexaアプリで音声ショッピングがオフの場合に、ユーザがスキル内商品を買おうとするとどうなりますか?</strong></p> <p>A.) Alexa側で、音声ショッピングがオフなのでオンにするよう促す発話を自動的に行います。</p> <p>&nbsp;</p> <p><strong>Q.) 開発者はサブスクリプションの課金頻度をどのように設定できますか?</strong></p> <p>A.) 2019年6月現在は毎月または毎年の課金設定が可能です。</p> <p>&nbsp;</p> <p><strong>Q.) 開発者はサブスクリプションに試用期間を設定することはできますか?</strong></p> <p>A.) はい、1日から31日の間で試用期間を設定でき、試用期間終了時点から課金が開始されます。</p> <p>&nbsp;</p> <p><strong>Q.) ユーザがサブスクリプションをキャンセルした場合、購入したスキル内商品はすぐ無効になりますか?</strong></p> <p>A.) いいえ、次回の課金日からスキル内商品が無効になりますので、それまでは有効です。ただし開発版のスキルでは、キャンセル後すぐに無効になります。</p> <p>&nbsp;</p> <p><strong>Q.) ユーザは購入した買い切り型や消費型のスキル内商品をキャンセルすることができますか?</strong></p> <p>A.) はい、ただし買い切り・消費型をキャンセルするには、Amazonのカスタマーサービスに連絡する必要があります。</p> <p>&nbsp;</p> <p><strong>Q.) 開発者がユーザのスキル内課金をキャンセルすることはできますか?</strong></p> <p>A.) いいえ、スキル内課金のキャンセルはお客様の要求に基づきAmazonが行います。</p> <p>&nbsp;</p> <p><strong>Q.) 開発者はスキル内商品の販売状況をどこで確認することができますか?</strong></p> <p>A.) ASK開発者コンソールの「レポート」から確認可能です。</p> <p>&nbsp;</p> <p><strong>Q.) 子供向けスキルにスキル内課金を導入できますか?</strong></p> <p>A.) いいえ、2019年6月現在ではできません。</p> <p>&nbsp;</p> <p><strong>Q.) ユーザが課金アイテムを購入した後にスキルを無効化・再度有効化すると購入状況は変わりますか?</strong></p> <p>A.) In-Skill Product Serviceにはユーザの購入状況が保持されていますので、スキルが無効化・再有効化されてもユーザ体験が変わらないようにしてください。</p> <p>&nbsp;</p> <p><strong>Q.) スキル内商品のアップセルで必ず説明すべき項目はありますか?</strong></p> <p>A.) 消費型のスキル内商品の場合には、アップセルメッセージの中で商品の利用条件(アイテムの個数・あれば有効期限・何に消費するか等)を明確に説明してください。</p> <p>&nbsp;</p> <p><strong>Q.) スキル内商品のアップセルはどのようなタイミングで行えばよいですか?</strong></p> <p>A.) 例えば、ユーザが有料コンテンツにアクセスしようとした際やヘルプメッセージ内が挙げられますが、それ以外でも問題ありません。スキル内課金を導入したスキルのVUIには、直接購入のためのフローに加えてスキル内商品の説明を含むアップセルのメッセージをどこかに入れるようにしてください。</p> <p>&nbsp;</p> <p><strong>Q.) ユーザがスキル内商品を見つけやすくするにはどうすればよいですか?</strong></p> <p>A.) まずはスキル内商品について聞かれたら明確に答えましょう。「何を買える?」のように聞かれた場合にはスキル内商品の種類と、それを買うことで何ができるのかを説明してください。またスキル内商品について聞かれた場合以外でも、無料の体験をしている最中やヘルプ・終了時など適切なタイミングで、アップセルやまだ利用していない購入済み商品の案内をしてみましょう。スキル内商品の存在が知られないと購入されることもありません。ただしユーザ体験を考慮して、あまりに頻繁にアップセルすることは避けましょう。その他スキル内課金に関するカスタマーエクスペリエンスの設計については、<a href="https://developer.amazon.com/ja/docs/in-skill-purchase/customer-experience.html">こちら</a>のドキュメントも参考にしてください。</p> <p>&nbsp;</p> <p><strong>Q.) 開発者が公開済みのスキル内商品を削除することはできますか?</strong></p> <p>A.) いいえ、スキル内商品を公開後に削除することはできません。代わりにスキル内商品を無効化することは可能です。ただしサブスクリプション型の商品を無効にした場合、全てのユーザが本来の次の課金日を迎えるまでは(つまり月毎のサブスクリプションであれば1ヶ月後まで)スキル内商品のコンテンツをサポートするようにしてください。</p> <p>&nbsp;</p> <p><strong>Q.) スキル内課金を導入した場合、スキル説明文で気をつけることはありますか?</strong></p> <p>A.) &nbsp;スキル説明文およびサンプルフレーズには、スキル内商品の購入を促す発話は入れないでください。スキル内商品の説明自体は問題ありません。</p> <p>&nbsp;</p> <p><strong>Q.) スキル内課金による報酬の受け取りには税に関する情報の入力が必須ですか?</strong></p> <p>A.) はい、開発者コンソールの<a href="https://developer.amazon.com/taxinterview.html">税に関する情報のページ</a>から、ロイヤリティ収入の納税者確認インタビューを完了させてください。</p> <p>&nbsp;</p> <p><strong>Q.) スキル内課金を導入したスキルでは利用規約の用意が必要ですか?</strong></p> <p>A.) はい、スキル内課金を導入したスキルでは利用規約が必要になります。規約のWebページをご用意の上、スキル公開情報の「利用規約のURL」にそのURLを設定してください。</p> <p>&nbsp;</p> <p><strong>Q.) スマートフォンのAlexaアプリでは、スキルからスキル内商品を購入できますか?</strong></p> <p>A.) いいえ、スマートフォンのAlexaアプリや Alexa for PC ではスキル内商品を購入できません。ただし、ユーザが購入済みのコンテンツを利用することは可能です。また、開発者コンソールのシミュレータでもスキル内商品は購入できません。</p> <p>&nbsp;</p> <p><strong>Q.) スキル内商品を購入しようとすると、「すみません、このコンテンツは、お住まいの国では、現在利用できません。」というエラーになり購入できません。どうしたらよいですか?</strong></p> <p>A.) デバイスに登録のアカウントで次の設定値が「日本」になっているかどうか確認の上、なっていない場合には「日本」に設定を変更してください。「Amazon.co.jpのアカウントサービス =&gt; コンテンツと端末の管理 =&gt; 設定 =&gt; 国/地域設定」</p> <p>&nbsp;</p> <p>他にも開発上の疑問点がありましたら、<a href="https://forums.developer.amazon.com/spaces/293/index.html">Alexa開発者フォーラム</a>もご活用ください。この機会にスキル内課金に取り組んでみましょう。</p> <p><a href="https://developer.amazon.com/ja/alexa-skills-kit/training/building-a-skill">■ トレーニングコース目次 ■</a></p>