Tying Up Loose Ends

Before we can publish our skill, there are a few to-do items we should address. Specifically, there’s an intent and its associated handler that we no longer need and that should be removed. We should also review and fine-tune a few of the responses returned from a few of the built-in intent handlers. We’ll start by saying goodbye to the HelloWorldIntent.

Removing Unused Intents

When we first began working on our skill, we based it on the “Hello World” template. With the “Hello World” template came the HelloWorldIntent and its associated intent handler. That helped us get started with a working skill right away and provided a convenient and simple intent to play around with until we could add more intents. Although we could publish the skill with this intent intact, it’s really just extra baggage and needs to go.

To get rid of the HelloWorldIntent, we’ll start by deleting the HelloWorldIntent definition from the interaction model for all locales. Specifically, remove the intent definition that looks like this in all of the JSON files in skill-package/interactionModels/custom:

 {
 "name"​: ​"HelloWorldIntent"​,
 "slots"​: [],
 "samples"​: [
  ...
  ]
 },

With the intent definition gone, Alexa will no longer handle requests for utterances like “hello” or “say hello”. Since those requests will no longer be dispatched to the HelloWorldIntentHandler, we can delete that intent handler. That’s easy because it’s defined in its own JavaScript file at lambda/HelloWorldIntentHandler.js. So just delete that file:

 $​ rm lambda/HelloWorldIntentHandler.js

The HelloWorldIntentHandler is referenced in lambda/index.js in a couple of places that will also need to be removed. Near the top of index.js is the line where the HelloWorldIntentHandler module is imported with require():

 const​ HelloWorldIntentHandler = require(​'./HelloWorldIntentHandler'​);

Remove that line as well as the line in which the HelloWorldIntentHandler constant is registered with the skill builder:

 exports.handler = Alexa.SkillBuilders.custom()
  .addRequestHandlers(
» HelloWorldIntentHandler,
  )

With no intent handler for the HelloWorldIntent, we no longer need the HELLO_MSG entries in lambda/languageStrings.js, so they can also be removed. There should be two such entries, one for English…

 HELLO_MSG: ​'Have a stellar day!'​,

…and another one for Spanish:

 HELLO_MSG: ​'¡Que tengas un día estelar!'​,

Now all traces of the HelloWorldIntent are gone from the skill’s fulfillment code and interaction model. All that’s left is to remove the tests that trigger that intent:

 $​ rm test/unit/hello.test.yml
 $​ rm test/unity/hello-given-name.test.yml

With that extra baggage gone, let’s have a look at a few of the built-in intents and see how to improve the responses.

Fine-Tuning Response Messages

As we’ve added new intent handlers to our skill, we’ve made sure that the textual responses are well-written and fitting to their respective intents. But there are a few intents given by the “Hello World” template that we’ve not paid much attention to. The AMAZON.CancelIntent, AMAZON.StopIntent, and AMAZON.FallbackIntent still respond with the same text as when we first created the skill. Let’s have a quick look at them to see if there’s any opportunity for improvement.

Fortunately, all of those intents are handled by simply having Alexa speak a fixed message defined in languageStrings.js. If we want to tweak those messages, all of the work can be done by editing that file. The English values for those localized strings are defined like this:

 GOODBYE_MSG: ​'Goodbye!'​,
 FALLBACK_MSG: ​'Sorry, I don​​'​​t know about that. Please try again.'​,

The GOODBYE_MSG string is used for both AMAZON.StopIntent and AMAZON.CancelIntent while FALLBACK_MSG is used for AMAZON.FallbackIntent. We can customize them for our skill like this:

 GOODBYE_MSG: ​'Goodbye and thanks for traveling with '​ +
 'Star Port 75 Travel!'​,
 FALLBACK_MSG: ​'I​​'​​m not sure that I can help with that. '​ +
 'Please ask again.'​,

Likewise, the Spanish messages can be changed to match:

 GOODBYE_MSG: ​'¡Adiós y gracias por viajar con Star Port 75 Travel!'​,
 FALLBACK_MSG: ​'No estoy seguro de poder ayudar con eso. '​ +
 'Por favor pregunte nuevamente.'​,

With the new messages defined, the tests that trigger those intents will also need to be updated:

 ---
 configuration:
  description: ​Tests for standard request handlers
 
 ---
 - test: ​Cancel request
 - ​AMAZON.CancelIntent​:
» - prompt: ​Goodbye and thanks for traveling with Star Port 75 Travel!
 
 ---
 - test: ​Stop request
 - ​AMAZON.StopIntent​:
» - prompt: ​Goodbye and thanks for traveling with Star Port 75 Travel!
 
 ---
 - test: ​Fallback Intent
 - ​AMAZON.FallbackIntent​:
» - prompt: ​I'm not sure that I can help with that. Please ask again.
 
 ---
 - test: ​Session ended request
 - SessionEndedRequest:

These changes may seem insignificant, but it’s important that our skill has its own personality and that the messages are set apart from the “Hello World” template that we started with.

Another way to give a skill its own identity is in how we define the skill manifest. Let’s crack open the skill.json file and make sure it’s ready for publication.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.108.196