alexa-js / alexa-app

A framework for Alexa (Amazon Echo) apps using Node.js
https://www.youtube.com/watch?v=pzM4jv7k7Rg
MIT License
1.03k stars 212 forks source link

No intent gets called - "App Launch" does work #333

Closed JustMeDaFaq closed 5 years ago

JustMeDaFaq commented 6 years ago

Hi, when using this interaction model:

{
    "interactionModel": {
        "languageModel": {
            "invocationName": "testintent",
            "intents": [
                {
                    "name": "AMAZON.CancelIntent",
                    "samples": []
                },
                {
                    "name": "AMAZON.HelpIntent",
                    "samples": []
                },
                {
                    "name": "AMAZON.StopIntent",
                    "samples": []
                },
                {
                    "name": "TestIntent",
                    "slots": [],
                    "samples": [
                        "tomato say me hello world"
                    ]
                }
            ],
            "types": []
        }
    }
}

calling "testintent" in amazons test console/alexa simulator correctly response with "You launched the app" (also console logs it), tho when then trying to invoke an intent by calling: "tomato say me hello world" or "testintent tomato say me hello world", it seems that the endpoint does not get loaded/called actually. So, launching app works but intents doesnt, what am i doing wrong?

Using following nodejs code:

var express = require("express");
var alexa = require("alexa-app");
var app = express();
var http = require("http"),
    https = require("https")
var alexaApp = new alexa.app("test");

alexaApp.express({
  expressApp: app,
  checkCert: false,
  debug: true
});

// now POST calls to /test in express will be handled by the app.request() function

// from here on you can setup any other express routes or middlewares as normal
app.set("view engine", "ejs");

alexaApp.launch(function(request, response) {
  console.log("yay");
  response.say("You launched the app!");
});

alexaApp.intent("TestIntent", {
    "utterances": [
      "tomato say me hello world"
    ]
  },
  function(request, response) {
      console.log("suc");
    response.say("Success!");
  }
);

var fs = require("fs");
var privateKey  = fs.readFileSync("./cer/privkey.pem", "utf8");
var certificate = fs.readFileSync("./cer/cert.pem", "utf8");
var credentials = {key: privateKey, cert: certificate};

var httpsServer = https.createServer(credentials, app);
httpsServer.listen(443);

Does someone may know, what im doing wrong?

kobim commented 6 years ago

Hi @JustMeDaFaq, Are you using the Alexa test simulator for testing? Also, can you verify that your http server is running properly (and the certificate is valid) against the url you provided for your alexa skill?

JustMeDaFaq commented 6 years ago

Yeah, certificate gets called. Using Alexa Test Simulator, the new one on the Homepage.

Writing testintent works, it triggers the 'you launched the app" stuff correctly. (alexaApp.launch)

Just not when using alexaApp.intent :)

kobim commented 6 years ago

If you are using the test simulator, can you take a look at the request it outputs in the Skill I/O tab? Also, try to invoke ask testintent to tomato say me hello world as your command.

JustMeDaFaq commented 6 years ago

ask testintent to tomato say me hello world => Works. How would i create a skill that just gets called by "tomato say me hello world " ?

kobim commented 6 years ago

You can read more about it at Invoking a Skill with a Specific Request , but I'm afraid the closest you will get is Alexa, say me hello world using tomato if your invocationName is tomato and your utterances include "say me hello world".

I'm pretty sure the usage of "connecting words" is there so Alexa could distinguish between different skills and route the request to the right one. If you want to elaborate on your use-case, we might be able to find the right utterance(s).

kobim commented 5 years ago

Good news! as Alexa's name-free interactions and skill discovery is in public beta, #378 will soon be merged and you will be able to resolve the issue you were having.

There's another issue (#367) with more links to developer documentation if you want to take a look.

DeepakDonde commented 5 years ago

I am facing the same issue when using Alexa simulator. But when I test with Manual JSON it works!!!!

I think nothing is wrong with your code.I will check on real Alexa device just to make sure that the problem is only with Alexa simulator.

Edit:I tried on alexa device but only App Launch is working.Intent calls are not delivered to webhook.

FunnyDevs commented 5 years ago

I have same problem, only app launch is working.

DeepakDonde commented 5 years ago

I am able to resolve this issue. The problem is with maintaining the session.When launch request fires, You need to keep session alive. shouldEndSession is the Boolean parameter which is used to maintain session.

Below link explains how it works: https://developer.amazon.com/docs/gadget-skills/keep-session-open.html

FunnyDevs commented 5 years ago

now it works! Thank you