0

The launch (New Session), unhandled, and Amazon default intents (cancel, help, stop) are working properly when I test them in the service simulator, but any one that I write doesn't seem to work. Below is an example of a test intent:

var handlers = {
'NewSession': function() {
    this.emit(':tell', 'Hello');

'Test': function() {
    this.emit(':tell','This intent is working');    
},     
'Unhandled': function() {
    this.emit(':tell','Sorry, I don\'t know what to do');    
},   
'AMAZON.HelpIntent': function(){
    this.emit(':ask', 'What can I help you with?', 'How can I help?');
},
'AMAZON.CancelIntent': function(){
    this.emit(':tell', 'Okay');
},
'AMAZON.StopIntent': function(){
      this.emit(':tell', 'Goodbye');
},


exports.handler = function(event,context){
var alexa = Alexa.handler(event,context);
alexa.registerHandlers(handlers);
alexa.execute();
};

The code snippet for the intents:

 "intents": [
  {
    "name": "AMAZON.CancelIntent",
    "samples": []
  },
  {
    "name": "AMAZON.HelpIntent",
    "samples": []
  },
  {
    "name": "AMAZON.StopIntent",
    "samples": []
  },
  {
    "name": "ColorIntent",
    "samples": [],
    "slots": [
  {
    "name": "Test",
    "samples": [
      "Test me"
    ],
    "slots": []

No matter what I do, I can't get the test intent to work and return "This intent is working'. Please help!

Chacko
  • 1,506
  • 1
  • 20
  • 42
kd1996
  • 3
  • 1
  • Code and intent are not complete. Is it something you missed while copying? For eg: `NewSession` function is not closed by `}` `ColorIntent` intent is also not closed. Are your code and intents building fine? – Chacko Dec 19 '17 at 12:51
  • Yeah, I copied and pasted haphazardly, but all the brackets should match. The code and intents are building fine without any errors – kd1996 Dec 19 '17 at 22:05
  • Add logging to your code and see which intent is getting invoked. It is not possible to help without error logs – Chacko Dec 20 '17 at 09:07
  • How do I add logging to my code? – kd1996 Dec 20 '17 at 22:28

1 Answers1

3

Maybe it's because your first invocation always gets handled by the NewSession handler, which then responds with 'Hello' and ends the session. I see two ways to activate your Test handler, i.e. to get your Skill to respond with 'This intent is working':

  1. You create a multi-turn conversation by ending your NewSession handler with this.emit(':ask', 'Hello! What do you want to do next?');, and then uttering 'Test me'.
  2. You replace your NewSession handler with a LaunchRequest handler, and invoke your Skill with 'Alexa, tell tie picker to test me'.

Hope that helps! :)

By the way, because I can't comment everywhere yet: You can log your lambda's state, e.g. for debugging, by using console.log( 'Test handler invoked');, and then looking up the logs in AWS CloudWatch.